Dotclear


Ignore:
Timestamp:
12/13/12 08:48:15 (13 years ago)
Author:
JcDenis
Branch:
twig
Message:
  • dcMenu is now "Twig compliant"
File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/admin/class.dc.menu.php

    r691 r1064  
    1414class dcMenu 
    1515{ 
     16     private $items; 
    1617     private $id; 
    1718     public $title; 
     19     public $separator; 
    1820      
    19      public function __construct($id,$title,$itemSpace='') 
     21     public function __construct($id,$title,$separator='') 
    2022     { 
    2123          $this->id = $id; 
    2224          $this->title = $title; 
    23           $this->itemSpace = $itemSpace; 
     25          $this->separator = $separator; 
    2426          $this->items = array(); 
     27     } 
     28      
     29     public function getID() 
     30     { 
     31          return $this->id; 
     32     } 
     33      
     34     public function getTitle() 
     35     { 
     36          return $this->title; 
     37     } 
     38      
     39     public function getSeparator() 
     40     { 
     41          return $this->separator; 
     42     } 
     43      
     44     public function getItems() 
     45     { 
     46          return $this->items; 
    2547     } 
    2648      
     
    3961     } 
    4062      
     63     protected function itemDef($title,$url,$img,$active,$id=null,$class=null) 
     64     { 
     65          if (is_array($url)) { 
     66               $link = $url[0]; 
     67               $ahtml = (!empty($url[1])) ? ' '.$url[1] : ''; 
     68          } else { 
     69               $link = $url; 
     70               $ahtml = ''; 
     71          } 
     72           
     73          return array( 
     74               'title' => $title, 
     75               'link' => $link, 
     76               'ahtml' => $ahtml, 
     77               'img' => dc_admin_icon_url($img), 
     78               'active' => (boolean) $active, 
     79               'id' => $id, 
     80               'class' => $class 
     81          ); 
     82     } 
     83      
     84     /** 
     85     @deprecated Use Template engine instead 
     86     */ 
    4187     public function draw() 
    4288     { 
     
    5298          for ($i=0; $i<count($this->items); $i++) 
    5399          { 
    54                if ($i+1 < count($this->items) && $this->itemSpace != '') { 
    55                     $res .= preg_replace('|</li>$|',$this->itemSpace.'</li>',$this->items[$i]); 
     100               if ($i+1 < count($this->items) && $this->separator != '') { 
     101                    $res .= preg_replace('|</li>$|',$this->separator.'</li>',$this->drawItem($this->items[$i])); 
    56102                    $res .= "\n"; 
    57103               } else { 
    58                     $res .= $this->items[$i]."\n"; 
     104                    $res .= $this->drawItem($this->items[$i])."\n"; 
    59105               } 
    60106          } 
     
    65111     } 
    66112      
    67      protected function itemDef($title,$url,$img,$active,$id=null,$class=null) 
     113     /** 
     114     @deprecated Use Template engine instead 
     115     */ 
     116     protected function drawItem($item) 
    68117     { 
    69           if (is_array($url)) { 
    70                $link = $url[0]; 
    71                $ahtml = (!empty($url[1])) ? ' '.$url[1] : ''; 
    72           } else { 
    73                $link = $url; 
    74                $ahtml = ''; 
    75           } 
    76            
    77           $img = dc_admin_icon_url($img); 
    78            
    79118          return 
    80           '<li'.(($active || $class) ? ' class="'.(($active) ? 'active ' : '').(($class) ? $class : '').'"' : ''). 
    81           (($id) ? ' id="'.$id.'"' : ''). 
    82           (($img) ? ' style="background-image: url('.$img.');"' : ''). 
     119          '<li'.(($item['active'] || $item['class']) ? ' class="'.(($item['active']) ? 'active ' : '').(($item['class']) ? $item['class'] : '').'"' : ''). 
     120          (($item['id']) ? ' id="'.$item['id'].'"' : ''). 
     121          (($item['img']) ? ' style="background-image: url('.$item['img'].');"' : ''). 
    83122          '>'. 
    84123           
    85           '<a href="'.$link.'"'.$ahtml.'>'.$title.'</a></li>'."\n"; 
     124          '<a href="'.$item['link'].'"'.$item['ahtml'].'>'.$item['title'].'</a></li>'."\n"; 
    86125     } 
    87126} 
Note: See TracChangeset for help on using the changeset viewer.

Sites map