uw Thu Mar 29 12:58:37 2001 EDT
Modified files:
/php4/pear/Experimental/HTML Menu_Browser.php
Log:
- Added an optional prefix for menu entries
Index: php4/pear/Experimental/HTML/Menu_Browser.php
diff -u php4/pear/Experimental/HTML/Menu_Browser.php:1.2
php4/pear/Experimental/HTML/Menu_Browser.php:1.3
--- php4/pear/Experimental/HTML/Menu_Browser.php:1.2 Thu Mar 22 10:38:32 2001
+++ php4/pear/Experimental/HTML/Menu_Browser.php Thu Mar 29 12:58:37 2001
@@ -16,7 +16,7 @@
// | Authors: Ulf Wendel <[EMAIL PROTECTED]> |
// +----------------------------------------------------------------------+
//
-// $Id: Menu_Browser.php,v 1.2 2001/03/22 18:38:32 uw Exp $
+// $Id: Menu_Browser.php,v 1.3 2001/03/29 20:58:37 uw 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 <[EMAIL PROTECTED]>
-* @version $Id: Menu_Browser.php,v 1.2 2001/03/22 18:38:32 uw Exp $
+* @version $Id: Menu_Browser.php,v 1.3 2001/03/29 20:58:37 uw Exp $
*/
class menubrowser {
@@ -95,6 +95,19 @@
/**
+ * Prefix for every menu hash entry.
+ *
+ * Set the ID prefix if you want to merge the browser menu
+ * hash with another (static) menu hash so that there're no
+ * name clashes with the ids.
+ *
+ * @var string
+ * @see setIDPrefix()
+ */
+ var $id_prefix = "";
+
+
+ /**
* Menu (3)'s setMenu() hash.
*
* @var array
@@ -103,7 +116,7 @@
/**
- * Creates the object and optionally sets the directoryto scan.
+ * Creates the object and optionally sets the directory to scan.
*
* @param string
* @see $dir
@@ -137,16 +150,32 @@
/**
+ * Sets the prefix for every id in the menu hash.
+ *
+ * @param string
+ * @access public
+ */
+ function setIDPrefix($prefix) {
+
+ $this->id_prefix = $prefix;
+
+ } // end func setIDPrefix
+
+
+ /**
* Returns a hash to be used with menu(3)'s setMenu().
*
* @param string directory to scan
+ * @param string id prefix
* @access public
*/
- function getMenu($dir = "") {
+ function getMenu($dir = "", $prefix = "") {
if ($dir)
$this->setDirectory($dir);
-
+ if ($prefix)
+ $this->setIDPrefix($prefix);
+
// drop the result of previous runs
$this->files = array();
@@ -181,11 +210,11 @@
if (file_exists($ffile . $this->index_file)) {
$id++;
- $struct[$id]["url"] = $ffile . $this->index_file;
+ $struct[$this->id_prefix . $id]["url"] = $ffile . $this->index_file;
$sub = $this->browse($ffile, $id + 1, true);
if (0 != count($sub))
- $struct[$id]["sub"] = $sub;
+ $struct[$this->id_prefix . $id]["sub"] = $sub;
}
@@ -194,7 +223,7 @@
if ($this->file_suffix == substr($file, strlen($file) -
$this->file_suffix_length, $this->file_suffix_length)
&& !($noindex && $this->index_file == $file) ) {
$id++;
- $struct[$id]["url"] = $dir . $file;
+ $struct[$this->id_prefix . $id]["url"] = $dir . $file;
}
}
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]