Dotclear


Ignore:
Timestamp:
11/27/13 16:32:38 (12 years ago)
Author:
Dsls
Branch:
twig
Children:
2612:1537212bd291, 2613:014098e27ea0
Parents:
2468:d7fda5a0bd39 (diff), 2589:3d427735ca70 (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:

Fusion avec default

File:
1 edited

Legend:

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

    r2566 r2593  
    44# This file is part of Dotclear 2. 
    55# 
    6 # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear 
     6# Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear 
    77# Licensed under the GPL version 2.0 license. 
    88# See LICENSE file or 
     
    1414class dcMenu 
    1515{ 
     16     private $items; 
    1617     private $id; 
    1718     public $title; 
    18  
    19      public function __construct($id,$title,$itemSpace='') 
     19     public $separator; 
     20      
     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(); 
    2527     } 
    26  
     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; 
     47     } 
     48      
    2749     public function addItem($title,$url,$img,$active,$show=true,$id=null,$class=null) 
    2850     { 
     
    3153          } 
    3254     } 
    33  
     55      
    3456     public function prependItem($title,$url,$img,$active,$show=true,$id=null,$class=null) 
    3557     { 
     
    3860          } 
    3961     } 
    40  
    41      public function draw() 
    42      { 
    43           if (count($this->items) == 0) { 
    44                return ''; 
    45           } 
    46  
    47           $res = 
    48           '<div id="'.$this->id.'">'. 
    49           ($this->title ? '<h3>'.$this->title.'</h3>' : ''). 
    50           '<ul>'."\n"; 
    51  
    52           for ($i=0; $i<count($this->items); $i++) 
    53           { 
    54                if ($i+1 < count($this->items) && $this->itemSpace != '') { 
    55                     $res .= preg_replace('|</li>$|',$this->itemSpace.'</li>',$this->items[$i]); 
    56                     $res .= "\n"; 
    57                } else { 
    58                     $res .= $this->items[$i]."\n"; 
    59                } 
    60           } 
    61  
    62           $res .= '</ul></div>'."\n"; 
    63  
    64           return $res; 
    65      } 
    66  
     62      
    6763     protected function itemDef($title,$url,$img,$active,$id=null,$class=null) 
    6864     { 
     
    7470               $ahtml = ''; 
    7571          } 
    76  
    77           $img = dc_admin_icon_url($img); 
    78  
     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     */ 
     87     public function draw() 
     88     { 
     89          if (count($this->items) == 0) { 
     90               return ''; 
     91          } 
     92           
     93          $res = 
     94          '<div id="'.$this->id.'">'. 
     95          ($this->title ? '<h3>'.$this->title.'</h3>' : ''). 
     96          '<ul>'."\n"; 
     97           
     98          for ($i=0; $i<count($this->items); $i++) 
     99          { 
     100               if ($i+1 < count($this->items) && $this->separator != '') { 
     101                    $res .= preg_replace('|</li>$|',$this->separator.'</li>',$this->drawItem($this->items[$i])); 
     102                    $res .= "\n"; 
     103               } else { 
     104                    $res .= $this->drawItem($this->items[$i])."\n"; 
     105               } 
     106          } 
     107           
     108          $res .= '</ul></div>'."\n"; 
     109           
     110          return $res; 
     111     } 
     112      
     113     /** 
     114     @deprecated Use Template engine instead 
     115     */ 
     116     protected function drawItem($item) 
     117     { 
    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          '>'. 
    84  
    85           '<a href="'.$link.'"'.$ahtml.'>'.$title.'</a></li>'."\n"; 
     123           
     124          '<a href="'.$item['link'].'"'.$item['ahtml'].'>'.$item['title'].'</a></li>'."\n"; 
    86125     } 
    87126} 
     127?> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map