X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;ds=sidebyside;f=include%2Fadmin%2Fmenus.php;h=1fbb24f687d49319ce289467b66413c1be806683;hb=a424d15c854ee0782fefdc32ec1c76dbb117adca;hp=5fd313b680073c4ff8d8eb5413d48eb15931c630;hpb=cf637ef87f5fb7d80b62c74b6ecbaae13ecc5da3;p=diogenes.git
diff --git a/include/admin/menus.php b/include/admin/menus.php
index 5fd313b..1fbb24f 100644
--- a/include/admin/menus.php
+++ b/include/admin/menus.php
@@ -2,6 +2,7 @@
require_once 'diogenes.common.inc.php';
require_once 'diogenes.admin.inc.php';
require_once 'Barrel/Menu.php';
+require_once 'Barrel/Page.php';
$page = new DiogenesAdmin;
$bbarrel =& $page->barrel;
@@ -19,7 +20,7 @@ switch ($action) {
/* we want to erase the current entry */
case "supprimer":
$MID = $_REQUEST['MID'];
- $bmenu->deleteEntry($MID, $page);
+ $bmenu->deleteEntry($MID, $MIDpere, $page);
break;
/* bring an entry up in the menu */
@@ -37,30 +38,21 @@ case "descendre":
/* create or update a menu entry */
case "modifier":
$typelink = $_REQUEST['typelink'];
+ $props = array(
+ 'parent' => $MIDpere,
+ 'pid' => 0,
+ 'link' => '',
+ 'title' => $_REQUEST['title'],
+ );
switch ($typelink) {
case "boutonPI" :
- $pid = isset($_REQUEST['PIvaleur']) ? $_REQUEST['PIvaleur'] : 0;
- $link = "";
+ $props['pid'] = isset($_REQUEST['PIvaleur']) ? $_REQUEST['PIvaleur'] : 0;
break;
case "boutonSE" :
- $pid = 0;
- $link = $_REQUEST['SEvaleur'];
+ $props['link'] = $_REQUEST['SEvaleur'];
break;
- default:
- $pid = 0;
- $link = "";
}
- $MID = $_REQUEST['MID'];
- $title = $_REQUEST['title'];
- if ($MID == 0) {
- $ordre = $bmenu->maxChildIndex($MIDpere);
- $ordre++;
- $globals->db->query("INSERT INTO {$bbarrel->table_menu} SET MIDpere='$MIDpere',ordre='$ordre',title='$title',link='$link',pid='$pid'");
- $MID = mysql_insert_id();
- } else {
- $globals->db->query("UPDATE {$bbarrel->table_menu} SET title='$title',link='$link',pid='$pid' WHERE MID=$MID");
- }
-
+ $MID = $bmenu->writeEntry($_REQUEST['MID'], $props);
break;
/* display the form to edit an entry */
@@ -73,9 +65,10 @@ case "editer":
// if this is an existing entry, retrieve data
if ($MID) {
- $res = $globals->db->query("SELECT link,title,pid FROM {$bbarrel->table_menu} WHERE MID=$MID");
- list($link, $title, $pid) = mysql_fetch_row($res);
- mysql_free_result($res);
+ $mcache = $bmenu->menuRead();
+ $link = $mcache[$MID]['link'];
+ $title = $mcache[$MID]['title'];
+ $pid = $mcache[$MID]['pid'];
}
// fill out form data
@@ -132,12 +125,15 @@ case "editer":
// get the maximum order
$maxOrdre = $bmenu->maxChildIndex($MIDpere);
-// retrieve the entries
-$res = $globals->db->query("SELECT m.MID,m.ordre,m.title,m.link,m.PID,p.title ".
- "from {$bbarrel->table_menu} as m ".
- "left join {$bbarrel->table_page} as p on m.PID=p.PID ".
- "where MIDpere=$MIDpere order by ordre");
-while (list($MID,$ordre,$title,$link,$PID,$ptitle) = mysql_fetch_row($res)) {
+// all menu entries from database
+$mcache = $bmenu->menuRead();
+
+foreach($mcache[$MIDpere]['children'] as $MID)
+{
+ $ordre = $mcache[$MID]['ordre'];
+ $title = $mcache[$MID]['title'];
+ $link = $mcache[$MID]['link'];
+ $PID = $mcache[$MID]['pid'];
$clickup="?action=remonter&MIDpere=$MIDpere&ordre=$ordre";
$clickdown="?action=descendre&MIDpere=$MIDpere&ordre=$ordre";
@@ -152,7 +148,8 @@ while (list($MID,$ordre,$title,$link,$PID,$ptitle) = mysql_fetch_row($res)) {
// describe the current link
if ($PID) {
- $descr = "$ptitle";
+ $tpage = Diogenes_Barrel_Page::fromDb($bbarrel, $PID);
+ $descr = "".$tpage->props['title']."";
} elseif ($link) {
$descr = "[ext] $link";
} else {
@@ -165,20 +162,15 @@ while (list($MID,$ordre,$title,$link,$PID,$ptitle) = mysql_fetch_row($res)) {
stripslashes($descr),
$edit,$del,$up,$down));
}
-mysql_free_result($res);
// all menu entries from database
-$mcache = $bmenu->menuRead();
$filiation = $bmenu->menuToRoot($mcache,$MIDpere,array());
$menubar = array();
foreach($filiation as $mykey=>$myval) {
if ($myval == 0) {
$blab = "home";
} else {
- $res = $globals->db->query("SELECT title FROM {$bbarrel->table_menu} WHERE MID='$myval'");
- list($blab) = mysql_fetch_row($res);
- $blab = stripslashes($blab);
- mysql_free_result($res);
+ $blab = stripslashes($mcache[$myval]['title']);
}
array_unshift($menubar,$mykey ? array($blab,"?MIDpere=$myval") : array($blab));
}