cvs: pear /HTML_Menu Menu.php MenuBrowser.php package.xml /HTML_Menu/Menu ArrayRenderer.php
| From: | Alexey Borzov | Date: | Mon, 15 Sep 2003 17:24:38 +0000 |
| Subject: | cvs: pear /HTML_Menu Menu.php MenuBrowser.php package.xml /HTML_Menu/Menu ArrayRenderer.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-12755@lists.php.net to get a copy of this message | ||
avb Mon Sep 15 13:24:38 2003 EDT
Added files:
/pear/HTML_Menu/Menu ArrayRenderer.php
Modified files:
/pear/HTML_Menu package.xml MenuBrowser.php Menu.php
Log:
* added Array renderer
* fixed some PHPDoc
* still preparing 2.0
Index: pear/HTML_Menu/package.xml diff -u pear/HTML_Menu/package.xml:1.4 pear/HTML_Menu/package.xml:1.5 --- pear/HTML_Menu/package.xml:1.4 Fri Sep 12 09:30:49 2003 +++ pear/HTML_Menu/package.xml Mon Sep 15 13:24:38 2003 @@ -28,10 +28,14 @@ <state>stable</state> <date>2003-09-??</date> <notes> -HTML_Menu now outputs the menu through renderers +HTML_Menu class does not contain output logic itself anymore. Output is now done via +external Renderer classes. This will cause BC break if you extended HTML_Menu to customize +its output. +Additions and changes: - Added Direct renderer: based on old code but it is possible to customize its output - Added Sigma renderer that uses an instance of HTML_Template_Sigma for output +- Added Array renderer that creates an array of menu's visible entries - Added usage examples - Changed 'prevnext' menu generation, previous element is now the one closest to the current. </notes> @@ -41,6 +45,7 @@ <file role="php" name="MenuBrowser.php"/> <dir name="Menu"> <file role="php" name="Renderer.php"/> + <file role="php" name="ArrayRenderer.php"/> <file role="php" name="DirectRenderer.php"/> <file role="php" name="SigmaRenderer.php"/> </dir> Index: pear/HTML_Menu/MenuBrowser.php diff -u pear/HTML_Menu/MenuBrowser.php:1.3 pear/HTML_Menu/MenuBrowser.php:1.4 --- pear/HTML_Menu/MenuBrowser.php:1.3 Mon Aug 25 07:08:35 2003 +++ pear/HTML_Menu/MenuBrowser.php Mon Sep 15 13:24:38 2003 @@ -16,7 +16,7 @@ // | Author: Ulf Wendel <ulf.wendel@phpdoc.de> | // +----------------------------------------------------------------------+ // -// $Id: MenuBrowser.php,v 1.3 2003/08/25 11:08:35 avb Exp $ +// $Id: MenuBrowser.php,v 1.4 2003/09/15 17:24:38 avb Exp $ /** * Simple filesystem browser that can be used to generated menu (3) hashes based on the directory structure. @@ -45,7 +45,7 @@ * (title!). Subclass exploreFile() depending on your file format. * * @author Ulf Wendel <ulf.wendel@phpdoc.de> -* @version $Revision: 1.3 $ +* @version $Revision: 1.4 $ * @package HTML_Menu */ class HTML_MenuBrowser @@ -54,7 +54,7 @@ * Filesuffix of your XML files. * * @var string - * @see menubrowser() + * @see HTML_MenuBrowser() */ var $file_suffix = 'xml'; @@ -62,7 +62,7 @@ * Number of characters of the file suffix. * * @var int - * @see menubrowser() + * @see HTML_MenuBrowser() */ var $file_suffix_length = 3; @@ -70,7 +70,7 @@ * Filename (without suffix) of your index / start pages. * * @var string - * @see menubrowser() + * @see HTML_MenuBrowser() */ var $index = 'index'; @@ -228,7 +228,7 @@ /** * Adds further informations to the menu hash gathered from the files in it * - * @var array Menu hash to examine + * @param array Menu hash to examine * @return array Modified menu hash with the new informations */ function addFileInfo($menu) Index: pear/HTML_Menu/Menu.php diff -u pear/HTML_Menu/Menu.php:1.6 pear/HTML_Menu/Menu.php:1.7 --- pear/HTML_Menu/Menu.php:1.6 Wed Sep 10 10:13:14 2003 +++ pear/HTML_Menu/Menu.php Mon Sep 15 13:24:38 2003 @@ -18,7 +18,7 @@ // | Alexey Borzov <avb@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Menu.php,v 1.6 2003/09/10 14:13:14 avb Exp $ +// $Id: Menu.php,v 1.7 2003/09/15 17:24:38 avb Exp $ // // Types of the menu entries, instead of former magic numbers @@ -35,7 +35,7 @@ * * Special thanks to the original author: Alex Vorobiev <sasha@mathforum.com>. * -* @version $Revision: 1.6 $ +* @version $Revision: 1.7 $ * @author Ulf Wendel <ulf.wendel@phpdoc.de> * @author Alexey Borzov <avb@php.net> * @access public @@ -101,10 +101,10 @@ /** * Initializes the menu, sets the type and menu structure. * - * @param array - * @param string - * @param string - * @see setMenuType(), setMenu() + * @param array menu structure + * @param string menu type + * @param string env. variable used to determine current URL + * @see setMenuType(), setMenu(), setURLEnvVar() */ function HTML_Menu($menu = null, $type = 'tree', $urlEnvVar = 'PHP_SELF') { @@ -150,7 +150,6 @@ * * @param array * @access public - * @see append(), update() */ function setMenu($menu) { @@ -196,6 +195,7 @@ * @param string Menu type: tree, urhere, rows, prevnext, sitemap * @return string HTML of the menu * @access public + * @see render() */ function get($menuType = '') { @@ -211,7 +211,7 @@ * * @access public * @param string Menu type: tree, urhere, rows, prevnext, sitemap - * @see get() + * @see get(), render() */ function show($menuType = '') { Index: pear/HTML_Menu/Menu/ArrayRenderer.php +++ pear/HTML_Menu/Menu/ArrayRenderer.php <?php // // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997-2003 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.0 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | http://www.php.net/license/2_02.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Author: Alexey Borzov <avb@php.net> | // +----------------------------------------------------------------------+ // // $Id: ArrayRenderer.php,v 1.1 2003/09/15 17:24:38 avb Exp $ // require_once 'HTML/Menu/Renderer.php'; /** * The renderer that creates an array of visible menu entries. * * The resultant array can be used with e.g. a template engine to produce * a completely custom menu look. * All menu types except 'rows' are "rendered" into a one-dimensional array * of entries: * array( * 'entry1', * ... * 'entryN' * ) * while 'rows' produce a two-dimensional array: * array( * array('entry 1 for row 1', ..., 'entry M_1 for row 1'), * ... * array('entry 1 for row N', ..., 'entry M_N for row 1') * ) * Here entry is * array( * 'url' => url element of menu entry * 'title' => title element of menu entry * 'level' => entry's depth in the tree structure * 'type' => type of entry, one of HTML_MENU_ENTRY_* constants * ) * * @version $Revision: 1.1 $ * @author Alexey Borzov <avb@php.net> * @access public * @package HTML_Menu */ class HTML_Menu_ArrayRenderer extends HTML_Menu_Renderer { /** * Generated array * @var array */ var $_ary = array(); /** * Array for the current "menu", that is moved into $_ary by finishMenu(), * makes sense mostly for 'rows * @var array */ var $_menuAry = array(); function finishMenu($level) { if ('rows' == $this->_menuType) { $this->_ary[] = $this->_menuAry; } else { $this->_ary = $this->_menuAry; } $this->_menuAry = array(); } function renderEntry($node, $level, $type) { $this->_menuAry[] = array( 'url' => $node['url'], 'title' => $node['title'], 'level' => $level, 'type' => $type ); } /** * Returns the resultant array * * @access public * @return array */ function toArray() { return $this->_ary; } } ?>
Index: pear/HTML_Menu/package.xml diff -u pear/HTML_Menu/package.xml:1.4 pear/HTML_Menu/package.xml:1.5 --- pear/HTML_Menu/package.xml:1.4 Fri Sep 12 09:30:49 2003 +++ pear/HTML_Menu/package.xml Mon Sep 15 13:24:38 2003 @@ -28,10 +28,14 @@ <state>stable</state> <date>2003-09-??</date> <notes> -HTML_Menu now outputs the menu through renderers +HTML_Menu class does not contain output logic itself anymore. Output is now done via +external Renderer classes. This will cause BC break if you extended HTML_Menu to customize +its output. +Additions and changes: - Added Direct renderer: based on old code but it is possible to customize its output - Added Sigma renderer that uses an instance of HTML_Template_Sigma for output +- Added Array renderer that creates an array of menu's visible entries - Added usage examples - Changed 'prevnext' menu generation, previous element is now the one closest to the current. </notes> @@ -41,6 +45,7 @@ <file role="php" name="MenuBrowser.php"/> <dir name="Menu"> <file role="php" name="Renderer.php"/> + <file role="php" name="ArrayRenderer.php"/> <file role="php" name="DirectRenderer.php"/> <file role="php" name="SigmaRenderer.php"/> </dir> Index: pear/HTML_Menu/MenuBrowser.php diff -u pear/HTML_Menu/MenuBrowser.php:1.3 pear/HTML_Menu/MenuBrowser.php:1.4 --- pear/HTML_Menu/MenuBrowser.php:1.3 Mon Aug 25 07:08:35 2003 +++ pear/HTML_Menu/MenuBrowser.php Mon Sep 15 13:24:38 2003 @@ -16,7 +16,7 @@ // | Author: Ulf Wendel <ulf.wendel@phpdoc.de> | // +----------------------------------------------------------------------+ // -// $Id: MenuBrowser.php,v 1.3 2003/08/25 11:08:35 avb Exp $ +// $Id: MenuBrowser.php,v 1.4 2003/09/15 17:24:38 avb Exp $ /** * Simple filesystem browser that can be used to generated menu (3) hashes based on the directory structure. @@ -45,7 +45,7 @@ * (title!). Subclass exploreFile() depending on your file format. * * @author Ulf Wendel <ulf.wendel@phpdoc.de> -* @version $Revision: 1.3 $ +* @version $Revision: 1.4 $ * @package HTML_Menu */ class HTML_MenuBrowser @@ -54,7 +54,7 @@ * Filesuffix of your XML files. * * @var string - * @see menubrowser() + * @see HTML_MenuBrowser() */ var $file_suffix = 'xml'; @@ -62,7 +62,7 @@ * Number of characters of the file suffix. * * @var int - * @see menubrowser() + * @see HTML_MenuBrowser() */ var $file_suffix_length = 3; @@ -70,7 +70,7 @@ * Filename (without suffix) of your index / start pages. * * @var string - * @see menubrowser() + * @see HTML_MenuBrowser() */ var $index = 'index'; @@ -228,7 +228,7 @@ /** * Adds further informations to the menu hash gathered from the files in it * - * @var array Menu hash to examine + * @param array Menu hash to examine * @return array Modified menu hash with the new informations */ function addFileInfo($menu) Index: pear/HTML_Menu/Menu.php diff -u pear/HTML_Menu/Menu.php:1.6 pear/HTML_Menu/Menu.php:1.7 --- pear/HTML_Menu/Menu.php:1.6 Wed Sep 10 10:13:14 2003 +++ pear/HTML_Menu/Menu.php Mon Sep 15 13:24:38 2003 @@ -18,7 +18,7 @@ // | Alexey Borzov <avb@php.net> | // +----------------------------------------------------------------------+ // -// $Id: Menu.php,v 1.6 2003/09/10 14:13:14 avb Exp $ +// $Id: Menu.php,v 1.7 2003/09/15 17:24:38 avb Exp $ // // Types of the menu entries, instead of former magic numbers @@ -35,7 +35,7 @@ * * Special thanks to the original author: Alex Vorobiev <sasha@mathforum.com>. * -* @version $Revision: 1.6 $ +* @version $Revision: 1.7 $ * @author Ulf Wendel <ulf.wendel@phpdoc.de> * @author Alexey Borzov <avb@php.net> * @access public @@ -101,10 +101,10 @@ /** * Initializes the menu, sets the type and menu structure. * - * @param array - * @param string - * @param string - * @see setMenuType(), setMenu() + * @param array menu structure + * @param string menu type + * @param string env. variable used to determine current URL + * @see setMenuType(), setMenu(), setURLEnvVar() */ function HTML_Menu($menu = null, $type = 'tree', $urlEnvVar = 'PHP_SELF') { @@ -150,7 +150,6 @@ * * @param array * @access public - * @see append(), update() */ function setMenu($menu) { @@ -196,6 +195,7 @@ * @param string Menu type: tree, urhere, rows, prevnext, sitemap * @return string HTML of the menu * @access public + * @see render() */ function get($menuType = '') { @@ -211,7 +211,7 @@ * * @access public * @param string Menu type: tree, urhere, rows, prevnext, sitemap - * @see get() + * @see get(), render() */ function show($menuType = '') { Index: pear/HTML_Menu/Menu/ArrayRenderer.php +++ pear/HTML_Menu/Menu/ArrayRenderer.php <?php // // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997-2003 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.0 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | http://www.php.net/license/2_02.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Author: Alexey Borzov <avb@php.net> | // +----------------------------------------------------------------------+ // // $Id: ArrayRenderer.php,v 1.1 2003/09/15 17:24:38 avb Exp $ // require_once 'HTML/Menu/Renderer.php'; /** * The renderer that creates an array of visible menu entries. * * The resultant array can be used with e.g. a template engine to produce * a completely custom menu look. * All menu types except 'rows' are "rendered" into a one-dimensional array * of entries: * array( * 'entry1', * ... * 'entryN' * ) * while 'rows' produce a two-dimensional array: * array( * array('entry 1 for row 1', ..., 'entry M_1 for row 1'), * ... * array('entry 1 for row N', ..., 'entry M_N for row 1') * ) * Here entry is * array( * 'url' => url element of menu entry * 'title' => title element of menu entry * 'level' => entry's depth in the tree structure * 'type' => type of entry, one of HTML_MENU_ENTRY_* constants * ) * * @version $Revision: 1.1 $ * @author Alexey Borzov <avb@php.net> * @access public * @package HTML_Menu */ class HTML_Menu_ArrayRenderer extends HTML_Menu_Renderer { /** * Generated array * @var array */ var $_ary = array(); /** * Array for the current "menu", that is moved into $_ary by finishMenu(), * makes sense mostly for 'rows * @var array */ var $_menuAry = array(); function finishMenu($level) { if ('rows' == $this->_menuType) { $this->_ary[] = $this->_menuAry; } else { $this->_ary = $this->_menuAry; } $this->_menuAry = array(); } function renderEntry($node, $level, $type) { $this->_menuAry[] = array( 'url' => $node['url'], 'title' => $node['title'], 'level' => $level, 'type' => $type ); } /** * Returns the resultant array * * @access public * @return array */ function toArray() { return $this->_ary; } } ?>