Source for file Menu.php
Documentation is available at Menu.php
* A Framework for Creating and Using Complex Web Elements
* The purpose of this framework is to provide a library of high-level objects
* to facilitate common HTML coding tasks, such as menus, tables, and forms.
* The intent is to reduce repetitive HTML coding as much as possible, replacing
* it with a combination of configuration files and style sheets with
* standardized naming conventions.
* This framework is built on and requires the
* {@link http://framework.zend.com/ Zend Framework}.
* @author Lyle Frost <lfrost@cnz.com>
* @copyright Copyright (c) 2006-2007 Citadel Network <{@link http://www.citadelnetwork.com/}>
* @license http://www.citadelnetwork.com/license/cnzframework New BSD License
* @version $Id: Menu.php 27 2007-07-19 18:47:54Z lfrost $
Zend_Loader::loadClass('Cnz_Html_Element');
Zend_Loader::loadClass('Cnz_Html_Menu_Item');
* This class asserts that the most appropriate structure for a menu is an
* unordered list enclosed in a div.
* Each configuration item value is of the form text,link. A blank item will
* cause a horizontal separator line to be created. For multiple blank lines,
* give each line a label, but no link value (e.g., LINE1:). If the text or
* link contains a colon, comma, or backslash, escape them with a backslash.
* Example INI (defaults shown as comments):
* Citadel Network:http\://www.citadelnetwork.com/
* Cnz_Html::loadAndDisplay('Cnz_Html_Menu', array('name' => 'main', 'config' => true, 'style' => true));
* background-color: #FFE4E1;
* border-width: 0 0 3px 3px;
* font-family: Helvetica,Helv,Arial,sans-serif;
* background-color: inherit;
* a[href]:hover.menu-main
* text-decoration: underline;
* background-color: inherit;
* background-color: inherit;
* Note that this class can also be used for horizontal menus by setting
* display:inline for <li>. Setting white-space:nowrap for <ul> may also
* be desired for horizontal menus.
private $itemArray = array();
/* Methods ===========================================================*/
* @param array $options Options
foreach ($menu as $text => $link)
* @param string $style Value for outermost style attribute
public function display($style = NULL)
echo $indent, '<div class = "', $this->genStyles(), '"';
echo ' id = "', $this->genId(), '"';
if (!empty($style)) echo ' style = "', $style, '"';
echo $indent, '<ul class = "', $this->genStyles(), '">', "\n";
$count = count($this->itemArray);
for ($i = 0; $i < $count; $i++ )
$this->itemArray[$i]->display($this->name);
echo $indent, '</ul>', "\n";
echo $indent, '</div>', "\n";
|