diff options
Diffstat (limited to 'h-source/Library/Helper/Menu.php')
-rwxr-xr-x | h-source/Library/Helper/Menu.php | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/h-source/Library/Helper/Menu.php b/h-source/Library/Helper/Menu.php index 8fd4bf4..4b33261 100755 --- a/h-source/Library/Helper/Menu.php +++ b/h-source/Library/Helper/Menu.php @@ -2,7 +2,7 @@ // EasyGiant is a PHP framework for creating and managing dynamic content // -// Copyright (C) 2009 - 2011 Antonio Gallo +// Copyright (C) 2009 - 2014 Antonio Gallo (info@laboratoriolibero.com) // See COPYRIGHT.txt and LICENSE.txt. // // This file is part of EasyGiant @@ -25,7 +25,8 @@ if (!defined('EG')) die('Direct access not allowed!'); //class to write the top menĂ¹ of the view files class Helper_Menu extends Helper_Html { - + public static $htmlLinks = array(); + public $panelController; //panel controller public $controller; @@ -49,6 +50,7 @@ class Helper_Menu extends Helper_Html 'text' => $this->strings->gtext('Back'), 'url' => 'main', 'icon' => $baseUrl."left.png", + 'queryString' => null, ), 'add' => array( @@ -57,6 +59,7 @@ class Helper_Menu extends Helper_Html 'text' => $this->strings->gtext('Add'), 'url' => 'form/insert', 'icon' => $baseUrl."add.png", + 'queryString' => null, ), 'panel' => array( @@ -65,9 +68,25 @@ class Helper_Menu extends Helper_Html 'text' => $this->strings->gtext('Panel'), 'url' => 'main', 'icon' => $baseUrl."panel.png", + 'queryString' => null, ) ); + + foreach (self::$htmlLinks as $k => $v) + { + if (!array_key_exists($k, $this->links)) + { + $this->links[$k] = $v; + } + else + { + foreach ($v as $subK => $subV) + { + $this->links[$k][$subK] = $subV; + } + } + } } public function build($controller = null, $panelController = null) @@ -89,8 +108,11 @@ class Helper_Menu extends Helper_Html //check that the text and the ure are defined if (isset($this->links[$linkName]['text']) and isset($this->links[$linkName]['url'])) { - $title = isset($this->links[$linkName]['title']) ? "title='".$this->links[$linkName]['title']."'" : null; + $title = isset($this->links[$linkName]['title']) ? "title=\"".$this->links[$linkName]['title']."\"" : null; + $class = isset($this->links[$linkName]['class']) ? "class='".$this->links[$linkName]['class']."'" : null; + $class = isset(self::$htmlLinks[$linkName]["class"]) ? "class='".self::$htmlLinks[$linkName]["class"]."'" : $class; + $icon = isset($this->links[$linkName]['icon']) ? "<img class='top_menu_icon' src='".$this->links[$linkName]['icon']."'> " : null; //choose the controller (current or panel) @@ -98,8 +120,18 @@ class Helper_Menu extends Helper_Html $viewStatus = (strcmp($linkName,'panel') === 0) ? null : $this->viewStatus; $href = Url::getRoot($controller.$this->links[$linkName]['url'].$viewStatus); + + if (isset($this->links[$linkName]['queryString'])) + { + $href .= $this->links[$linkName]['queryString']; + } + $text = $this->links[$linkName]['text']; - $menu .= "<div $class>$icon <a $title href='$href'>$text</a></div>\n"; + $htmlBefore = isset($this->links[$linkName]["htmlBefore"]) ? $this->links[$linkName]["htmlBefore"] : "<div $class>$icon "; + $htmlAfter = isset($this->links[$linkName]["htmlAfter"]) ? $this->links[$linkName]["htmlAfter"] : "</div>"; + $attributes = isset($this->links[$linkName]["attributes"]) ? $this->links[$linkName]["attributes"] : null; + + $menu .= "$htmlBefore<a $title $attributes href='$href'>$text</a>$htmlAfter\n"; } } } |