X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fdiogenes.barrel.inc.php;h=b348c7ee406c84e56fc43db120e524f2aba7754d;hb=2f25588f79339ef0d0f27bfda9ddfbe1b1675c26;hp=d217a35f7bbdd7e523c4a3908ddc01e5c264caf2;hpb=6855525e48fad5de270500a5445c4f4ff85d8bda;p=diogenes.git diff --git a/include/diogenes.barrel.inc.php b/include/diogenes.barrel.inc.php index d217a35..b348c7e 100644 --- a/include/diogenes.barrel.inc.php +++ b/include/diogenes.barrel.inc.php @@ -21,6 +21,7 @@ require_once 'diogenes.page.inc.php'; require_once 'Barrel.php'; +require_once 'Barrel/Menu.php'; /** This class is used to display a page of a Diogenes barrel, * that is an RCS-managed website with a virtual directory @@ -213,6 +214,7 @@ class DiogenesBarrel extends DiogenesPage $render_plugin = $plugobj; } } + // source page or pass it to a rendering plugin if (is_object($render_plugin)) { $content = $render_plugin->render($path); @@ -312,6 +314,9 @@ class DiogenesBarrel extends DiogenesPage // favicon if ($bbarrel->options->favicon) array_push($this->head, 'options->favicon).'" type="image/png" />'); + + // RSS feed + array_push($this->head, ''); } @@ -352,73 +357,9 @@ class DiogenesBarrel extends DiogenesPage if (!isset($this->table_menu)) return; - // try to figure out the current MID from the current PID - // and build filiation - $filiation = array(); - $res = $this->dbh->query("select MID from {$this->table_menu} where PID='$PID'"); - while (list($MID) = mysql_fetch_row($res)) - $filiation = $this->menuToRoot($MID, $filiation); - mysql_free_result($res); - // add the user-defined part of the menu - $this->menu = array_merge($this->menu,$this->menuRecurse(0,$filiation,0)); - } - - - /** Return the filiation to get to the root element. - * - * @param MID - * @param path - */ - function menuToRoot($MID, $path) { - /* add ourself to the path */ - array_push($path,$MID); - - if ($MID) { - /* recursion */ - $res = $this->dbh->query("select MIDpere from {$this->table_menu} where MID=$MID"); - list($MIDpere) = mysql_fetch_row($res); - mysql_free_result($res); - - return $this->menuToRoot($MIDpere, $path); - } else { - /* termination */ - return $path; - } - } - - - /** Recursively add menu entries - * - * @param MIDpere - * @param filiation - * @param level - */ - function menuRecurse($MIDpere, $filiation, $level) { - // the produced output - $out = array(); - - $res = $this->dbh->query("select m.MID,m.title,m.link,m.PID ". - "from {$this->table_menu} as m ". - "where MIDpere=$MIDpere order by ordre"); - - while(list($mid,$title,$link,$pid) = mysql_fetch_row($res)) { - $location = $this->barrel->getLocation($pid); -// echo "pid : $pid, location : $location
"; - $title = stripslashes($title); - $entry = htmlentities(stripslashes($title), ENT_QUOTES); - $link = $pid ? $this->urlSite($location) : $link; - // decide whether this menu should be expanded - $expanded = ($this->barrel->options->menu_min_level == 0) || - ($level+1 < $this->barrel->options->menu_min_level) || - in_array($mid, $filiation); - array_push($out, array($level, $entry, $link, $expanded)); - $out = array_merge($out, $this->menuRecurse($mid, $filiation, $level+1)); - } - - // free MySQL result and return output - mysql_free_result($res); - return $out; + $bmenu = new Diogenes_Barrel_Menu($this->dbh, $this->table_menu); + $this->menu = array_merge($this->menu, $bmenu->makeMenu($PID, $this->barrel->options->menu_min_level, array($this, 'urlSiteByPid'))); } @@ -468,7 +409,7 @@ class DiogenesBarrel extends DiogenesPage } return $path; } - + /** Returns the URL to one of the barrel's pages relative to * the current location. @@ -483,6 +424,18 @@ class DiogenesBarrel extends DiogenesPage return strlen($url) ? $url : "./"; } + + /** Returns the URL to one of the barrel's pages relative to + * the current location. + * + * @param dir + * @param file + */ + function urlSiteByPid($PID, $file = '') + { + return $this->urlSite($this->barrel->getLocation($PID), $file); + } + } ?>