1fbb24f687d49319ce289467b66413c1be806683
2 require_once 'diogenes.common.inc.php';
3 require_once 'diogenes.admin.inc.php';
4 require_once 'Barrel/Menu.php';
5 require_once 'Barrel/Page.php';
7 $page = new DiogenesAdmin
;
8 $bbarrel =& $page->barrel
;
9 $bmenu = new Diogenes_Barrel_Menu($globals->db
, $bbarrel->table_menu
);
11 // the id of the parent menu
12 $MIDpere = isset($_REQUEST['MIDpere']) ?
$_REQUEST['MIDpere'] : 0;
14 //// start constructing the page
16 $page->assign('greeting',__("The site's menus"));
17 $action = isset($_REQUEST['action']) ?
$_REQUEST["action"] : "";
20 /* we want to erase the current entry */
22 $MID = $_REQUEST['MID'];
23 $bmenu->deleteEntry($MID, $MIDpere, $page);
26 /* bring an entry up in the menu */
28 $ordre = $_REQUEST['ordre'];
29 $bmenu->swapEntries($MIDpere, $ordre-1, $ordre);
32 /* push an entry down in the menu */
34 $ordre = $_REQUEST['ordre'];
35 $bmenu->swapEntries($MIDpere, $ordre, $ordre+
1);
38 /* create or update a menu entry */
40 $typelink = $_REQUEST['typelink'];
45 'title' => $_REQUEST['title'],
49 $props['pid'] = isset($_REQUEST['PIvaleur']) ?
$_REQUEST['PIvaleur'] : 0;
52 $props['link'] = $_REQUEST['SEvaleur'];
55 $MID = $bmenu->writeEntry($_REQUEST['MID'], $props);
58 /* display the form to edit an entry */
64 $MID = isset($_REQUEST['MID']) ?
$_REQUEST['MID'] : 0;
66 // if this is an existing entry, retrieve data
68 $mcache = $bmenu->menuRead();
69 $link = $mcache[$MID]['link'];
70 $title = $mcache[$MID]['title'];
71 $pid = $mcache[$MID]['pid'];
76 $chk_se = ($link != "");
77 $chk_z = !$chk_pi && !$chk_se;
78 $chk = " checked=\"checked\"";
80 $page->assign('post',$page->script_self());
81 $page->assign('MID', $MID);
82 $page->assign('MIDpere',$_REQUEST['MIDpere']);
83 $page->assign('title',stripslashes($title));
84 $page->assign('chk_z',($chk_z ?
$chk : ""));
85 $page->assign('chk_pi',($chk_pi ?
$chk : ""));
86 $page->assign('chk_se',($chk_se ?
$chk : ""));
87 $page->assign('SEvaleur', $link ?
$link : "http://");
88 $page->assign('page_sel',$pid);
90 // retrieve all the barrel's pages
91 $fpages = $bbarrel->getPages();
93 foreach($fpages as $pkey => $ppage)
95 $pageloc = $bbarrel->getLocation($pkey);
96 $page_opts[$pkey] = ( strlen($pageloc) ?
"<$pageloc> " : "") . $ppage->props
['title'];
98 $page->assign('page_opts', $page_opts);
100 $res = $globals->db
->query("SELECT PID,title from {$bbarrel->table_page} ORDER BY title");
101 while (list($myPID,$myTITLE) = mysql_fetch_row($res)) {
102 //$pageloc = $bbarrel->getLocation($pkey);
103 //$page_opts[$pkey] = ( strlen($pageloc) ? "<$pageloc> " : "") . $ppage->props['title'];
104 $page->append('page_values',$myPID);
105 $page->append('page_names',stripslashes($myTITLE));
107 mysql_free_result($res);
109 $page->assign('doedit',1);
112 $page->assign('msg_prop',__("menu entry properties"));
113 $page->assign('msg_title',__("entry title"));
114 $page->assign('msg_type',__("type of link"));
115 $page->assign('msg_type_z',__("none"));
116 $page->assign('msg_type_pi',__("internal link"));
117 $page->assign('msg_type_se',__("external link"));
119 $page->assign('submit',__("Submit"));
120 $page->display('admin-menus.tpl');
125 // get the maximum order
126 $maxOrdre = $bmenu->maxChildIndex($MIDpere);
128 // all menu entries from database
129 $mcache = $bmenu->menuRead();
131 foreach($mcache[$MIDpere]['children'] as $MID)
133 $ordre = $mcache[$MID]['ordre'];
134 $title = $mcache[$MID]['title'];
135 $link = $mcache[$MID]['link'];
136 $PID = $mcache[$MID]['pid'];
137 $clickup="?action=remonter&MIDpere=$MIDpere&ordre=$ordre";
138 $clickdown="?action=descendre&MIDpere=$MIDpere&ordre=$ordre";
140 // do we offer an "up" link ?
141 $up = ($ordre != 1) ?
array(__("move up"),$clickup) : _("move up");
143 // do we offer a "down" link ?
144 $down = ($ordre != $maxOrdre) ?
array(__("move down"),$clickdown) : $down = __("move down");
146 $edit = array(__("edit"), "?action=editer&MIDpere=$MIDpere&MID=$MID");
147 $del = array(__("delete"), "?action=supprimer&MIDpere=$MIDpere&MID=$MID");
149 // describe the current link
151 $tpage = Diogenes_Barrel_Page
::fromDb($bbarrel, $PID);
152 $descr = "<a href=\"pages?dir=$PID\">".$tpage->props
['title']."</a>";
154 $descr = "<a href=\"$link\">[ext] $link</a>";
159 // smarty assignments
160 $page->append('entries',
161 array($MID, array(stripslashes($title), "?MIDpere=$MID"),
162 stripslashes($descr),
163 $edit,$del,$up,$down));
166 // all menu entries from database
167 $filiation = $bmenu->menuToRoot($mcache,$MIDpere,array());
169 foreach($filiation as $mykey=>$myval) {
171 $blab = "<i>home</i>";
173 $blab = stripslashes($mcache[$myval]['title']);
175 array_unshift($menubar,$mykey ?
array($blab,"?MIDpere=$myval") : array($blab));
177 $page->assign('menubar',$menubar);
178 $page->assign('script',$page->script_self());
179 $page->assign('MIDpere',$MIDpere);
182 $page->assign('msg_ext',__("External links are denoted with the [ext] prefix."));
183 $page->assign('msg_menu',__("menu name"));
184 $page->assign('msg_link',__("link"));
185 $page->assign('msg_actions',__("actions"));
186 $page->assign('msg_menubar',__("Menu"));
187 $page->assign('submit',__("Add new entry"));
188 $page->display('admin-menus.tpl');