Dotclear

Changeset 2683:fb8aa74332f1 for inc


Ignore:
Timestamp:
03/13/14 11:42:57 (11 years ago)
Author:
Dsls
Branch:
twig
Parents:
2656:95fe4eacc716 (diff), 2682:cac55fdd7178 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge with default

Location:
inc
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • inc/core/class.dc.core.php

    r2650 r2683  
    44# This file is part of Dotclear 2. 
    55# 
    6 # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear 
     6# Copyright (c) 2003-2014 Olivier Meunier & Association Dotclear 
    77# Licensed under the GPL version 2.0 license. 
    88# See LICENSE file or 
     
    102102           
    103103          $this->log = new dcLog($this); 
    104            
    105           $this->addFormater('xhtml', create_function('$s','return $s;')); 
    106           $this->addFormater('wiki', array($this,'wikiTransform')); 
    107           $this->loadTemplateEnvironment(); 
    108104     } 
    109105      
     
    248244     //@} 
    249245      
    250       
    251246     /// @name Text Formatters methods 
    252247     //@{ 
     
    255250     transform text. The function must be a valid callback and takes one 
    256251     argument: the string to transform. It returns the transformed string. 
     252 
     253     @param    editor_id <b>string</b>  Editor id (dcLegacyEditor, dcCKEditor, ...) 
     254     @param    name      <b>string</b>  Formater name 
     255     @param    func      <b>callback</b>     Function to use, must be a valid and callable callback 
     256     */ 
     257     public function addEditorFormater($editor_id,$name,$func) 
     258     { 
     259          if (is_callable($func)) { 
     260               $this->formaters[$editor_id][$name] = $func; 
     261          } 
     262     } 
     263      
     264     /// @name Text Formatters methods 
     265     //@{ 
     266     /** 
     267     Adds a new text formater which will call the function <var>$func</var> to 
     268     transform text. The function must be a valid callback and takes one 
     269     argument: the string to transform. It returns the transformed string. 
    257270      
    258271     @param    name      <b>string</b>       Formater name 
     
    261274     public function addFormater($name,$func) 
    262275     { 
    263           if (is_callable($func)) { 
    264                $this->formaters[$name] = $func; 
    265           } 
    266      } 
    267       
    268      /** 
    269      Returns formaters list. 
    270       
     276          $this->addEditorFormater('dcLegacyEditor',$name,$func); 
     277     } 
     278 
     279     /** 
     280     Returns editors list 
     281 
     282     @return   <b>array</b> An array of editors values. 
     283     */ 
     284     public function getEditors() 
     285     { 
     286          $editors = array(); 
     287 
     288          foreach (array_keys($this->formaters) as $editor_id) { 
     289               $editors[$editor_id] = $this->plugins->moduleInfo($editor_id,'name'); 
     290          } 
     291 
     292          return $editors; 
     293     } 
     294      
     295     /** 
     296     Returns formaters list by editor 
     297      
     298     @param    editor_id <b>string</b>  Editor id (dcLegacyEditor, dcCKEditor, ...) 
    271299     @return   <b>array</b> An array of formaters names in values. 
    272      */ 
    273      public function getFormaters() 
    274      { 
    275           return array_keys($this->formaters); 
     300 
     301    /** 
     302    if @param editor_id is empty: 
     303    return all formaters sorted by actives editors 
     304     
     305    if @param editor_id is not empty 
     306    return formaters for an editor if editor is active 
     307    return empty() array if editor is not active.  
     308    It can happens when a user choose an editor and admin deactivate that editor later 
     309     */ 
     310     public function getFormaters($editor_id='') 
     311     { 
     312          $formaters_list = array(); 
     313 
     314          if (!empty($editor_id)) { 
     315            if (isset($this->formaters[$editor_id])) { 
     316                $formaters_list = array_keys($this->formaters[$editor_id]); 
     317            } 
     318          } else { 
     319               foreach ($this->formaters as $editor => $formaters) { 
     320                    $formaters_list[$editor] = array_keys($formaters); 
     321               } 
     322          } 
     323 
     324          return $formaters_list; 
    276325     } 
    277326      
     
    280329     transformed using that formater. 
    281330      
     331     @param    editor_id <b>string</b>  Editor id (dcLegacyEditor, dcCKEditor, ...) 
    282332     @param    name      <b>string</b>       Formater name 
    283333     @param    str       <b>string</b>       String to transform 
    284334     @return   <b>string</b>  String transformed 
    285335     */ 
     336     public function callEditorFormater($editor_id,$name,$str) 
     337     { 
     338          if (isset($this->formaters[$editor_id]) && isset($this->formaters[$editor_id][$name])) { 
     339               return call_user_func($this->formaters[$editor_id][$name],$str); 
     340          } 
     341           
     342          return $str; 
     343     } 
     344     //@} 
     345      
     346     /** 
     347     If <var>$name</var> is a valid formater, it returns <var>$str</var> 
     348     transformed using that formater. 
     349 
     350     @param    name      <b>string</b>       Formater name 
     351     @param    str       <b>string</b>       String to transform 
     352     @return   <b>string</b>  String transformed 
     353     */ 
    286354     public function callFormater($name,$str) 
    287355     { 
    288           if (isset($this->formaters[$name])) { 
    289                return call_user_func($this->formaters[$name],$str); 
    290           } 
    291            
    292           return $str; 
     356          return $this->callEditorFormater('dcLegacyEditor',$name,$str); 
    293357     } 
    294358     //@} 
    295       
     359 
    296360      
    297361     /// @name Behaviors methods 
  • inc/core/class.dc.core.php

    r2682 r2683  
    3939     public $rest;       ///< <b>dcRestServer</b> dcRestServer object 
    4040     public $log;        ///< <b>dcLog</b>             dcLog object 
     41     public $tpl;        ///< <b>Twig_Environment</b>  Twig_Environment object 
    4142     public $stime;      ///< <b>float</b>             starting time 
    42  
     43      
    4344     private $versions = null; 
    4445     private $formaters = array(); 
    4546     private $behaviors = array(); 
    4647     private $post_types = array(); 
    47  
     48      
    4849     /** 
    4950     dcCore constructor inits everything related to Dotclear. It takes arguments 
    5051     to init database connection. 
    51  
     52      
    5253     @param    driver    <b>string</b>  Database driver name 
    5354     @param    host      <b>string</b>  Database hostname 
     
    6768 
    6869          $this->con = dbLayer::init($driver,$host,$db,$user,$password,$persist); 
    69  
     70           
    7071          # define weak_locks for mysql 
    7172          if ($this->con instanceof mysqlConnection) { 
     
    7475               mysqliConnection::$weak_locks = true; 
    7576          } 
    76  
     77           
    7778          # define searchpath for postgresql 
    7879          if ($this->con instanceof pgsqlConnection) 
     
    8687               } 
    8788          } 
    88  
     89           
    8990          $this->prefix = $prefix; 
    90  
     91           
    9192          $this->error = new dcError(); 
    9293          $this->auth = $this->authInstance(); 
    9394          $this->session = new sessionDB($this->con,$this->prefix.'session',DC_SESSION_NAME,'',null,DC_ADMIN_SSL); 
    9495          $this->url = new dcUrlHandlers(); 
    95  
     96           
    9697          $this->plugins = new dcPlugins($this); 
    97  
     98           
    9899          $this->rest = new dcRestServer($this); 
    99  
     100           
    100101          $this->meta = new dcMeta($this); 
    101  
     102           
    102103          $this->log = new dcLog($this); 
    103104     } 
    104  
     105      
    105106     private function authInstance() 
    106107     { 
     
    112113               $c = DC_AUTH_CLASS; 
    113114          } 
    114  
     115           
    115116          if (!class_exists($c)) { 
    116117               throw new Exception('Authentication class '.$c.' does not exist.'); 
    117118          } 
    118  
     119           
    119120          if ($c != 'dcAuth' && !is_subclass_of($c,'dcAuth')) { 
    120121               throw new Exception('Authentication class '.$c.' does not inherit dcAuth.'); 
    121122          } 
    122  
     123           
    123124          return new $c($this); 
    124125     } 
    125  
    126  
     126      
     127     /** 
     128     Create template environment (Twig_Environment instance) 
     129      
     130     default-templates path must be added from admin|public/prepend.php with: 
     131     $core->tpl->getLoader()->addPath('PATH_TO/default-templates'); 
     132     Selected theme path must be added with: 
     133     $core->tpl->getLoader()->prependPath('PATH_TO/MY_THEME'); 
     134     */ 
     135     public function loadTemplateEnvironment() 
     136     { 
     137          $cache_dir = path::real(DC_TPL_CACHE.'/twtpl',false); 
     138          if (!is_dir($cache_dir)) { 
     139               try { 
     140                    files::makeDir($cache_dir); 
     141               } catch (Exception $e) { 
     142                    $cache_dir = false; 
     143               } 
     144          } 
     145           
     146          $this->tpl = new Twig_Environment( 
     147               new Twig_Loader_Filesystem(dirname(__FILE__).'/../swf'), 
     148               array( 
     149                    'auto_reload' => true, 
     150                    'autoescape' => false, 
     151                    'base_template_class' => 'Twig_Template', 
     152                    'cache' => $cache_dir,  
     153                    'charset' => 'UTF-8', 
     154                    'debug' => DC_DEBUG, 
     155                    'optimizations' => -1, 
     156                    'strict_variables' => 0 //DC_DEBUG // Please fix undefined variables! 
     157               ) 
     158          ); 
     159          $this->tpl->addExtension(new dcFormExtension($this)); 
     160          $this->tpl->addExtension(new dcTabExtension($this)); 
     161     } 
     162      
    127163     /// @name Blog init methods 
    128164     //@{ 
    129165     /** 
    130166     Sets a blog to use in <var>blog</var> property. 
    131  
     167      
    132168     @param    id        <b>string</b>       Blog ID 
    133169     */ 
     
    136172          $this->blog = new dcBlog($this, $id); 
    137173     } 
    138  
     174      
    139175     /** 
    140176     Unsets <var>blog</var> property. 
     
    145181     } 
    146182     //@} 
    147  
    148  
     183      
     184      
    149185     /// @name Blog status methods 
    150186     //@{ 
    151187     /** 
    152188     Returns an array of available blog status codes and names. 
    153  
     189      
    154190     @return   <b>array</b> Simple array with codes in keys and names in value 
    155191     */ 
     
    162198          ); 
    163199     } 
    164  
     200      
    165201     /** 
    166202     Returns a blog status name given to a code. This is intended to be 
    167203     human-readable and will be translated, so never use it for tests. 
    168204     If status code does not exist, returns <i>offline</i>. 
    169  
     205      
    170206     @param    s    <b>integer</b> Status code 
    171207     @return   <b>string</b> Blog status name 
     
    180216     } 
    181217     //@} 
    182  
     218      
    183219     /// @name Admin nonce secret methods 
    184220     //@{ 
    185  
     221      
    186222     public function getNonce() 
    187223     { 
    188224          return crypt::hmac(DC_MASTER_KEY,session_id()); 
    189225     } 
    190  
     226      
    191227     public function checkNonce($secret) 
    192228     { 
     
    194230               return false; 
    195231          } 
    196  
     232           
    197233          return $secret == crypt::hmac(DC_MASTER_KEY,session_id()); 
    198234     } 
    199  
     235      
    200236     public function formNonce() 
    201237     { 
     
    203239               return; 
    204240          } 
    205  
     241           
    206242          return form::hidden(array('xd_check'),$this->getNonce()); 
    207243     } 
    208244     //@} 
    209  
     245      
    210246     /// @name Text Formatters methods 
    211247     //@{ 
     
    225261          } 
    226262     } 
    227  
     263      
    228264     /// @name Text Formatters methods 
    229265     //@{ 
     
    232268     transform text. The function must be a valid callback and takes one 
    233269     argument: the string to transform. It returns the transformed string. 
    234  
     270      
    235271     @param    name      <b>string</b>       Formater name 
    236272     @param    func      <b>callback</b>     Function to use, must be a valid and callable callback 
     
    256292          return $editors; 
    257293     } 
    258  
     294      
    259295     /** 
    260296     Returns formaters list by editor 
    261  
     297      
    262298     @param    editor_id <b>string</b>  Editor id (dcLegacyEditor, dcCKEditor, ...) 
    263299     @return   <b>array</b> An array of formaters names in values. 
     
    288324          return $formaters_list; 
    289325     } 
    290  
     326      
    291327     /** 
    292328     If <var>$name</var> is a valid formater, it returns <var>$str</var> 
    293329     transformed using that formater. 
    294  
     330      
    295331     @param    editor_id <b>string</b>  Editor id (dcLegacyEditor, dcCKEditor, ...) 
    296332     @param    name      <b>string</b>       Formater name 
     
    303339               return call_user_func($this->formaters[$editor_id][$name],$str); 
    304340          } 
    305  
     341           
    306342          return $str; 
    307343     } 
    308344     //@} 
    309  
     345      
    310346     /** 
    311347     If <var>$name</var> is a valid formater, it returns <var>$str</var> 
     
    322358     //@} 
    323359 
    324  
     360      
    325361     /// @name Behaviors methods 
    326362     //@{ 
     
    328364     Adds a new behavior to behaviors stack. <var>$func</var> must be a valid 
    329365     and callable callback. 
    330  
     366      
    331367     @param    behavior  <b>string</b>       Behavior name 
    332368     @param    func      <b>callback</b>     Function to call 
     
    338374          } 
    339375     } 
    340  
     376      
    341377     /** 
    342378     Tests if a particular behavior exists in behaviors stack. 
    343  
     379      
    344380     @param    behavior  <b>string</b>  Behavior name 
    345381     @return   <b>boolean</b> 
     
    349385          return isset($this->behaviors[$behavior]); 
    350386     } 
    351  
     387      
    352388     /** 
    353389     Get behaviors stack (or part of). 
    354  
     390      
    355391     @param    behavior  <b>string</b>       Behavior name 
    356392     @return   <b>array</b> 
     
    359395     { 
    360396          if (empty($this->behaviors)) return null; 
    361  
     397           
    362398          if ($behavior == '') { 
    363399               return $this->behaviors; 
     
    365401               return $this->behaviors[$behavior]; 
    366402          } 
    367  
     403           
    368404          return array(); 
    369405     } 
    370  
     406      
    371407     /** 
    372408     Calls every function in behaviors stack for a given behavior and returns 
    373409     concatened result of each function. 
    374  
     410      
    375411     Every parameters added after <var>$behavior</var> will be pass to 
    376412     behavior calls. 
    377  
     413      
    378414     @param    behavior  <b>string</b>  Behavior name 
    379415     @return   <b>string</b> Behavior concatened result 
     
    385421               $args = func_get_args(); 
    386422               array_shift($args); 
    387  
     423                
    388424               $res = ''; 
    389  
     425                
    390426               foreach ($this->behaviors[$behavior] as $f) { 
    391427                    $res .= call_user_func_array($f,$args); 
    392428               } 
    393  
     429                
    394430               return $res; 
    395431          } 
    396432     } 
    397433     //@} 
    398  
     434      
    399435     /// @name Post types URLs management 
    400436     //@{ 
     
    404440               $type = 'post'; 
    405441          } 
    406  
     442           
    407443          $url = sprintf($this->post_types[$type]['admin_url'],$post_id); 
    408444          return $escaped ? html::escapeURL($url) : $url; 
    409445     } 
    410  
     446      
    411447     public function getPostPublicURL($type,$post_url,$escaped=true) 
    412448     { 
     
    414450               $type = 'post'; 
    415451          } 
    416  
     452           
    417453          $url = sprintf($this->post_types[$type]['public_url'],$post_url); 
    418454          return $escaped ? html::escapeURL($url) : $url; 
    419455     } 
    420  
     456      
    421457     public function setPostType($type,$admin_url,$public_url,$label='') 
    422458     { 
     
    427463          ); 
    428464     } 
    429  
     465      
    430466     public function getPostTypes() 
    431467     { 
     
    433469     } 
    434470     //@} 
    435  
     471      
    436472     /// @name Versions management methods 
    437473     //@{ 
    438474     /** 
    439475     Returns a given $module version. 
    440  
     476      
    441477     @param    module    <b>string</b>  Module name 
    442478     @return   <b>string</b>  Module version 
     
    449485               $strReq = 'SELECT module, version FROM '.$this->prefix.'version'; 
    450486               $rs = $this->con->select($strReq); 
    451  
     487                
    452488               while ($rs->fetch()) { 
    453489                    $this->versions[$rs->module] = $rs->version; 
    454490               } 
    455491          } 
    456  
     492           
    457493          if (isset($this->versions[$module])) { 
    458494               return $this->versions[$module]; 
     
    461497          } 
    462498     } 
    463  
     499      
    464500     /** 
    465501     Sets $version to given $module. 
    466  
     502      
    467503     @param    module    <b>string</b>  Module name 
    468504     @param    version   <b>string</b>  Module version 
     
    471507     { 
    472508          $cur_version = $this->getVersion($module); 
    473  
     509           
    474510          $cur = $this->con->openCursor($this->prefix.'version'); 
    475511          $cur->module = (string) $module; 
    476512          $cur->version = (string) $version; 
    477  
     513           
    478514          if ($cur_version === null) { 
    479515               $cur->insert(); 
     
    481517               $cur->update("WHERE module='".$this->con->escape($module)."'"); 
    482518          } 
    483  
     519           
    484520          $this->versions[$module] = $version; 
    485521     } 
    486  
     522      
    487523     /** 
    488524     Removes given $module version entry. 
    489  
     525      
    490526     @param    module    <b>string</b>  Module name 
    491527     */ 
     
    495531          'DELETE FROM '.$this->prefix.'version '. 
    496532          "WHERE module = '".$this->con->escape($module)."' "; 
    497  
     533           
    498534          $this->con->execute($strReq); 
    499  
     535           
    500536          if (is_array($this->versions)) { 
    501537               unset($this->versions[$module]); 
    502538          } 
    503539     } 
    504  
     540      
    505541     //@} 
    506  
     542      
    507543     /// @name Users management methods 
    508544     //@{ 
    509545     /** 
    510546     Returns a user by its ID. 
    511  
     547      
    512548     @param    id        <b>string</b>       User ID 
    513549     @return   <b>record</b> 
     
    516552     { 
    517553          $params['user_id'] = $id; 
    518  
     554           
    519555          return $this->getUsers($params); 
    520556     } 
    521  
     557      
    522558     /** 
    523559     Returns a users list. <b>$params</b> is an array with the following 
    524560     optionnal parameters: 
    525  
     561      
    526562      - <var>q</var>: search string (on user_id, user_name, user_firstname) 
    527563      - <var>user_id</var>: user ID 
    528564      - <var>order</var>: ORDER BY clause (default: user_id ASC) 
    529565      - <var>limit</var>: LIMIT clause (should be an array ![limit,offset]) 
    530  
     566      
    531567     @param    params         <b>array</b>        Parameters 
    532568     @param    count_only     <b>boolean</b>      Only counts results 
     
    553589               'WHERE NULL IS NULL '; 
    554590          } 
    555  
     591           
    556592          if (!empty($params['q'])) { 
    557593               $q = $this->con->escape(str_replace('*','%',strtolower($params['q']))); 
     
    562598                    ') '; 
    563599          } 
    564  
     600           
    565601          if (!empty($params['user_id'])) { 
    566602               $strReq .= "AND U.user_id = '".$this->con->escape($params['user_id'])."' "; 
    567603          } 
    568  
     604           
    569605          if (!$count_only) { 
    570606               $strReq .= 'GROUP BY U.user_id,user_super,user_status,user_pwd,user_change_pwd,'. 
    571607               'user_name,user_firstname,user_displayname,user_email,user_url,'. 
    572608               'user_desc, user_lang,user_tz,user_post_status,user_options '; 
    573  
     609                
    574610               if (!empty($params['order']) && !$count_only) { 
    575611                    $strReq .= 'ORDER BY '.$this->con->escape($params['order']).' '; 
     
    578614               } 
    579615          } 
    580  
     616           
    581617          if (!$count_only && !empty($params['limit'])) { 
    582618               $strReq .= $this->con->limit($params['limit']); 
    583619          } 
    584  
     620           
    585621          $rs = $this->con->select($strReq); 
    586622          $rs->extend('rsExtUser'); 
    587623          return $rs; 
    588624     } 
    589  
     625      
    590626     /** 
    591627     Create a new user. Takes a cursor as input and returns the new user ID. 
    592  
     628      
    593629     @param    cur       <b>cursor</b>       User cursor 
    594630     @return   <b>string</b> 
     
    599635               throw new Exception(__('You are not an administrator')); 
    600636          } 
    601  
     637           
    602638          if ($cur->user_id == '') { 
    603639               throw new Exception(__('No user ID given')); 
    604640          } 
    605  
     641           
    606642          if ($cur->user_pwd == '') { 
    607643               throw new Exception(__('No password given')); 
    608644          } 
    609  
     645           
    610646          $this->getUserCursor($cur); 
    611  
     647           
    612648          if ($cur->user_creadt === null) { 
    613649               $cur->user_creadt = date('Y-m-d H:i:s'); 
    614650          } 
    615  
     651           
    616652          $cur->insert(); 
    617  
     653           
    618654          $this->auth->afterAddUser($cur); 
    619  
     655           
    620656          return $cur->user_id; 
    621657     } 
    622  
     658      
    623659     /** 
    624660     Updates an existing user. Returns the user ID. 
    625  
     661      
    626662     @param    id        <b>string</b>       User ID 
    627663     @param    cur       <b>cursor</b>       User cursor 
     
    631667     { 
    632668          $this->getUserCursor($cur); 
    633  
     669           
    634670          if (($cur->user_id !== null || $id != $this->auth->userID()) && 
    635671          !$this->auth->isSuperAdmin()) { 
    636672               throw new Exception(__('You are not an administrator')); 
    637673          } 
    638  
     674           
    639675          $cur->update("WHERE user_id = '".$this->con->escape($id)."' "); 
    640  
     676           
    641677          $this->auth->afterUpdUser($id,$cur); 
    642  
     678           
    643679          if ($cur->user_id !== null) { 
    644680               $id = $cur->user_id; 
    645681          } 
    646  
     682           
    647683          # Updating all user's blogs 
    648684          $rs = $this->con->select( 
     
    650686               "WHERE user_id = '".$this->con->escape($id)."' " 
    651687               ); 
    652  
     688           
    653689          while ($rs->fetch()) { 
    654690               $b = new dcBlog($this,$rs->blog_id); 
     
    656692               unset($b); 
    657693          } 
    658  
     694           
    659695          return $id; 
    660696     } 
    661  
     697      
    662698     /** 
    663699     Deletes a user. 
    664  
     700      
    665701     @param    id        <b>string</b>       User ID 
    666702     */ 
     
    670706               throw new Exception(__('You are not an administrator')); 
    671707          } 
    672  
     708           
    673709          if ($id == $this->auth->userID()) { 
    674710               return; 
    675711          } 
    676  
     712           
    677713          $rs = $this->getUser($id); 
    678  
     714           
    679715          if ($rs->nb_post > 0) { 
    680716               return; 
    681717          } 
    682  
     718           
    683719          $strReq = 'DELETE FROM '.$this->prefix.'user '. 
    684720                    "WHERE user_id = '".$this->con->escape($id)."' "; 
    685  
     721           
    686722          $this->con->execute($strReq); 
    687  
     723           
    688724          $this->auth->afterDelUser($id); 
    689725     } 
    690  
     726      
    691727     /** 
    692728     Checks whether a user exists. 
    693  
     729      
    694730     @param    id        <b>string</b>       User ID 
    695731     @return   <b>boolean</b> 
     
    700736                    'FROM '.$this->prefix.'user '. 
    701737                    "WHERE user_id = '".$this->con->escape($id)."' "; 
    702  
     738           
    703739          $rs = $this->con->select($strReq); 
    704  
     740           
    705741          return !$rs->isEmpty(); 
    706742     } 
    707  
     743      
    708744     /** 
    709745     Returns all user permissions as an array which looks like: 
    710  
     746      
    711747      - [blog_id] 
    712748        - [name] => Blog name 
    713749        - [url] => Blog URL 
    714750        - [p] 
    715           - [permission] => true 
     751          - [permission] => true 
    716752          - ... 
    717  
     753      
    718754     @param    id        <b>string</b>       User ID 
    719755     @return   <b>array</b> 
     
    725761                    'INNER JOIN '.$this->prefix.'blog B ON P.blog_id = B.blog_id '. 
    726762                    "WHERE user_id = '".$this->con->escape($id)."' "; 
    727  
     763           
    728764          $rs = $this->con->select($strReq); 
    729  
     765           
    730766          $res = array(); 
    731  
     767           
    732768          while ($rs->fetch()) 
    733769          { 
     
    738774               ); 
    739775          } 
    740  
     776           
    741777          return $res; 
    742778     } 
    743  
     779      
    744780     /** 
    745781     Sets user permissions. The <var>$perms</var> array looks like: 
    746  
     782      
    747783      - [blog_id] => '|perm1|perm2|' 
    748784      - ... 
    749  
     785      
    750786     @param    id        <b>string</b>       User ID 
    751787     @param    perms     <b>array</b>        Permissions array 
     
    756792               throw new Exception(__('You are not an administrator')); 
    757793          } 
    758  
     794           
    759795          $strReq = 'DELETE FROM '.$this->prefix.'permissions '. 
    760796                    "WHERE user_id = '".$this->con->escape($id)."' "; 
    761  
     797           
    762798          $this->con->execute($strReq); 
    763  
     799           
    764800          foreach ($perms as $blog_id => $p) { 
    765801               $this->setUserBlogPermissions($id, $blog_id, $p, false); 
    766802          } 
    767803     } 
    768  
     804      
    769805     /** 
    770806     Sets user permissions for a given blog. <var>$perms</var> is an array with 
    771807     permissions in values 
    772  
     808      
    773809     @param    id             <b>string</b>       User ID 
    774810     @param    blog_id        <b>string</b>       Blog ID 
     
    781817               throw new Exception(__('You are not an administrator')); 
    782818          } 
    783  
     819           
    784820          $no_perm = empty($perms); 
    785  
     821           
    786822          $perms = '|'.implode('|',array_keys($perms)).'|'; 
    787  
     823           
    788824          $cur = $this->con->openCursor($this->prefix.'permissions'); 
    789  
     825           
    790826          $cur->user_id = (string) $id; 
    791827          $cur->blog_id = (string) $blog_id; 
    792828          $cur->permissions = $perms; 
    793  
     829           
    794830          if ($delete_first || $no_perm) 
    795831          { 
     
    797833                         "WHERE blog_id = '".$this->con->escape($blog_id)."' ". 
    798834                         "AND user_id = '".$this->con->escape($id)."' "; 
    799  
     835                
    800836               $this->con->execute($strReq); 
    801837          } 
    802  
     838           
    803839          if (!$no_perm) { 
    804840               $cur->insert(); 
    805841          } 
    806842     } 
    807  
     843      
    808844     /** 
    809845     Sets a user default blog. This blog will be selected when user log in. 
    810  
     846      
    811847     @param    id             <b>string</b>       User ID 
    812848     @param    blog_id        <b>string</b>       Blog ID 
     
    815851     { 
    816852          $cur = $this->con->openCursor($this->prefix.'user'); 
    817  
     853           
    818854          $cur->user_default_blog = (string) $blog_id; 
    819  
     855           
    820856          $cur->update("WHERE user_id = '".$this->con->escape($id)."'"); 
    821857     } 
    822  
     858      
    823859     private function getUserCursor($cur) 
    824860     { 
     
    827863               throw new Exception(__('User ID must contain at least 2 characters using letters, numbers or symbols.')); 
    828864          } 
    829  
     865           
    830866          if ($cur->user_url !== null && $cur->user_url != '') { 
    831867               if (!preg_match('|^http(s?)://|',$cur->user_url)) { 
     
    833869               } 
    834870          } 
    835  
     871           
    836872          if ($cur->isField('user_pwd')) { 
    837873               if (strlen($cur->user_pwd) < 6) { 
     
    840876               $cur->user_pwd = crypt::hmac(DC_MASTER_KEY,$cur->user_pwd); 
    841877          } 
    842  
     878           
    843879          if ($cur->user_lang !== null && !preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$cur->user_lang)) { 
    844880               throw new Exception(__('Invalid user language code')); 
    845881          } 
    846  
     882           
    847883          if ($cur->user_upddt === null) { 
    848884               $cur->user_upddt = date('Y-m-d H:i:s'); 
    849885          } 
    850  
     886           
    851887          if ($cur->user_options !== null) { 
    852888               $cur->user_options = serialize((array) $cur->user_options); 
    853889          } 
    854890     } 
    855  
     891      
    856892     /** 
    857893     Returns user default settings in an associative array with setting names in 
    858894     keys. 
    859  
     895      
    860896     @return   <b>array</b> 
    861897     */ 
     
    869905     } 
    870906     //@} 
    871  
     907      
    872908     /// @name Blog management methods 
    873909     //@{ 
    874910     /** 
    875911     Returns all blog permissions (users) as an array which looks like: 
    876  
     912      
    877913      - [user_id] 
    878914        - [name] => User name 
     
    881917        - [super] => (true|false) super admin 
    882918        - [p] 
    883           - [permission] => true 
     919          - [permission] => true 
    884920          - ... 
    885  
     921      
    886922     @param    id             <b>string</b>       Blog ID 
    887923     @param    with_super     <b>boolean</b>      Includes super admins in result 
     
    896932          'JOIN '.$this->prefix.'permissions P ON U.user_id = P.user_id '. 
    897933          "WHERE blog_id = '".$this->con->escape($id)."' "; 
    898  
     934           
    899935          if ($with_super) { 
    900936               $strReq .= 
     
    905941               'WHERE user_super = 1 '; 
    906942          } 
    907  
     943           
    908944          $rs = $this->con->select($strReq); 
    909  
     945           
    910946          $res = array(); 
    911  
     947           
    912948          while ($rs->fetch()) 
    913949          { 
     
    921957               ); 
    922958          } 
    923  
     959           
    924960          return $res; 
    925961     } 
    926  
     962      
    927963     /** 
    928964     Returns a blog of given ID. 
    929  
     965      
    930966     @param    id        <b>string</b>       Blog ID 
    931967     @return   <b>record</b> 
     
    934970     { 
    935971          $blog = $this->getBlogs(array('blog_id'=>$id)); 
    936  
     972           
    937973          if ($blog->isEmpty()) { 
    938974               return false; 
    939975          } 
    940  
     976           
    941977          return $blog; 
    942978     } 
    943  
     979      
    944980     /** 
    945981     Returns a record of blogs. <b>$params</b> is an array with the following 
    946982     optionnal parameters: 
    947  
     983      
    948984      - <var>blog_id</var>: Blog ID 
    949985      - <var>q</var>: Search string on blog_id, blog_name and blog_url 
    950986      - <var>limit</var>: limit results 
    951  
     987      
    952988     @param    params         <b>array</b>        Parameters 
    953989     @param    count_only     <b>boolean</b>      Count only results 
     
    958994          $join = '';    // %1$s 
    959995          $where = '';   // %2$s 
    960  
     996           
    961997          if ($count_only) 
    962998          { 
     
    9761012               'WHERE NULL IS NULL '. 
    9771013               '%2$s '; 
    978  
     1014                
    9791015               if (!empty($params['order'])) { 
    9801016                    $strReq .= 'ORDER BY '.$this->con->escape($params['order']).' '; 
     
    9821018                    $strReq .= 'ORDER BY B.blog_id ASC '; 
    9831019               } 
    984  
     1020                
    9851021               if (!empty($params['limit'])) { 
    9861022                    $strReq .= $this->con->limit($params['limit']); 
    9871023               } 
    9881024          } 
    989  
     1025           
    9901026          if ($this->auth->userID() && !$this->auth->isSuperAdmin()) 
    9911027          { 
     
    9981034               $where = 'AND blog_status IN (1,0) '; 
    9991035          } 
    1000  
     1036           
    10011037          if (!empty($params['blog_id'])) { 
    10021038               $where .= "AND B.blog_id = '".$this->con->escape($params['blog_id'])."' "; 
    10031039          } 
    1004  
     1040           
    10051041          if (!empty($params['q'])) { 
    10061042               $params['q'] = strtolower(str_replace('*','%',$params['q'])); 
     
    10121048               ') '; 
    10131049          } 
    1014  
     1050           
    10151051          $strReq = sprintf($strReq,$join,$where); 
    10161052          return $this->con->select($strReq); 
    10171053     } 
    1018  
     1054      
    10191055     /** 
    10201056     Creates a new blog. 
    1021  
     1057      
    10221058     @param    cur            <b>cursor</b>       Blog cursor 
    10231059     */ 
     
    10271063               throw new Exception(__('You are not an administrator')); 
    10281064          } 
    1029  
     1065           
    10301066          $this->getBlogCursor($cur); 
    1031  
     1067           
    10321068          $cur->blog_creadt = date('Y-m-d H:i:s'); 
    10331069          $cur->blog_upddt = date('Y-m-d H:i:s'); 
    10341070          $cur->blog_uid = md5(uniqid()); 
    1035  
     1071           
    10361072          $cur->insert(); 
    10371073     } 
    1038  
     1074      
    10391075     /** 
    10401076     Updates a given blog. 
    1041  
     1077      
    10421078     @param    id        <b>string</b>       Blog ID 
    10431079     @param    cur       <b>cursor</b>       Blog cursor 
     
    10461082     { 
    10471083          $this->getBlogCursor($cur); 
    1048  
     1084           
    10491085          $cur->blog_upddt = date('Y-m-d H:i:s'); 
    1050  
     1086           
    10511087          $cur->update("WHERE blog_id = '".$this->con->escape($id)."'"); 
    10521088     } 
    1053  
     1089      
    10541090     private function getBlogCursor($cur) 
    10551091     { 
     
    10571093               && !preg_match('/^[A-Za-z0-9._-]{2,}$/',$cur->blog_id)) || 
    10581094               (!$cur->blog_id)) { 
    1059                throw new Exception(__('Blog ID must contain at least 2 characters using letters, numbers or symbols.')); 
    1060           } 
    1061  
     1095               throw new Exception(__('Blog ID must contain at least 2 characters using letters, numbers or symbols.'));  
     1096          } 
     1097           
    10621098          if (($cur->blog_name !== null && $cur->blog_name == '') || 
    10631099               (!$cur->blog_name)) { 
    10641100               throw new Exception(__('No blog name')); 
    10651101          } 
    1066  
     1102           
    10671103          if (($cur->blog_url !== null && $cur->blog_url == '') || 
    10681104               (!$cur->blog_url)) { 
    10691105               throw new Exception(__('No blog URL')); 
    10701106          } 
    1071  
     1107           
    10721108          if ($cur->blog_desc !== null) { 
    10731109               $cur->blog_desc = html::clean($cur->blog_desc); 
    10741110          } 
    10751111     } 
    1076  
     1112      
    10771113     /** 
    10781114     Removes a given blog. 
    10791115     @warning This will remove everything related to the blog (posts, 
    10801116     categories, comments, links...) 
    1081  
     1117      
    10821118     @param    id        <b>string</b>       Blog ID 
    10831119     */ 
     
    10871123               throw new Exception(__('You are not an administrator')); 
    10881124          } 
    1089  
     1125           
    10901126          $strReq = 'DELETE FROM '.$this->prefix.'blog '. 
    10911127                    "WHERE blog_id = '".$this->con->escape($id)."' "; 
    1092  
     1128           
    10931129          $this->con->execute($strReq); 
    10941130     } 
    1095  
     1131      
    10961132     /** 
    10971133     Checks if a blog exist. 
    1098  
     1134      
    10991135     @param    id        <b>string</b>       Blog ID 
    11001136     @return   <b>boolean</b> 
     
    11051141                    'FROM '.$this->prefix.'blog '. 
    11061142                    "WHERE blog_id = '".$this->con->escape($id)."' "; 
    1107  
     1143           
    11081144          $rs = $this->con->select($strReq); 
    1109  
     1145           
    11101146          return !$rs->isEmpty(); 
    11111147     } 
    1112  
     1148      
    11131149     /** 
    11141150     Count posts on a blog 
    1115  
     1151      
    11161152     @param    id        <b>string</b>       Blog ID 
    11171153     @param    type      <b>string</b>       Post type 
     
    11231159                    'FROM '.$this->prefix.'post '. 
    11241160                    "WHERE blog_id = '".$this->con->escape($id)."' "; 
    1125  
     1161           
    11261162          if ($type) { 
    11271163               $strReq .= "AND post_type = '".$this->con->escape($type)."' "; 
    11281164          } 
    1129  
     1165           
    11301166          return $this->con->select($strReq)->f(0); 
    11311167     } 
    11321168     //@} 
    1133  
     1169      
    11341170     /// @name HTML Filter methods 
    11351171     //@{ 
     
    11381174     tidy extension is present). If <b>enable_html_filter</b> blog setting is 
    11391175     false, returns not filtered string. 
    1140  
     1176      
    11411177     @param    str  <b>string</b>       String to filter 
    11421178     @return   <b>string</b> Filtered string. 
     
    11471183               return $str; 
    11481184          } 
    1149  
     1185           
    11501186          $filter = new htmlFilter; 
    11511187          $str = trim($filter->apply($str)); 
     
    11531189     } 
    11541190     //@} 
    1155  
     1191      
    11561192     /// @name wiki2xhtml methods 
    11571193     //@{ 
     
    11601196          $this->wiki2xhtml = new wiki2xhtml; 
    11611197     } 
    1162  
     1198      
    11631199     /** 
    11641200     Returns a transformed string with wiki2xhtml. 
    1165  
     1201      
    11661202     @param    str       <b>string</b>       String to transform 
    11671203     @return   <b>string</b>  Transformed string 
     
    11741210          return $this->wiki2xhtml->transform($str); 
    11751211     } 
    1176  
     1212      
    11771213     /** 
    11781214     Inits <var>wiki2xhtml</var> property for blog post. 
     
    11811217     { 
    11821218          $this->initWiki(); 
    1183  
     1219           
    11841220          $this->wiki2xhtml->setOpts(array( 
    11851221               'active_title' => 1, 
     
    12131249               'note_str' => '<div class="footnotes"><h4>Notes</h4>%s</div>' 
    12141250          )); 
    1215  
     1251           
    12161252          $this->wiki2xhtml->registerFunction('url:post',array($this,'wikiPostLink')); 
    1217  
     1253           
    12181254          # --BEHAVIOR-- coreWikiPostInit 
    12191255          $this->callBehavior('coreInitWikiPost',$this->wiki2xhtml); 
    12201256     } 
    1221  
     1257      
    12221258     /** 
    12231259     Inits <var>wiki2xhtml</var> property for simple blog comment (basic syntax). 
     
    12261262     { 
    12271263          $this->initWiki(); 
    1228  
     1264           
    12291265          $this->wiki2xhtml->setOpts(array( 
    12301266               'active_title' => 0, 
     
    12551291               'active_fr_syntax' => 0 
    12561292          )); 
    1257  
     1293           
    12581294          # --BEHAVIOR-- coreInitWikiSimpleComment 
    12591295          $this->callBehavior('coreInitWikiSimpleComment',$this->wiki2xhtml); 
    12601296     } 
    1261  
     1297      
    12621298     /** 
    12631299     Inits <var>wiki2xhtml</var> property for blog comment. 
     
    12661302     { 
    12671303          $this->initWiki(); 
    1268  
     1304           
    12691305          $this->wiki2xhtml->setOpts(array( 
    12701306               'active_title' => 0, 
     
    12951331               'active_fr_syntax' => 0 
    12961332          )); 
    1297  
     1333           
    12981334          # --BEHAVIOR-- coreInitWikiComment 
    12991335          $this->callBehavior('coreInitWikiComment',$this->wiki2xhtml); 
    13001336     } 
    1301  
     1337      
    13021338     public function wikiPostLink($url,$content) 
    13031339     { 
    1304           if (!($this->blog instanceof dcBlog)) { 
     1340          if (!($this->blog instanceof dcBlog)) {  
    13051341               return array(); 
    13061342          } 
    1307  
     1343           
    13081344          $post_id = abs((integer) substr($url,5)); 
    13091345          if (!$post_id) { 
    13101346               return array(); 
    13111347          } 
    1312  
     1348           
    13131349          $post = $this->blog->getPosts(array('post_id'=>$post_id)); 
    13141350          if ($post->isEmpty()) { 
    13151351               return array(); 
    13161352          } 
    1317  
     1353           
    13181354          $res = array('url' => $post->getURL()); 
    13191355          $post_title = $post->post_title; 
    1320  
     1356           
    13211357          if ($content != $url) { 
    13221358               $res['title'] = html::escapeHTML($post->post_title); 
    13231359          } 
    1324  
     1360           
    13251361          if ($content == '' || $content == $url) { 
    13261362               $res['content'] = html::escapeHTML($post->post_title); 
    13271363          } 
    1328  
     1364           
    13291365          if ($post->post_lang) { 
    13301366               $res['lang'] = $post->post_lang; 
    13311367          } 
    1332  
     1368           
    13331369          return $res; 
    13341370     } 
    13351371     //@} 
    1336  
     1372      
    13371373     /// @name Maintenance methods 
    13381374     //@{ 
     
    13401376     Creates default settings for active blog. Optionnal parameter 
    13411377     <var>defaults</var> replaces default params while needed. 
    1342  
     1378      
    13431379     @param    defaults       <b>array</b>   Default parameters 
    13441380     */ 
     
    14251461               ); 
    14261462          } 
    1427  
     1463           
    14281464          $settings = new dcSettings($this,null); 
    14291465          $settings->addNamespace('system'); 
    1430  
     1466           
    14311467          foreach ($defaults as $v) { 
    14321468               $settings->system->put($v[0],$v[2],$v[1],$v[3],false,true); 
    14331469          } 
    14341470     } 
    1435  
     1471      
    14361472     /** 
    14371473     Recreates entries search engine index. 
    1438  
     1474      
    14391475     @param    start     <b>integer</b>      Start entry index 
    14401476     @param    limit     <b>integer</b>      Number of entry to index 
    1441  
     1477      
    14421478     @return   <b>integer</b>      <var>$start</var> and <var>$limit</var> sum 
    14431479     */ 
     
    14481484          $rs = $this->con->select($strReq); 
    14491485          $count = $rs->f(0); 
    1450  
     1486           
    14511487          $strReq = 'SELECT post_id, post_title, post_excerpt_xhtml, post_content_xhtml '. 
    14521488                    'FROM '.$this->prefix.'post '; 
    1453  
     1489           
    14541490          if ($start !== null && $limit !== null) { 
    14551491               $strReq .= $this->con->limit($start,$limit); 
    14561492          } 
    1457  
     1493           
    14581494          $rs = $this->con->select($strReq,true); 
    1459  
     1495           
    14601496          $cur = $this->con->openCursor($this->prefix.'post'); 
    1461  
     1497           
    14621498          while ($rs->fetch()) 
    14631499          { 
    14641500               $words = $rs->post_title.' '. $rs->post_excerpt_xhtml.' '. 
    14651501               $rs->post_content_xhtml; 
    1466  
     1502                
    14671503               $cur->post_words = implode(' ',text::splitWords($words)); 
    14681504               $cur->update('WHERE post_id = '.(integer) $rs->post_id); 
    14691505               $cur->clean(); 
    14701506          } 
    1471  
     1507           
    14721508          if ($start+$limit > $count) { 
    14731509               return null; 
     
    14751511          return $start+$limit; 
    14761512     } 
    1477  
     1513      
    14781514     /** 
    14791515     Recreates comments search engine index. 
    1480  
     1516      
    14811517     @param    start     <b>integer</b>      Start comment index 
    14821518     @param    limit     <b>integer</b>      Number of comments to index 
    1483  
     1519      
    14841520     @return   <b>integer</b>      <var>$start</var> and <var>$limit</var> sum 
    14851521     */ 
     
    14901526          $rs = $this->con->select($strReq); 
    14911527          $count = $rs->f(0); 
    1492  
     1528           
    14931529          $strReq = 'SELECT comment_id, comment_content '. 
    14941530                    'FROM '.$this->prefix.'comment '; 
    1495  
     1531           
    14961532          if ($start !== null && $limit !== null) { 
    14971533               $strReq .= $this->con->limit($start,$limit); 
    14981534          } 
    1499  
     1535           
    15001536          $rs = $this->con->select($strReq); 
    1501  
     1537           
    15021538          $cur = $this->con->openCursor($this->prefix.'comment'); 
    1503  
     1539           
    15041540          while ($rs->fetch()) 
    15051541          { 
     
    15081544               $cur->clean(); 
    15091545          } 
    1510  
     1546           
    15111547          if ($start+$limit > $count) { 
    15121548               return null; 
     
    15141550          return $start+$limit; 
    15151551     } 
    1516  
     1552      
    15171553     /** 
    15181554     Reinits nb_comment and nb_trackback in post table. 
     
    15201556     public function countAllComments() 
    15211557     { 
    1522  
     1558      
    15231559          $updCommentReq = 'UPDATE '.$this->prefix.'post P '. 
    15241560               'SET nb_comment = ('. 
     
    15361572          $this->con->execute($updTrackbackReq); 
    15371573     } 
    1538  
     1574      
    15391575     /** 
    15401576     Empty templates cache directory 
     
    15491585     /** 
    15501586      Return elapsed time since script has been started 
    1551       @param     $mtime <b>float</b> timestamp (microtime format) to evaluate delta from 
    1552                                           current time is taken if null 
    1553       @return <b>float</b>          elapsed time 
     1587      @param   $mtime <b>float</b> timestamp (microtime format) to evaluate delta from 
     1588                                     current time is taken if null 
     1589      @return <b>float</b>        elapsed time 
    15541590      */ 
    15551591     public function getElapsedTime ($mtime=null) { 
  • inc/prepend.php

    r2654 r2683  
    7373$__autoload['adminModulesList']              = dirname(__FILE__).'/admin/lib.moduleslist.php'; 
    7474$__autoload['adminThemesList']               = dirname(__FILE__).'/admin/lib.moduleslist.php'; 
     75$__autoload['dcThemeConfig']     = dirname(__FILE__).'/admin/lib.themeconfig.php'; 
    7576 
    7677$__autoload['dcTemplate']               = dirname(__FILE__).'/public/class.dc.template.php'; 
  • inc/prepend.php

    r2657 r2683  
    1515 
    1616/* ------------------------------------------------------------------------------------------- */ 
    17 #  ClearBricks, DotClear classes auto-loader 
     17#  ClearBricks, Twig, DotClear classes auto-loader 
    1818if (@is_dir('/usr/lib/clearbricks')) { 
    1919     define('CLEARBRICKS_PATH','/usr/lib/clearbricks'); 
    20 } elseif (is_dir(dirname(__FILE__).'/libs/clearbricks')) { 
    21      define('CLEARBRICKS_PATH',dirname(__FILE__).'/libs/clearbricks'); 
     20} elseif (is_dir(dirname(__FILE__).'/../vendor/dotclear/clearbricks')) { 
     21     define('CLEARBRICKS_PATH',dirname(__FILE__).'/../vendor/dotclear/clearbricks'); 
    2222} elseif (isset($_SERVER['CLEARBRICKS_PATH']) && is_dir($_SERVER['CLEARBRICKS_PATH'])) { 
    2323     define('CLEARBRICKS_PATH',$_SERVER['CLEARBRICKS_PATH']); 
     
    2929 
    3030require CLEARBRICKS_PATH.'/_common.php'; 
    31 $__autoload['dcCore']        = dirname(__FILE__).'/core/class.dc.core.php'; 
    32 $__autoload['dcAuth']        = dirname(__FILE__).'/core/class.dc.auth.php'; 
    33 $__autoload['dcBlog']        = dirname(__FILE__).'/core/class.dc.blog.php'; 
    34 $__autoload['dcCategories']  = dirname(__FILE__).'/core/class.dc.categories.php'; 
    35 $__autoload['dcError']       = dirname(__FILE__).'/core/class.dc.error.php'; 
    36 $__autoload['dcMeta']        = dirname(__FILE__).'/core/class.dc.meta.php'; 
    37 $__autoload['dcMedia']       = dirname(__FILE__).'/core/class.dc.media.php'; 
    38 $__autoload['dcPostMedia']   = dirname(__FILE__).'/core/class.dc.postmedia.php'; 
    39 $__autoload['dcModules']     = dirname(__FILE__).'/core/class.dc.modules.php'; 
    40 $__autoload['dcPlugins']     = dirname(__FILE__).'/core/class.dc.plugins.php'; 
    41 $__autoload['dcThemes']      = dirname(__FILE__).'/core/class.dc.themes.php'; 
    42 $__autoload['dcRestServer']  = dirname(__FILE__).'/core/class.dc.rest.php'; 
    43 $__autoload['dcNamespace']   = dirname(__FILE__).'/core/class.dc.namespace.php'; 
    44 $__autoload['dcSettings']    = dirname(__FILE__).'/core/class.dc.settings.php'; 
    45 $__autoload['dcTrackback']   = dirname(__FILE__).'/core/class.dc.trackback.php'; 
    46 $__autoload['dcUpdate']      = dirname(__FILE__).'/core/class.dc.update.php'; 
    47 $__autoload['dcUtils']       = dirname(__FILE__).'/core/class.dc.utils.php'; 
    48 $__autoload['dcXmlRpc']      = dirname(__FILE__).'/core/class.dc.xmlrpc.php'; 
    49 $__autoload['dcLog']         = dirname(__FILE__).'/core/class.dc.log.php'; 
    50 $__autoload['dcWorkspace']   = dirname(__FILE__).'/core/class.dc.workspace.php'; 
    51 $__autoload['dcPrefs']       = dirname(__FILE__).'/core/class.dc.prefs.php'; 
    52 $__autoload['dcStore']       = dirname(__FILE__).'/core/class.dc.store.php'; 
    53 $__autoload['dcStoreReader'] = dirname(__FILE__).'/core/class.dc.store.reader.php'; 
    54 $__autoload['dcStoreParser'] = dirname(__FILE__).'/core/class.dc.store.parser.php'; 
    55 $__autoload['dcFavorites']   = dirname(__FILE__).'/admin/class.dc.favorites.php'; 
    56  
    57 $__autoload['rsExtPost']    = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 
    58 $__autoload['rsExtComment'] = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 
    59 $__autoload['rsExtDates']   = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 
    60 $__autoload['rsExtUser']    = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 
    61  
    62 $__autoload['dcMenu']            = dirname(__FILE__).'/admin/class.dc.menu.php'; 
    63 $__autoload['dcPage']            = dirname(__FILE__).'/admin/lib.dc.page.php'; 
    64 $__autoload['adminGenericList']  = dirname(__FILE__).'/admin/lib.pager.php'; 
    65 $__autoload['adminPostList']     = dirname(__FILE__).'/admin/lib.pager.php'; 
    66 $__autoload['adminPostMiniList'] = dirname(__FILE__).'/admin/lib.pager.php'; 
    67 $__autoload['adminCommentList']  = dirname(__FILE__).'/admin/lib.pager.php'; 
    68 $__autoload['adminUserList']     = dirname(__FILE__).'/admin/lib.pager.php'; 
    69 $__autoload['dcPager']           = dirname(__FILE__).'/admin/lib.pager.php'; 
    70 $__autoload['dcAdminCombos']     = dirname(__FILE__).'/admin/lib.admincombos.php'; 
    71 $__autoload['adminModulesList']  = dirname(__FILE__).'/admin/lib.moduleslist.php'; 
    72 $__autoload['adminThemesList']   = dirname(__FILE__).'/admin/lib.moduleslist.php'; 
     31$__autoload['dcCore']                   = dirname(__FILE__).'/core/class.dc.core.php'; 
     32$__autoload['dcAuth']                   = dirname(__FILE__).'/core/class.dc.auth.php'; 
     33$__autoload['dcBlog']                   = dirname(__FILE__).'/core/class.dc.blog.php'; 
     34$__autoload['dcCategories']             = dirname(__FILE__).'/core/class.dc.categories.php'; 
     35$__autoload['dcError']                  = dirname(__FILE__).'/core/class.dc.error.php'; 
     36$__autoload['dcMeta']                   = dirname(__FILE__).'/core/class.dc.meta.php'; 
     37$__autoload['dcMedia']                  = dirname(__FILE__).'/core/class.dc.media.php'; 
     38$__autoload['dcPostMedia']                   = dirname(__FILE__).'/core/class.dc.postmedia.php'; 
     39$__autoload['dcModules']                = dirname(__FILE__).'/core/class.dc.modules.php'; 
     40$__autoload['dcPlugins']                = dirname(__FILE__).'/core/class.dc.plugins.php'; 
     41$__autoload['dcThemes']                 = dirname(__FILE__).'/core/class.dc.themes.php'; 
     42$__autoload['dcRestServer']             = dirname(__FILE__).'/core/class.dc.rest.php'; 
     43$__autoload['dcNamespace']              = dirname(__FILE__).'/core/class.dc.namespace.php'; 
     44$__autoload['dcSettings']               = dirname(__FILE__).'/core/class.dc.settings.php'; 
     45$__autoload['dcTrackback']              = dirname(__FILE__).'/core/class.dc.trackback.php'; 
     46$__autoload['dcUpdate']                 = dirname(__FILE__).'/core/class.dc.update.php'; 
     47$__autoload['dcUtils']                  = dirname(__FILE__).'/core/class.dc.utils.php'; 
     48$__autoload['dcXmlRpc']                 = dirname(__FILE__).'/core/class.dc.xmlrpc.php'; 
     49$__autoload['dcLog']                    = dirname(__FILE__).'/core/class.dc.log.php'; 
     50$__autoload['dcWorkspace']              = dirname(__FILE__).'/core/class.dc.workspace.php'; 
     51$__autoload['dcPrefs']                  = dirname(__FILE__).'/core/class.dc.prefs.php'; 
     52$__autoload['dcTwigPage']               = dirname(__FILE__).'/core/class.dc.twig.page.php'; 
     53$__autoload['dcStore']             = dirname(__FILE__).'/core/class.dc.store.php'; 
     54$__autoload['dcStoreReader']       = dirname(__FILE__).'/core/class.dc.store.reader.php'; 
     55$__autoload['dcStoreParser']       = dirname(__FILE__).'/core/class.dc.store.parser.php'; 
     56$__autoload['dcFavorites']              = dirname(__FILE__).'/admin/class.dc.favorites.php'; 
     57 
     58$__autoload['rsExtPost']                = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 
     59$__autoload['rsExtComment']             = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 
     60$__autoload['rsExtDates']               = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 
     61$__autoload['rsExtUser']                = dirname(__FILE__).'/core/class.dc.rs.extensions.php'; 
     62 
     63$__autoload['dcAdminContext']                = dirname(__FILE__).'/admin/class.dc.admincontext.php'; 
     64$__autoload['dcMenu']                   = dirname(__FILE__).'/admin/class.dc.menu.php'; 
     65$__autoload['dcPage']                   = dirname(__FILE__).'/admin/lib.dc.page.php'; 
     66$__autoload['adminGenericList']         = dirname(__FILE__).'/admin/lib.pager.php'; 
     67$__autoload['adminPostList']            = dirname(__FILE__).'/admin/lib.pager.php'; 
     68$__autoload['adminPostMiniList']        = dirname(__FILE__).'/admin/lib.pager.php'; 
     69$__autoload['adminCommentList']         = dirname(__FILE__).'/admin/lib.pager.php'; 
     70$__autoload['adminUserList']            = dirname(__FILE__).'/admin/lib.pager.php'; 
     71$__autoload['dcPager']        = dirname(__FILE__).'/admin/lib.pager.php'; 
     72$__autoload['dcAdminCombos']            = dirname(__FILE__).'/admin/lib.admincombos.php'; 
     73$__autoload['adminModulesList']              = dirname(__FILE__).'/admin/lib.moduleslist.php'; 
     74$__autoload['adminThemesList']               = dirname(__FILE__).'/admin/lib.moduleslist.php'; 
    7375$__autoload['dcThemeConfig']     = dirname(__FILE__).'/admin/lib.themeconfig.php'; 
    7476 
    75 $__autoload['dcTemplate']            = dirname(__FILE__).'/public/class.dc.template.php'; 
    76 $__autoload['context']               = dirname(__FILE__).'/public/lib.tpl.context.php'; 
    77 $__autoload['dcUrlHandlers']         = dirname(__FILE__).'/public/lib.urlhandlers.php'; 
    78 $__autoload['dcPostsActionsPage']    = dirname(__FILE__).'/admin/actions/class.dcactionposts.php'; 
    79 $__autoload['dcCommentsActionsPage'] = dirname(__FILE__).'/admin/actions/class.dcactioncomments.php'; 
    80 $__autoload['dcActionsPage']         = dirname(__FILE__).'/admin/actions/class.dcaction.php'; 
     77$__autoload['dcTemplate']               = dirname(__FILE__).'/public/class.dc.template.php'; 
     78$__autoload['context']                  = dirname(__FILE__).'/public/lib.tpl.context.php'; 
     79$__autoload['dcUrlHandlers']            = dirname(__FILE__).'/public/lib.urlhandlers.php'; 
     80$__autoload['dcPostsActionsPage']            = dirname(__FILE__).'/admin/actions/class.dcactionposts.php'; 
     81$__autoload['dcCommentsActionsPage']              = dirname(__FILE__).'/admin/actions/class.dcactioncomments.php'; 
     82$__autoload['dcActionsPage']            = dirname(__FILE__).'/admin/actions/class.dcaction.php'; 
     83$__autoload['dcForm']              = dirname(__FILE__).'/admin/class.dc.form.php'; 
     84$__autoload['dcFormExtension']               = dirname(__FILE__).'/admin/class.dc.form.php'; 
     85$__autoload['dcTabExtension']           = dirname(__FILE__).'/admin/class.dc.tab.php'; 
     86$__autoload['dcItemList']               = dirname(__FILE__).'/admin/class.dc.list.php'; 
     87$__autoload['dcListFetcher']            = dirname(__FILE__).'/admin/class.dc.list.php'; 
     88 
     89foreach (array('dcFilterSet', 'dcFilter','dcFilterCombo','dcFilterText','dcFilterBoolean') as $c) { 
     90     $__autoload[$c] = dirname(__FILE__).'/admin/class.dc.filter.php'; 
     91} 
    8192 
    8293# Clearbricks extensions 
    8394html::$absolute_regs[] = '/(<param\s+name="movie"\s+value=")(.*?)(")/msu'; 
    8495html::$absolute_regs[] = '/(<param\s+name="FlashVars"\s+value=".*?(?:mp3|flv)=)(.*?)(&|")/msu'; 
     96 
     97if (@is_dir('/usr/lib/twig')) { 
     98     define('TWIG_PATH','/usr/lib/Twig'); 
     99} elseif (is_dir(dirname(__FILE__).'/../vendor/twig/twig/lib/Twig')) { 
     100     define('TWIG_PATH',dirname(__FILE__).'/../vendor/twig/twig/lib/Twig'); 
     101} elseif (isset($_SERVER['TWIG_PATH']) && is_dir($_SERVER['TWIG_PATH'])) { 
     102     define('TWIG_PATH',$_SERVER['TWIG_PATH']); 
     103} 
     104 
     105if (!defined('TWIG_PATH') || !is_dir(TWIG_PATH)) { 
     106     exit('No Twig path defined'); 
     107} 
     108require TWIG_PATH.'/Autoloader.php'; 
     109Twig_Autoloader::register(); 
     110 
    85111/* ------------------------------------------------------------------------------------------- */ 
    86112 
     
    139165# Constants 
    140166define('DC_ROOT',path::real(dirname(__FILE__).'/..')); 
    141 define('DC_VERSION','2.7-dev'); 
     167define('DC_VERSION','2.99-dev'); 
    142168define('DC_DIGESTS',dirname(__FILE__).'/digests'); 
    143169define('DC_L10N_ROOT',dirname(__FILE__).'/../locales'); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map