Re: [phplib] menu.inc troubles under PHP4.04pl1 From: Alexandr E. Bravo (abravo <email protected>)
Date: 01/16/01

Paolo Brutti wrote:

> I've banged my head against this problem when php4 was released:

Below is my solution (as a patch to original menu.inc) for menu under PHP4. It
differs a bit from Paolo's changes but allows to keep "" as a root item value.
Not sure that it's bugs free, checked it on two menu configurations only.

-------------

--- /tmp/php-lib/php/html/menu.inc Wed Jul 12 15:05:15 2000
+++ menu.inc Tue Jan 16 13:58:12 2001
@@ -5,7 +5,7 @@
  * Copyright (c) 1999 NetUSE GmbH
  * Kristian Koehntopp
  *
- * $Id: menu.inc,v 1.2 2000/07/12 11:05:15 kk Exp $
+ * $Id: menu.inc,v 1.1 2000/11/19 11:02:42 abravo Exp $
  *
  */
 class Menu {
@@ -184,10 +184,11 @@
   /* private: normalize current menu position
    */
   function normalize_pos($pos) {
- if ( $m = $this->urlmap[basename($pos)] )
+ $m = $this->urlmap[basename($pos)];
+ if ( isset($m) )
         return($m);
     $m = $pos;
- while(substr($m, 0, 1)) {
+ while( strlen($m)>1 ) {
       if ($this->urlmap[$m])
         break;
       $m = dirname($m);
@@ -244,6 +245,7 @@
     reset($this->urlmap);
     while(list($k, $v) = each($this->urlmap)) {
       $base = dirname($v);
+ if ($base=="/") { $base=""; }
       $this->children[$base][] = $v;
       $this->item[$v]["url"] = $k;
     }

-------------

Alexandr Bravo
abravo <email protected>

---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>