Dotclear


Ignore:
Timestamp:
11/17/13 20:25:53 (12 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
2.6
Children:
2567:6c11245cbf04, 2568:61c67a7d17fa
Message:

Add some people in CREDITS, remove trailing spaces and tabs.

File:
1 edited

Legend:

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

    r2492 r2566  
    3939     public $rest;       ///< <b>dcRestServer</b> dcRestServer object 
    4040     public $log;        ///< <b>dcLog</b>             dcLog object 
    41       
     41 
    4242     private $versions = null; 
    4343     private $formaters = array(); 
    4444     private $behaviors = array(); 
    4545     private $post_types = array(); 
    46       
     46 
    4747     /** 
    4848     dcCore constructor inits everything related to Dotclear. It takes arguments 
    4949     to init database connection. 
    50       
     50 
    5151     @param    driver    <b>string</b>  Database driver name 
    5252     @param    host      <b>string</b>  Database hostname 
     
    6060     { 
    6161          $this->con = dbLayer::init($driver,$host,$db,$user,$password,$persist); 
    62            
     62 
    6363          # define weak_locks for mysql 
    6464          if ($this->con instanceof mysqlConnection) { 
     
    6767               mysqliConnection::$weak_locks = true; 
    6868          } 
    69            
     69 
    7070          # define searchpath for postgresql 
    7171          if ($this->con instanceof pgsqlConnection) 
     
    7979               } 
    8080          } 
    81            
     81 
    8282          $this->prefix = $prefix; 
    83            
     83 
    8484          $this->error = new dcError(); 
    8585          $this->auth = $this->authInstance(); 
    8686          $this->session = new sessionDB($this->con,$this->prefix.'session',DC_SESSION_NAME,'',null,DC_ADMIN_SSL); 
    8787          $this->url = new dcUrlHandlers(); 
    88            
     88 
    8989          $this->plugins = new dcPlugins($this); 
    90            
     90 
    9191          $this->rest = new dcRestServer($this); 
    92            
     92 
    9393          $this->meta = new dcMeta($this); 
    94            
     94 
    9595          $this->log = new dcLog($this); 
    96            
     96 
    9797          $this->addFormater('xhtml', create_function('$s','return $s;')); 
    9898          $this->addFormater('wiki', array($this,'wikiTransform')); 
    9999     } 
    100       
     100 
    101101     private function authInstance() 
    102102     { 
     
    108108               $c = DC_AUTH_CLASS; 
    109109          } 
    110            
     110 
    111111          if (!class_exists($c)) { 
    112112               throw new Exception('Authentication class '.$c.' does not exist.'); 
    113113          } 
    114            
     114 
    115115          if ($c != 'dcAuth' && !is_subclass_of($c,'dcAuth')) { 
    116116               throw new Exception('Authentication class '.$c.' does not inherit dcAuth.'); 
    117117          } 
    118            
     118 
    119119          return new $c($this); 
    120120     } 
    121       
    122       
     121 
     122 
    123123     /// @name Blog init methods 
    124124     //@{ 
    125125     /** 
    126126     Sets a blog to use in <var>blog</var> property. 
    127       
     127 
    128128     @param    id        <b>string</b>       Blog ID 
    129129     */ 
     
    132132          $this->blog = new dcBlog($this, $id); 
    133133     } 
    134       
     134 
    135135     /** 
    136136     Unsets <var>blog</var> property. 
     
    141141     } 
    142142     //@} 
    143       
    144       
     143 
     144 
    145145     /// @name Blog status methods 
    146146     //@{ 
    147147     /** 
    148148     Returns an array of available blog status codes and names. 
    149       
     149 
    150150     @return   <b>array</b> Simple array with codes in keys and names in value 
    151151     */ 
     
    158158          ); 
    159159     } 
    160       
     160 
    161161     /** 
    162162     Returns a blog status name given to a code. This is intended to be 
    163163     human-readable and will be translated, so never use it for tests. 
    164164     If status code does not exist, returns <i>offline</i>. 
    165       
     165 
    166166     @param    s    <b>integer</b> Status code 
    167167     @return   <b>string</b> Blog status name 
     
    176176     } 
    177177     //@} 
    178       
     178 
    179179     /// @name Admin nonce secret methods 
    180180     //@{ 
    181       
     181 
    182182     public function getNonce() 
    183183     { 
    184184          return crypt::hmac(DC_MASTER_KEY,session_id()); 
    185185     } 
    186       
     186 
    187187     public function checkNonce($secret) 
    188188     { 
     
    190190               return false; 
    191191          } 
    192            
     192 
    193193          return $secret == crypt::hmac(DC_MASTER_KEY,session_id()); 
    194194     } 
    195       
     195 
    196196     public function formNonce() 
    197197     { 
     
    199199               return; 
    200200          } 
    201            
     201 
    202202          return form::hidden(array('xd_check'),$this->getNonce()); 
    203203     } 
    204204     //@} 
    205       
    206       
     205 
     206 
    207207     /// @name Text Formatters methods 
    208208     //@{ 
     
    211211     transform text. The function must be a valid callback and takes one 
    212212     argument: the string to transform. It returns the transformed string. 
    213       
     213 
    214214     @param    name      <b>string</b>       Formater name 
    215215     @param    func      <b>callback</b>     Function to use, must be a valid and callable callback 
     
    221221          } 
    222222     } 
    223       
     223 
    224224     /** 
    225225     Returns formaters list. 
    226       
     226 
    227227     @return   <b>array</b> An array of formaters names in values. 
    228228     */ 
     
    231231          return array_keys($this->formaters); 
    232232     } 
    233       
     233 
    234234     /** 
    235235     If <var>$name</var> is a valid formater, it returns <var>$str</var> 
    236236     transformed using that formater. 
    237       
     237 
    238238     @param    name      <b>string</b>       Formater name 
    239239     @param    str       <b>string</b>       String to transform 
     
    245245               return call_user_func($this->formaters[$name],$str); 
    246246          } 
    247            
     247 
    248248          return $str; 
    249249     } 
    250250     //@} 
    251       
    252       
     251 
     252 
    253253     /// @name Behaviors methods 
    254254     //@{ 
     
    256256     Adds a new behavior to behaviors stack. <var>$func</var> must be a valid 
    257257     and callable callback. 
    258       
     258 
    259259     @param    behavior  <b>string</b>       Behavior name 
    260260     @param    func      <b>callback</b>     Function to call 
     
    266266          } 
    267267     } 
    268       
     268 
    269269     /** 
    270270     Tests if a particular behavior exists in behaviors stack. 
    271       
     271 
    272272     @param    behavior  <b>string</b>  Behavior name 
    273273     @return   <b>boolean</b> 
     
    277277          return isset($this->behaviors[$behavior]); 
    278278     } 
    279       
     279 
    280280     /** 
    281281     Get behaviors stack (or part of). 
    282       
     282 
    283283     @param    behavior  <b>string</b>       Behavior name 
    284284     @return   <b>array</b> 
     
    287287     { 
    288288          if (empty($this->behaviors)) return null; 
    289            
     289 
    290290          if ($behavior == '') { 
    291291               return $this->behaviors; 
     
    293293               return $this->behaviors[$behavior]; 
    294294          } 
    295            
     295 
    296296          return array(); 
    297297     } 
    298       
     298 
    299299     /** 
    300300     Calls every function in behaviors stack for a given behavior and returns 
    301301     concatened result of each function. 
    302       
     302 
    303303     Every parameters added after <var>$behavior</var> will be pass to 
    304304     behavior calls. 
    305       
     305 
    306306     @param    behavior  <b>string</b>  Behavior name 
    307307     @return   <b>string</b> Behavior concatened result 
     
    313313               $args = func_get_args(); 
    314314               array_shift($args); 
    315                 
     315 
    316316               $res = ''; 
    317                 
     317 
    318318               foreach ($this->behaviors[$behavior] as $f) { 
    319319                    $res .= call_user_func_array($f,$args); 
    320320               } 
    321                 
     321 
    322322               return $res; 
    323323          } 
    324324     } 
    325325     //@} 
    326       
     326 
    327327     /// @name Post types URLs management 
    328328     //@{ 
     
    332332               $type = 'post'; 
    333333          } 
    334            
     334 
    335335          $url = sprintf($this->post_types[$type]['admin_url'],$post_id); 
    336336          return $escaped ? html::escapeURL($url) : $url; 
    337337     } 
    338       
     338 
    339339     public function getPostPublicURL($type,$post_url,$escaped=true) 
    340340     { 
     
    342342               $type = 'post'; 
    343343          } 
    344            
     344 
    345345          $url = sprintf($this->post_types[$type]['public_url'],$post_url); 
    346346          return $escaped ? html::escapeURL($url) : $url; 
    347347     } 
    348       
     348 
    349349     public function setPostType($type,$admin_url,$public_url,$label='') 
    350350     { 
     
    355355          ); 
    356356     } 
    357       
     357 
    358358     public function getPostTypes() 
    359359     { 
     
    361361     } 
    362362     //@} 
    363       
     363 
    364364     /// @name Versions management methods 
    365365     //@{ 
    366366     /** 
    367367     Returns a given $module version. 
    368       
     368 
    369369     @param    module    <b>string</b>  Module name 
    370370     @return   <b>string</b>  Module version 
     
    377377               $strReq = 'SELECT module, version FROM '.$this->prefix.'version'; 
    378378               $rs = $this->con->select($strReq); 
    379                 
     379 
    380380               while ($rs->fetch()) { 
    381381                    $this->versions[$rs->module] = $rs->version; 
    382382               } 
    383383          } 
    384            
     384 
    385385          if (isset($this->versions[$module])) { 
    386386               return $this->versions[$module]; 
     
    389389          } 
    390390     } 
    391       
     391 
    392392     /** 
    393393     Sets $version to given $module. 
    394       
     394 
    395395     @param    module    <b>string</b>  Module name 
    396396     @param    version   <b>string</b>  Module version 
     
    399399     { 
    400400          $cur_version = $this->getVersion($module); 
    401            
     401 
    402402          $cur = $this->con->openCursor($this->prefix.'version'); 
    403403          $cur->module = (string) $module; 
    404404          $cur->version = (string) $version; 
    405            
     405 
    406406          if ($cur_version === null) { 
    407407               $cur->insert(); 
     
    409409               $cur->update("WHERE module='".$this->con->escape($module)."'"); 
    410410          } 
    411            
     411 
    412412          $this->versions[$module] = $version; 
    413413     } 
    414       
     414 
    415415     /** 
    416416     Removes given $module version entry. 
    417       
     417 
    418418     @param    module    <b>string</b>  Module name 
    419419     */ 
     
    423423          'DELETE FROM '.$this->prefix.'version '. 
    424424          "WHERE module = '".$this->con->escape($module)."' "; 
    425            
     425 
    426426          $this->con->execute($strReq); 
    427            
     427 
    428428          if (is_array($this->versions)) { 
    429429               unset($this->versions[$module]); 
    430430          } 
    431431     } 
    432       
     432 
    433433     //@} 
    434       
     434 
    435435     /// @name Users management methods 
    436436     //@{ 
    437437     /** 
    438438     Returns a user by its ID. 
    439       
     439 
    440440     @param    id        <b>string</b>       User ID 
    441441     @return   <b>record</b> 
     
    444444     { 
    445445          $params['user_id'] = $id; 
    446            
     446 
    447447          return $this->getUsers($params); 
    448448     } 
    449       
     449 
    450450     /** 
    451451     Returns a users list. <b>$params</b> is an array with the following 
    452452     optionnal parameters: 
    453       
     453 
    454454      - <var>q</var>: search string (on user_id, user_name, user_firstname) 
    455455      - <var>user_id</var>: user ID 
    456456      - <var>order</var>: ORDER BY clause (default: user_id ASC) 
    457457      - <var>limit</var>: LIMIT clause (should be an array ![limit,offset]) 
    458       
     458 
    459459     @param    params         <b>array</b>        Parameters 
    460460     @param    count_only     <b>boolean</b>      Only counts results 
     
    481481               'WHERE NULL IS NULL '; 
    482482          } 
    483            
     483 
    484484          if (!empty($params['q'])) { 
    485485               $q = $this->con->escape(str_replace('*','%',strtolower($params['q']))); 
     
    490490                    ') '; 
    491491          } 
    492            
     492 
    493493          if (!empty($params['user_id'])) { 
    494494               $strReq .= "AND U.user_id = '".$this->con->escape($params['user_id'])."' "; 
    495495          } 
    496            
     496 
    497497          if (!$count_only) { 
    498498               $strReq .= 'GROUP BY U.user_id,user_super,user_status,user_pwd,user_change_pwd,'. 
    499499               'user_name,user_firstname,user_displayname,user_email,user_url,'. 
    500500               'user_desc, user_lang,user_tz,user_post_status,user_options '; 
    501                 
     501 
    502502               if (!empty($params['order']) && !$count_only) { 
    503503                    $strReq .= 'ORDER BY '.$this->con->escape($params['order']).' '; 
     
    506506               } 
    507507          } 
    508            
     508 
    509509          if (!$count_only && !empty($params['limit'])) { 
    510510               $strReq .= $this->con->limit($params['limit']); 
    511511          } 
    512            
     512 
    513513          $rs = $this->con->select($strReq); 
    514514          $rs->extend('rsExtUser'); 
    515515          return $rs; 
    516516     } 
    517       
     517 
    518518     /** 
    519519     Create a new user. Takes a cursor as input and returns the new user ID. 
    520       
     520 
    521521     @param    cur       <b>cursor</b>       User cursor 
    522522     @return   <b>string</b> 
     
    527527               throw new Exception(__('You are not an administrator')); 
    528528          } 
    529            
     529 
    530530          if ($cur->user_id == '') { 
    531531               throw new Exception(__('No user ID given')); 
    532532          } 
    533            
     533 
    534534          if ($cur->user_pwd == '') { 
    535535               throw new Exception(__('No password given')); 
    536536          } 
    537            
     537 
    538538          $this->getUserCursor($cur); 
    539            
     539 
    540540          if ($cur->user_creadt === null) { 
    541541               $cur->user_creadt = date('Y-m-d H:i:s'); 
    542542          } 
    543            
     543 
    544544          $cur->insert(); 
    545            
     545 
    546546          $this->auth->afterAddUser($cur); 
    547            
     547 
    548548          return $cur->user_id; 
    549549     } 
    550       
     550 
    551551     /** 
    552552     Updates an existing user. Returns the user ID. 
    553       
     553 
    554554     @param    id        <b>string</b>       User ID 
    555555     @param    cur       <b>cursor</b>       User cursor 
     
    559559     { 
    560560          $this->getUserCursor($cur); 
    561            
     561 
    562562          if (($cur->user_id !== null || $id != $this->auth->userID()) && 
    563563          !$this->auth->isSuperAdmin()) { 
    564564               throw new Exception(__('You are not an administrator')); 
    565565          } 
    566            
     566 
    567567          $cur->update("WHERE user_id = '".$this->con->escape($id)."' "); 
    568            
     568 
    569569          $this->auth->afterUpdUser($id,$cur); 
    570            
     570 
    571571          if ($cur->user_id !== null) { 
    572572               $id = $cur->user_id; 
    573573          } 
    574            
     574 
    575575          # Updating all user's blogs 
    576576          $rs = $this->con->select( 
     
    578578               "WHERE user_id = '".$this->con->escape($id)."' " 
    579579               ); 
    580            
     580 
    581581          while ($rs->fetch()) { 
    582582               $b = new dcBlog($this,$rs->blog_id); 
     
    584584               unset($b); 
    585585          } 
    586            
     586 
    587587          return $id; 
    588588     } 
    589       
     589 
    590590     /** 
    591591     Deletes a user. 
    592       
     592 
    593593     @param    id        <b>string</b>       User ID 
    594594     */ 
     
    598598               throw new Exception(__('You are not an administrator')); 
    599599          } 
    600            
     600 
    601601          if ($id == $this->auth->userID()) { 
    602602               return; 
    603603          } 
    604            
     604 
    605605          $rs = $this->getUser($id); 
    606            
     606 
    607607          if ($rs->nb_post > 0) { 
    608608               return; 
    609609          } 
    610            
     610 
    611611          $strReq = 'DELETE FROM '.$this->prefix.'user '. 
    612612                    "WHERE user_id = '".$this->con->escape($id)."' "; 
    613            
     613 
    614614          $this->con->execute($strReq); 
    615            
     615 
    616616          $this->auth->afterDelUser($id); 
    617617     } 
    618       
     618 
    619619     /** 
    620620     Checks whether a user exists. 
    621       
     621 
    622622     @param    id        <b>string</b>       User ID 
    623623     @return   <b>boolean</b> 
     
    628628                    'FROM '.$this->prefix.'user '. 
    629629                    "WHERE user_id = '".$this->con->escape($id)."' "; 
    630            
     630 
    631631          $rs = $this->con->select($strReq); 
    632            
     632 
    633633          return !$rs->isEmpty(); 
    634634     } 
    635       
     635 
    636636     /** 
    637637     Returns all user permissions as an array which looks like: 
    638       
     638 
    639639      - [blog_id] 
    640640        - [name] => Blog name 
     
    643643          - [permission] => true 
    644644          - ... 
    645       
     645 
    646646     @param    id        <b>string</b>       User ID 
    647647     @return   <b>array</b> 
     
    653653                    'INNER JOIN '.$this->prefix.'blog B ON P.blog_id = B.blog_id '. 
    654654                    "WHERE user_id = '".$this->con->escape($id)."' "; 
    655            
     655 
    656656          $rs = $this->con->select($strReq); 
    657            
     657 
    658658          $res = array(); 
    659            
     659 
    660660          while ($rs->fetch()) 
    661661          { 
     
    666666               ); 
    667667          } 
    668            
     668 
    669669          return $res; 
    670670     } 
    671       
     671 
    672672     /** 
    673673     Sets user permissions. The <var>$perms</var> array looks like: 
    674       
     674 
    675675      - [blog_id] => '|perm1|perm2|' 
    676676      - ... 
    677       
     677 
    678678     @param    id        <b>string</b>       User ID 
    679679     @param    perms     <b>array</b>        Permissions array 
     
    684684               throw new Exception(__('You are not an administrator')); 
    685685          } 
    686            
     686 
    687687          $strReq = 'DELETE FROM '.$this->prefix.'permissions '. 
    688688                    "WHERE user_id = '".$this->con->escape($id)."' "; 
    689            
     689 
    690690          $this->con->execute($strReq); 
    691            
     691 
    692692          foreach ($perms as $blog_id => $p) { 
    693693               $this->setUserBlogPermissions($id, $blog_id, $p, false); 
    694694          } 
    695695     } 
    696       
     696 
    697697     /** 
    698698     Sets user permissions for a given blog. <var>$perms</var> is an array with 
    699699     permissions in values 
    700       
     700 
    701701     @param    id             <b>string</b>       User ID 
    702702     @param    blog_id        <b>string</b>       Blog ID 
     
    709709               throw new Exception(__('You are not an administrator')); 
    710710          } 
    711            
     711 
    712712          $no_perm = empty($perms); 
    713            
     713 
    714714          $perms = '|'.implode('|',array_keys($perms)).'|'; 
    715            
     715 
    716716          $cur = $this->con->openCursor($this->prefix.'permissions'); 
    717            
     717 
    718718          $cur->user_id = (string) $id; 
    719719          $cur->blog_id = (string) $blog_id; 
    720720          $cur->permissions = $perms; 
    721            
     721 
    722722          if ($delete_first || $no_perm) 
    723723          { 
     
    725725                         "WHERE blog_id = '".$this->con->escape($blog_id)."' ". 
    726726                         "AND user_id = '".$this->con->escape($id)."' "; 
    727                 
     727 
    728728               $this->con->execute($strReq); 
    729729          } 
    730            
     730 
    731731          if (!$no_perm) { 
    732732               $cur->insert(); 
    733733          } 
    734734     } 
    735       
     735 
    736736     /** 
    737737     Sets a user default blog. This blog will be selected when user log in. 
    738       
     738 
    739739     @param    id             <b>string</b>       User ID 
    740740     @param    blog_id        <b>string</b>       Blog ID 
     
    743743     { 
    744744          $cur = $this->con->openCursor($this->prefix.'user'); 
    745            
     745 
    746746          $cur->user_default_blog = (string) $blog_id; 
    747            
     747 
    748748          $cur->update("WHERE user_id = '".$this->con->escape($id)."'"); 
    749749     } 
    750       
     750 
    751751     private function getUserCursor($cur) 
    752752     { 
     
    755755               throw new Exception(__('User ID must contain at least 2 characters using letters, numbers or symbols.')); 
    756756          } 
    757            
     757 
    758758          if ($cur->user_url !== null && $cur->user_url != '') { 
    759759               if (!preg_match('|^http(s?)://|',$cur->user_url)) { 
     
    761761               } 
    762762          } 
    763            
     763 
    764764          if ($cur->isField('user_pwd')) { 
    765765               if (strlen($cur->user_pwd) < 6) { 
     
    768768               $cur->user_pwd = crypt::hmac(DC_MASTER_KEY,$cur->user_pwd); 
    769769          } 
    770            
     770 
    771771          if ($cur->user_lang !== null && !preg_match('/^[a-z]{2}(-[a-z]{2})?$/',$cur->user_lang)) { 
    772772               throw new Exception(__('Invalid user language code')); 
    773773          } 
    774            
     774 
    775775          if ($cur->user_upddt === null) { 
    776776               $cur->user_upddt = date('Y-m-d H:i:s'); 
    777777          } 
    778            
     778 
    779779          if ($cur->user_options !== null) { 
    780780               $cur->user_options = serialize((array) $cur->user_options); 
    781781          } 
    782782     } 
    783       
     783 
    784784     /** 
    785785     Returns user default settings in an associative array with setting names in 
    786786     keys. 
    787       
     787 
    788788     @return   <b>array</b> 
    789789     */ 
     
    797797     } 
    798798     //@} 
    799       
     799 
    800800     /// @name Blog management methods 
    801801     //@{ 
    802802     /** 
    803803     Returns all blog permissions (users) as an array which looks like: 
    804       
     804 
    805805      - [user_id] 
    806806        - [name] => User name 
     
    811811          - [permission] => true 
    812812          - ... 
    813       
     813 
    814814     @param    id             <b>string</b>       Blog ID 
    815815     @param    with_super     <b>boolean</b>      Includes super admins in result 
     
    824824          'JOIN '.$this->prefix.'permissions P ON U.user_id = P.user_id '. 
    825825          "WHERE blog_id = '".$this->con->escape($id)."' "; 
    826            
     826 
    827827          if ($with_super) { 
    828828               $strReq .= 
     
    833833               'WHERE user_super = 1 '; 
    834834          } 
    835            
     835 
    836836          $rs = $this->con->select($strReq); 
    837            
     837 
    838838          $res = array(); 
    839            
     839 
    840840          while ($rs->fetch()) 
    841841          { 
     
    849849               ); 
    850850          } 
    851            
     851 
    852852          return $res; 
    853853     } 
    854       
     854 
    855855     /** 
    856856     Returns a blog of given ID. 
    857       
     857 
    858858     @param    id        <b>string</b>       Blog ID 
    859859     @return   <b>record</b> 
     
    862862     { 
    863863          $blog = $this->getBlogs(array('blog_id'=>$id)); 
    864            
     864 
    865865          if ($blog->isEmpty()) { 
    866866               return false; 
    867867          } 
    868            
     868 
    869869          return $blog; 
    870870     } 
    871       
     871 
    872872     /** 
    873873     Returns a record of blogs. <b>$params</b> is an array with the following 
    874874     optionnal parameters: 
    875       
     875 
    876876      - <var>blog_id</var>: Blog ID 
    877877      - <var>q</var>: Search string on blog_id, blog_name and blog_url 
    878878      - <var>limit</var>: limit results 
    879       
     879 
    880880     @param    params         <b>array</b>        Parameters 
    881881     @param    count_only     <b>boolean</b>      Count only results 
     
    886886          $join = '';    // %1$s 
    887887          $where = '';   // %2$s 
    888            
     888 
    889889          if ($count_only) 
    890890          { 
     
    904904               'WHERE NULL IS NULL '. 
    905905               '%2$s '; 
    906                 
     906 
    907907               if (!empty($params['order'])) { 
    908908                    $strReq .= 'ORDER BY '.$this->con->escape($params['order']).' '; 
     
    910910                    $strReq .= 'ORDER BY B.blog_id ASC '; 
    911911               } 
    912                 
     912 
    913913               if (!empty($params['limit'])) { 
    914914                    $strReq .= $this->con->limit($params['limit']); 
    915915               } 
    916916          } 
    917            
     917 
    918918          if ($this->auth->userID() && !$this->auth->isSuperAdmin()) 
    919919          { 
     
    926926               $where = 'AND blog_status IN (1,0) '; 
    927927          } 
    928            
     928 
    929929          if (!empty($params['blog_id'])) { 
    930930               $where .= "AND B.blog_id = '".$this->con->escape($params['blog_id'])."' "; 
    931931          } 
    932            
     932 
    933933          if (!empty($params['q'])) { 
    934934               $params['q'] = strtolower(str_replace('*','%',$params['q'])); 
     
    940940               ') '; 
    941941          } 
    942            
     942 
    943943          $strReq = sprintf($strReq,$join,$where); 
    944944          return $this->con->select($strReq); 
    945945     } 
    946       
     946 
    947947     /** 
    948948     Creates a new blog. 
    949       
     949 
    950950     @param    cur            <b>cursor</b>       Blog cursor 
    951951     */ 
     
    955955               throw new Exception(__('You are not an administrator')); 
    956956          } 
    957            
     957 
    958958          $this->getBlogCursor($cur); 
    959            
     959 
    960960          $cur->blog_creadt = date('Y-m-d H:i:s'); 
    961961          $cur->blog_upddt = date('Y-m-d H:i:s'); 
    962962          $cur->blog_uid = md5(uniqid()); 
    963            
     963 
    964964          $cur->insert(); 
    965965     } 
    966       
     966 
    967967     /** 
    968968     Updates a given blog. 
    969       
     969 
    970970     @param    id        <b>string</b>       Blog ID 
    971971     @param    cur       <b>cursor</b>       Blog cursor 
     
    974974     { 
    975975          $this->getBlogCursor($cur); 
    976            
     976 
    977977          $cur->blog_upddt = date('Y-m-d H:i:s'); 
    978            
     978 
    979979          $cur->update("WHERE blog_id = '".$this->con->escape($id)."'"); 
    980980     } 
    981       
     981 
    982982     private function getBlogCursor($cur) 
    983983     { 
    984984          if ($cur->blog_id !== null 
    985985          && !preg_match('/^[A-Za-z0-9._-]{2,}$/',$cur->blog_id)) { 
    986                throw new Exception(__('Blog ID must contain at least 2 characters using letters, numbers or symbols.'));  
    987           } 
    988            
     986               throw new Exception(__('Blog ID must contain at least 2 characters using letters, numbers or symbols.')); 
     987          } 
     988 
    989989          if ($cur->blog_name !== null && $cur->blog_name == '') { 
    990990               throw new Exception(__('No blog name')); 
    991991          } 
    992            
     992 
    993993          if ($cur->blog_url !== null && $cur->blog_url == '') { 
    994994               throw new Exception(__('No blog URL')); 
    995995          } 
    996            
     996 
    997997          if ($cur->blog_desc !== null) { 
    998998               $cur->blog_desc = html::clean($cur->blog_desc); 
    999999          } 
    10001000     } 
    1001       
     1001 
    10021002     /** 
    10031003     Removes a given blog. 
    10041004     @warning This will remove everything related to the blog (posts, 
    10051005     categories, comments, links...) 
    1006       
     1006 
    10071007     @param    id        <b>string</b>       Blog ID 
    10081008     */ 
     
    10121012               throw new Exception(__('You are not an administrator')); 
    10131013          } 
    1014            
     1014 
    10151015          $strReq = 'DELETE FROM '.$this->prefix.'blog '. 
    10161016                    "WHERE blog_id = '".$this->con->escape($id)."' "; 
    1017            
     1017 
    10181018          $this->con->execute($strReq); 
    10191019     } 
    1020       
     1020 
    10211021     /** 
    10221022     Checks if a blog exist. 
    1023       
     1023 
    10241024     @param    id        <b>string</b>       Blog ID 
    10251025     @return   <b>boolean</b> 
     
    10301030                    'FROM '.$this->prefix.'blog '. 
    10311031                    "WHERE blog_id = '".$this->con->escape($id)."' "; 
    1032            
     1032 
    10331033          $rs = $this->con->select($strReq); 
    1034            
     1034 
    10351035          return !$rs->isEmpty(); 
    10361036     } 
    1037       
     1037 
    10381038     /** 
    10391039     Count posts on a blog 
    1040       
     1040 
    10411041     @param    id        <b>string</b>       Blog ID 
    10421042     @param    type      <b>string</b>       Post type 
     
    10481048                    'FROM '.$this->prefix.'post '. 
    10491049                    "WHERE blog_id = '".$this->con->escape($id)."' "; 
    1050            
     1050 
    10511051          if ($type) { 
    10521052               $strReq .= "AND post_type = '".$this->con->escape($type)."' "; 
    10531053          } 
    1054            
     1054 
    10551055          return $this->con->select($strReq)->f(0); 
    10561056     } 
    10571057     //@} 
    1058       
     1058 
    10591059     /// @name HTML Filter methods 
    10601060     //@{ 
     
    10631063     tidy extension is present). If <b>enable_html_filter</b> blog setting is 
    10641064     false, returns not filtered string. 
    1065       
     1065 
    10661066     @param    str  <b>string</b>       String to filter 
    10671067     @return   <b>string</b> Filtered string. 
     
    10721072               return $str; 
    10731073          } 
    1074            
     1074 
    10751075          $filter = new htmlFilter; 
    10761076          $str = trim($filter->apply($str)); 
     
    10781078     } 
    10791079     //@} 
    1080       
     1080 
    10811081     /// @name wiki2xhtml methods 
    10821082     //@{ 
     
    10851085          $this->wiki2xhtml = new wiki2xhtml; 
    10861086     } 
    1087       
     1087 
    10881088     /** 
    10891089     Returns a transformed string with wiki2xhtml. 
    1090       
     1090 
    10911091     @param    str       <b>string</b>       String to transform 
    10921092     @return   <b>string</b>  Transformed string 
     
    10991099          return $this->wiki2xhtml->transform($str); 
    11001100     } 
    1101       
     1101 
    11021102     /** 
    11031103     Inits <var>wiki2xhtml</var> property for blog post. 
     
    11061106     { 
    11071107          $this->initWiki(); 
    1108            
     1108 
    11091109          $this->wiki2xhtml->setOpts(array( 
    11101110               'active_title' => 1, 
     
    11381138               'note_str' => '<div class="footnotes"><h4>Notes</h4>%s</div>' 
    11391139          )); 
    1140            
     1140 
    11411141          $this->wiki2xhtml->registerFunction('url:post',array($this,'wikiPostLink')); 
    1142            
     1142 
    11431143          # --BEHAVIOR-- coreWikiPostInit 
    11441144          $this->callBehavior('coreInitWikiPost',$this->wiki2xhtml); 
    11451145     } 
    1146       
     1146 
    11471147     /** 
    11481148     Inits <var>wiki2xhtml</var> property for simple blog comment (basic syntax). 
     
    11511151     { 
    11521152          $this->initWiki(); 
    1153            
     1153 
    11541154          $this->wiki2xhtml->setOpts(array( 
    11551155               'active_title' => 0, 
     
    11801180               'active_fr_syntax' => 0 
    11811181          )); 
    1182            
     1182 
    11831183          # --BEHAVIOR-- coreInitWikiSimpleComment 
    11841184          $this->callBehavior('coreInitWikiSimpleComment',$this->wiki2xhtml); 
    11851185     } 
    1186       
     1186 
    11871187     /** 
    11881188     Inits <var>wiki2xhtml</var> property for blog comment. 
     
    11911191     { 
    11921192          $this->initWiki(); 
    1193            
     1193 
    11941194          $this->wiki2xhtml->setOpts(array( 
    11951195               'active_title' => 0, 
     
    12201220               'active_fr_syntax' => 0 
    12211221          )); 
    1222            
     1222 
    12231223          # --BEHAVIOR-- coreInitWikiComment 
    12241224          $this->callBehavior('coreInitWikiComment',$this->wiki2xhtml); 
    12251225     } 
    1226       
     1226 
    12271227     public function wikiPostLink($url,$content) 
    12281228     { 
    1229           if (!($this->blog instanceof dcBlog)) {  
     1229          if (!($this->blog instanceof dcBlog)) { 
    12301230               return array(); 
    12311231          } 
    1232            
     1232 
    12331233          $post_id = abs((integer) substr($url,5)); 
    12341234          if (!$post_id) { 
    12351235               return array(); 
    12361236          } 
    1237            
     1237 
    12381238          $post = $this->blog->getPosts(array('post_id'=>$post_id)); 
    12391239          if ($post->isEmpty()) { 
    12401240               return array(); 
    12411241          } 
    1242            
     1242 
    12431243          $res = array('url' => $post->getURL()); 
    12441244          $post_title = $post->post_title; 
    1245            
     1245 
    12461246          if ($content != $url) { 
    12471247               $res['title'] = html::escapeHTML($post->post_title); 
    12481248          } 
    1249            
     1249 
    12501250          if ($content == '' || $content == $url) { 
    12511251               $res['content'] = html::escapeHTML($post->post_title); 
    12521252          } 
    1253            
     1253 
    12541254          if ($post->post_lang) { 
    12551255               $res['lang'] = $post->post_lang; 
    12561256          } 
    1257            
     1257 
    12581258          return $res; 
    12591259     } 
    12601260     //@} 
    1261       
     1261 
    12621262     /// @name Maintenance methods 
    12631263     //@{ 
     
    12651265     Creates default settings for active blog. Optionnal parameter 
    12661266     <var>defaults</var> replaces default params while needed. 
    1267       
     1267 
    12681268     @param    defaults       <b>array</b>   Default parameters 
    12691269     */ 
     
    13481348               ); 
    13491349          } 
    1350            
     1350 
    13511351          $settings = new dcSettings($this,null); 
    13521352          $settings->addNamespace('system'); 
    1353            
     1353 
    13541354          foreach ($defaults as $v) { 
    13551355               $settings->system->put($v[0],$v[2],$v[1],$v[3],false,true); 
    13561356          } 
    13571357     } 
    1358       
     1358 
    13591359     /** 
    13601360     Recreates entries search engine index. 
    1361       
     1361 
    13621362     @param    start     <b>integer</b>      Start entry index 
    13631363     @param    limit     <b>integer</b>      Number of entry to index 
    1364       
     1364 
    13651365     @return   <b>integer</b>      <var>$start</var> and <var>$limit</var> sum 
    13661366     */ 
     
    13711371          $rs = $this->con->select($strReq); 
    13721372          $count = $rs->f(0); 
    1373            
     1373 
    13741374          $strReq = 'SELECT post_id, post_title, post_excerpt_xhtml, post_content_xhtml '. 
    13751375                    'FROM '.$this->prefix.'post '; 
    1376            
     1376 
    13771377          if ($start !== null && $limit !== null) { 
    13781378               $strReq .= $this->con->limit($start,$limit); 
    13791379          } 
    1380            
     1380 
    13811381          $rs = $this->con->select($strReq,true); 
    1382            
     1382 
    13831383          $cur = $this->con->openCursor($this->prefix.'post'); 
    1384            
     1384 
    13851385          while ($rs->fetch()) 
    13861386          { 
    13871387               $words = $rs->post_title.' '. $rs->post_excerpt_xhtml.' '. 
    13881388               $rs->post_content_xhtml; 
    1389                 
     1389 
    13901390               $cur->post_words = implode(' ',text::splitWords($words)); 
    13911391               $cur->update('WHERE post_id = '.(integer) $rs->post_id); 
    13921392               $cur->clean(); 
    13931393          } 
    1394            
     1394 
    13951395          if ($start+$limit > $count) { 
    13961396               return null; 
     
    13981398          return $start+$limit; 
    13991399     } 
    1400       
     1400 
    14011401     /** 
    14021402     Recreates comments search engine index. 
    1403       
     1403 
    14041404     @param    start     <b>integer</b>      Start comment index 
    14051405     @param    limit     <b>integer</b>      Number of comments to index 
    1406       
     1406 
    14071407     @return   <b>integer</b>      <var>$start</var> and <var>$limit</var> sum 
    14081408     */ 
     
    14131413          $rs = $this->con->select($strReq); 
    14141414          $count = $rs->f(0); 
    1415            
     1415 
    14161416          $strReq = 'SELECT comment_id, comment_content '. 
    14171417                    'FROM '.$this->prefix.'comment '; 
    1418            
     1418 
    14191419          if ($start !== null && $limit !== null) { 
    14201420               $strReq .= $this->con->limit($start,$limit); 
    14211421          } 
    1422            
     1422 
    14231423          $rs = $this->con->select($strReq); 
    1424            
     1424 
    14251425          $cur = $this->con->openCursor($this->prefix.'comment'); 
    1426            
     1426 
    14271427          while ($rs->fetch()) 
    14281428          { 
     
    14311431               $cur->clean(); 
    14321432          } 
    1433            
     1433 
    14341434          if ($start+$limit > $count) { 
    14351435               return null; 
     
    14371437          return $start+$limit; 
    14381438     } 
    1439       
     1439 
    14401440     /** 
    14411441     Reinits nb_comment and nb_trackback in post table. 
     
    14431443     public function countAllComments() 
    14441444     { 
    1445       
     1445 
    14461446          $updCommentReq = 'UPDATE '.$this->prefix.'post P '. 
    14471447               'SET nb_comment = ('. 
     
    14591459          $this->con->execute($updTrackbackReq); 
    14601460     } 
    1461       
     1461 
    14621462     /** 
    14631463     Empty templates cache directory 
     
    14711471     //@} 
    14721472} 
    1473 ?> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map