0byt3m1n1-V2
Path:
/
home
/
magalijoj
/
www
/
blog
/
inc
/
admin
/
[
Home
]
File: class.dc.menu.php
<?php # ***** BEGIN LICENSE BLOCK ***** # This file is part of DotClear. # Copyright (c) 2005 Olivier Meunier and contributors. All rights # reserved. # # DotClear is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # DotClear is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with DotClear; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # ***** END LICENSE BLOCK ***** class dcMenu { private $id; private $title; public function __construct($id,$title,$itemSpace='') { $this->id = $id; $this->title = $title; $this->itemSpace = $itemSpace; $this->items = array(); } public function addItem($title,$url,$img,$active,$show=true,$id=NULL) { if($show) { if (is_array($url)) { $link = $url[0]; $ahtml = (!empty($url[1])) ? ' '.$url[1] : ''; } else { $link = $url; $ahtml = ''; } $this->items[] = '<li'.(($active) ? ' class="active"' : ''). (($id) ? ' id="'.$id.'"' : ''). (($img) ? ' style="background-image: url('.$img.');"' : ''). '>'. '<a href="'.$link.'"'.$ahtml.'>'.$title.'</a></li>'."\n"; } } public function draw() { if (count($this->items) == 0) { return ''; } $res = '<div id="'.$this->id.'">'. '<h3>'.$this->title.'</h3>'. '<ul>'."\n"; for ($i=0; $i<count($this->items); $i++) { if ($i+1 < count($this->items) && $this->itemSpace != '') { $res .= preg_replace('|</li>$|',$this->itemSpace.'</li>',$this->items[$i]); $res .= "\n"; } else { $res .= $this->items[$i]."\n"; } } $res .= '</ul></div>'."\n"; return $res; } } ?>
©
2018.