- $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<br/>";
- $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;