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.categories.php

    r1532 r2566  
    2222     protected $f_right = 'cat_rgt'; 
    2323     protected $f_id = 'cat_id'; 
    24       
     24 
    2525     protected $core; 
    2626     protected $blog_id; 
    27       
     27 
    2828     public function __construct($core) 
    2929     { 
     
    3434          $this->add_condition = array('blog_id' => "'".$this->con->escape($this->blog_id)."'"); 
    3535     } 
    36       
     36 
    3737     public function getChildren($start=0,$id=null,$sort='asc',$fields=array()) 
    3838     { 
     
    4040          return parent::getChildren($start,$id,$sort,$fields); 
    4141     } 
    42       
     42 
    4343     public function getParents($id,$fields=array()) 
    4444     { 
     
    4646          return parent::getParents($id,$fields); 
    4747     } 
    48       
     48 
    4949     public function getParent($id,$fields=array()) 
    5050     { 
     
    5757{ 
    5858     protected $con; 
    59       
     59 
    6060     protected $table; 
    6161     protected $f_left; 
    6262     protected $f_right; 
    6363     protected $f_id; 
    64       
     64 
    6565     protected $add_condition = array(); 
    66       
     66 
    6767     protected $parents; 
    68       
     68 
    6969     public function __construct($con) 
    7070     { 
    7171          $this->con =& $con; 
    7272     } 
    73       
     73 
    7474     public function getChildren($start=0,$id=null,$sort='asc',$fields=array()) 
    7575     { 
    7676          $fields = count($fields) > 0 ? ', C2.'.implode(', C2.',$fields) : ''; 
    77            
     77 
    7878          $sql = 'SELECT C2.'.$this->f_id.', C2.'.$this->f_left.', C2.'.$this->f_right.', COUNT(C1.'.$this->f_id.') AS level ' 
    79           . $fields.' '   
     79          . $fields.' ' 
    8080          . 'FROM '.$this->table.' AS C1, '.$this->table.' AS C2 %s ' 
    8181          . 'WHERE C2.'.$this->f_left.' BETWEEN C1.'.$this->f_left.' AND C1.'.$this->f_right.' ' 
     
    8686          . ' %s ' 
    8787          . 'ORDER BY C2.'.$this->f_left.' '.($sort == 'asc' ? 'ASC' : 'DESC').' '; 
    88            
     88 
    8989          $from = $where = ''; 
    9090          if ($start > 0) { 
     
    9393               $where .= $this->getCondition('AND','C3.'); 
    9494          } 
    95            
     95 
    9696          $having = ''; 
    9797          if ($id !== null) { 
    9898               $having = ' HAVING C2.'.$this->f_id.' = '.(integer) $id; 
    9999          } 
    100            
     100 
    101101          $sql = sprintf($sql,$from,$where,$having); 
    102            
     102 
    103103          return $this->con->select($sql); 
    104104     } 
    105       
     105 
    106106     public function getParents($id,$fields=array()) 
    107107     { 
    108108          $fields = count($fields) > 0 ? ', C1.'.implode(', C1.',$fields) : ''; 
    109            
     109 
    110110          return $this->con->select( 
    111111               'SELECT C1.'.$this->f_id.' '.$fields.' ' 
     
    119119          ); 
    120120     } 
    121       
     121 
    122122     public function getParent($id,$fields=array()) 
    123123     { 
    124124          $fields = count($fields) > 0 ? ', C1.'.implode(', C1.',$fields) : ''; 
    125            
     125 
    126126          return $this->con->select( 
    127127               'SELECT C1.'.$this->f_id.' '.$fields.' ' 
     
    136136          ); 
    137137     } 
    138       
     138 
    139139     /* ------------------------------------------------ 
    140140      * Tree manipulations 
     
    145145               throw new Exception('Invalid data block'); 
    146146          } 
    147            
     147 
    148148          if (is_array($data)) 
    149149          { 
     
    155155               unset($D); 
    156156          } 
    157            
     157 
    158158          # We want to put it at the end 
    159159          $this->con->writeLock($this->table); 
     
    162162               $rs = $this->con->select('SELECT MAX('.$this->f_id.') as n_id FROM '.$this->table); 
    163163               $id = $rs->n_id; 
    164                 
     164 
    165165               $rs = $this->con->select( 
    166166                    'SELECT MAX('.$this->f_right.') as n_r '. 
     
    169169               ); 
    170170               $last = $rs->n_r == 0 ? 1 : $rs->n_r; 
    171                 
     171 
    172172               $data->{$this->f_id} = $id+1; 
    173173               $data->{$this->f_left} = $last+1; 
    174174               $data->{$this->f_right} = $last+2; 
    175                 
     175 
    176176               $data->insert(); 
    177177               $this->con->unlock(); 
     
    187187          } 
    188188     } 
    189       
     189 
    190190        public function updatePosition($id,$left,$right) 
    191191        { 
     
    209209     { 
    210210          $node = (integer) $node; 
    211            
     211 
    212212          $rs = $this->getChildren(0,$node); 
    213213          if ($rs->isEmpty()) { 
     
    216216          $node_left = (integer) $rs->{$this->f_left}; 
    217217          $node_right = (integer) $rs->{$this->f_right}; 
    218            
     218 
    219219          try 
    220220          { 
    221221               $this->con->begin(); 
    222                 
     222 
    223223               if ($keep_children) 
    224224               { 
    225225                    $this->con->execute('DELETE FROM '.$this->table.' WHERE '.$this->f_id.' = '.$node); 
    226                      
     226 
    227227                    $sql = 'UPDATE '.$this->table.' SET ' 
    228228                    . $this->f_right.' = CASE ' 
     
    242242                    . 'WHERE '.$this->f_right.' > '.$node_left 
    243243                    . $this->getCondition(); 
    244                      
     244 
    245245                    $this->con->execute($sql); 
    246246               } 
     
    248248               { 
    249249                    $this->con->execute('DELETE FROM '.$this->table.' WHERE '.$this->f_left.' BETWEEN '.$node_left.' AND '.$node_right); 
    250                      
     250 
    251251                    $node_delta = $node_right - $node_left + 1; 
    252252                    $sql = 'UPDATE '.$this->table.' SET ' 
     
    264264                    . $this->getCondition(); 
    265265               } 
    266                 
     266 
    267267               $this->con->commit(); 
    268268          } 
     
    273273          } 
    274274     } 
    275       
     275 
    276276     public function resetOrder() 
    277277     { 
     
    282282               .'ORDER BY '.$this->f_left.' ASC ' 
    283283          ); 
    284            
     284 
    285285          $lft = 2; 
    286286          $this->con->begin(); 
     
    304304          } 
    305305     } 
    306       
     306 
    307307     public function setNodeParent($node,$target=0) 
    308308     { 
     
    312312          $node = (integer) $node; 
    313313          $target = (integer) $target; 
    314            
     314 
    315315          $rs = $this->getChildren(0,$node); 
    316316          if ($rs->isEmpty()) { 
     
    320320          $node_right = (integer) $rs->{$this->f_right}; 
    321321          $node_level = (integer) $rs->level; 
    322            
     322 
    323323          if ($target > 0) 
    324324          { 
     
    336336          $target_right = (integer) $rs->{$this->f_right}; 
    337337          $target_level = (integer) $rs->level; 
    338            
     338 
    339339          if ($node_left == $target_left 
    340340               || ($target_left >= $node_left && $target_left <= $node_right) 
     
    344344               throw new Exception('Cannot move tree'); 
    345345          } 
    346            
     346 
    347347          if ($target_left < $node_left && $target_right > $node_right && $target_level < $node_level -1) 
    348348          { 
     
    405405               .    'OR '.$this->f_right.' BETWEEN '.$node_left.' AND '.$target_right.')'; 
    406406          } 
    407            
     407 
    408408          $sql .= ' '.$this->getCondition(); 
    409            
     409 
    410410          $this->con->execute($sql); 
    411411     } 
    412       
     412 
    413413     public function setNodePosition($nodeA,$nodeB,$position='after') 
    414414     { 
    415415          $nodeA = (integer) $nodeA; 
    416416          $nodeB = (integer) $nodeB; 
    417            
     417 
    418418          $rs = $this->getChildren(0,$nodeA); 
    419419          if ($rs->isEmpty()) { 
     
    423423          $A_right = $rs->{$this->f_right}; 
    424424          $A_level = $rs->level; 
    425            
     425 
    426426          $rs = $this->getChildren(0,$nodeB); 
    427427          if ($rs->isEmpty()) { 
     
    431431          $B_right = $rs->{$this->f_right}; 
    432432          $B_level = $rs->level; 
    433            
     433 
    434434          if ($A_level != $B_level) { 
    435435               throw new Exception('Cannot change position'); 
    436436          } 
    437            
     437 
    438438          $rs = $this->getParents($nodeA); 
    439439          $parentA = $rs->isEmpty() ? 0 : $rs->{$this->f_id}; 
    440440          $rs = $this->getParents($nodeB); 
    441441          $parentB = $rs->isEmpty() ? 0 : $rs->{$this->f_id}; 
    442            
     442 
    443443          if ($parentA != $parentB) { 
    444444               throw new Exception('Cannot change position'); 
    445445          } 
    446            
     446 
    447447          if ($position == 'before') 
    448448          { 
     
    481481               } 
    482482          } 
    483            
     483 
    484484          $sql .= $this->getCondition(); 
    485485          $this->con->execute($sql); 
    486486     } 
    487       
     487 
    488488     protected function getCondition($start='AND',$prefix='') 
    489489     { 
     
    491491               return ''; 
    492492          } 
    493            
     493 
    494494          $w = array(); 
    495495          foreach ($this->add_condition as $c => $n) { 
     
    499499     } 
    500500} 
    501 ?> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map