cvs: pear /DB_NestedSet/NestedSet Menu.php /DB_NestedSet/docs Menu_example.php
| From: | Daniel Khan | Date: | Tue, 25 Oct 2005 22:31:48 +0000 |
| Subject: | cvs: pear /DB_NestedSet/NestedSet Menu.php /DB_NestedSet/docs Menu_example.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-35861@lists.php.net to get a copy of this message | ||
datenpunk Tue Oct 25 18:31:48 2005 EDT
Modified files:
/pear/DB_NestedSet/NestedSet Menu.php
/pear/DB_NestedSet/docs Menu_example.php
Log:
Fixed Bug #4349 Problem with driver 'Menu'
http://cvs.php.net/diff.php/pear/DB_NestedSet/NestedSet/Menu.php?r1=1.6&r2=1.7&ty=u
Index: pear/DB_NestedSet/NestedSet/Menu.php
diff -u pear/DB_NestedSet/NestedSet/Menu.php:1.6 pear/DB_NestedSet/NestedSet/Menu.php:1.7
--- pear/DB_NestedSet/NestedSet/Menu.php:1.6 Wed Feb 16 09:31:19 2005
+++ pear/DB_NestedSet/NestedSet/Menu.php Tue Oct 25 18:31:45 2005
@@ -14,7 +14,7 @@
// +----------------------------------------------------------------------+
// | Authors: Daniel Khan <dk@webcluster.at> |
// +----------------------------------------------------------------------+
-// $Id: Menu.php,v 1.6 2005/02/16 14:31:19 datenpunk Exp $
+// $Id: Menu.php,v 1.7 2005/10/25 22:31:45 datenpunk Exp $
// {{{ DB_NestedSet_Menu:: class
/**
* Simple helper class which takes a node array create by DB_NestedSet and transforms it
@@ -23,7 +23,7 @@
* @see docs/Menu_example.php
* @author Daniel Khan <dk@webcluster.at>
* @package DB_NestedSet
- * @version $Revision: 1.6 $
+ * @version $Revision: 1.7 $
* @access public
*/
// }}}
@@ -33,7 +33,7 @@
* @package
* @author daniel
* @copyright Copyright (c) 2004
- * @version $Id: Menu.php,v 1.6 2005/02/16 14:31:19 datenpunk Exp $
+ * @version $Id: Menu.php,v 1.7 2005/10/25 22:31:45 datenpunk Exp $
* @access public
*/
class DB_NestedSet_Menu extends DB_NestedSet_Output {
@@ -78,8 +78,15 @@
* @param $params
* @return array The menu array
**/
- function _createFromStructure($params) {
+ function _createFromStructure($params, $iterate = false) {
static $menuStructure, $menuParts, $offset;
+
+ if(!$iterate) {
+ $menuStructure = array();
+ $menuParts = array();
+ $offset = false;
+ }
+
// always start at level 1
if (!isset($params['currentLevel'])) {
$params['currentLevel'] = 1;
@@ -153,7 +160,7 @@
$recurseParams['structure'] = $children;
$recurseParams['currentLevel']++;
$recurseParams['currentParent'] = & $node;
- $this->_createFromStructure($recurseParams);
+ $this->_createFromStructure($recurseParams, true);
}
}
return $menuStructure;
http://cvs.php.net/diff.php/pear/DB_NestedSet/docs/Menu_example.php?r1=1.6&r2=1.7&ty=u
Index: pear/DB_NestedSet/docs/Menu_example.php
diff -u pear/DB_NestedSet/docs/Menu_example.php:1.6 pear/DB_NestedSet/docs/Menu_example.php:1.7
--- pear/DB_NestedSet/docs/Menu_example.php:1.6 Wed Feb 16 09:30:27 2005
+++ pear/DB_NestedSet/docs/Menu_example.php Tue Oct 25 18:31:48 2005
@@ -1,4 +1,4 @@
-<?php /** $Id: Menu_example.php,v 1.6 2005/02/16 14:30:27 datenpunk Exp $ */ ?>
+<?php /** $Id: Menu_example.php,v 1.7 2005/10/25 22:31:48 datenpunk Exp $ */ ?>
<html>
<title>DB_NestedSet using PEAR::HTML_Menu Output class</title>
<body>
@@ -79,15 +79,15 @@
'r' => 'r',
'STREH' => 'norder',
'LEVEL' => 'level',
- 'STRNA' => 'name',
+ 'STRNA' => 'name',
'parent' => 'parent'
);
-$nestedSet =& DB_NestedSet::factory('DB', $dsn, $params);
+$nestedSet =& DB_NestedSet::factory('DB', $dsn, $params);
// we want the nodes to be displayed ordered by name, so we add the secondarySort attribute
$nestedSet->setAttr(array(
- 'node_table' => 'tb_nodes',
- 'lock_table' => 'tb_locks',
+ 'node_table' => 'tb_nodes',
+ 'lock_table' => 'tb_locks',
'secondarySort' => 'STRNA',
)
);
@@ -110,6 +110,7 @@
// get data (important to fetch it as an array, using the true flag)
// $data = $nestedSet->getAllNodes(true);
$data = $nestedSet->getSubBranch($eh, true);
+$data2 = $nestedSet->getSubBranch($eh4, true);
// }}}
@@ -127,9 +128,15 @@
'titleField' => 'name',
'urlField' => 'url');
-// Create the output driver object
+$params2 = array(
+ 'structure' => $data2,
+ 'titleField' => 'name',
+ 'urlField' => 'url');
+
+// Create the output driver object
$output =& DB_NestedSet_Output::factory($params, 'Menu');
+
// Fetch the menu array
$structure = $output->returnStructure();
@@ -144,7 +151,6 @@
$menu->forceCurrentUrl($currentUrl);
// Output the menu
$menu->show();
-echo "<hr>";
echo "Menu type 'tree'<br>";
// Set another type