[532] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
[1179] | 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
[532] | 7 | # Licensed under the GPL version 2.0 license. |
---|
| 8 | # See LICENSE file or |
---|
| 9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
| 10 | # |
---|
| 11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
| 12 | if (!defined('DC_CONTEXT_ADMIN')) { return; } |
---|
| 13 | |
---|
| 14 | dcPage::check('admin'); |
---|
| 15 | |
---|
| 16 | $page_title = __('Simple menu'); |
---|
| 17 | |
---|
| 18 | # Url de base |
---|
| 19 | $p_url = 'plugin.php?p=simpleMenu'; |
---|
| 20 | |
---|
[538] | 21 | # Url du blog |
---|
| 22 | $blog_url = html::stripHostURL($core->blog->url); |
---|
| 23 | |
---|
[532] | 24 | # Liste des catégories |
---|
| 25 | $categories_combo = array(); |
---|
| 26 | $categories_label = array(); |
---|
| 27 | try { |
---|
| 28 | $rs = $core->blog->getCategories(array('post_type'=>'post')); |
---|
| 29 | while ($rs->fetch()) { |
---|
| 30 | $categories_combo[] = new formSelectOption( |
---|
| 31 | str_repeat(' ',$rs->level-1).($rs->level-1 == 0 ? '' : '• ').html::escapeHTML($rs->cat_title), |
---|
| 32 | $rs->cat_url |
---|
| 33 | ); |
---|
| 34 | $categories_label[$rs->cat_url] = html::escapeHTML($rs->cat_title); |
---|
| 35 | } |
---|
| 36 | } catch (Exception $e) { } |
---|
| 37 | |
---|
| 38 | # Liste des langues utilisées |
---|
| 39 | $langs_combo = array(); |
---|
| 40 | try { |
---|
| 41 | $rs = $core->blog->getLangs(array('order'=>'asc')); |
---|
| 42 | if ($rs->count() > 1) |
---|
| 43 | { |
---|
| 44 | $all_langs = l10n::getISOcodes(0,1); |
---|
| 45 | while ($rs->fetch()) { |
---|
| 46 | $lang_name = isset($all_langs[$rs->post_lang]) ? $all_langs[$rs->post_lang] : $rs->post_lang; |
---|
| 47 | $langs_combo[$lang_name] = $rs->post_lang; |
---|
| 48 | } |
---|
| 49 | unset($all_langs); |
---|
| 50 | } |
---|
| 51 | unset($rs); |
---|
| 52 | } catch (Exception $e) { } |
---|
| 53 | |
---|
| 54 | # Liste des mois d'archive |
---|
| 55 | $months_combo = array(); |
---|
| 56 | try { |
---|
| 57 | $rs = $core->blog->getDates(array('type'=>'month')); |
---|
| 58 | $months_combo[__('All months')] = '-'; |
---|
| 59 | $first_year = $last_year = 0; |
---|
| 60 | while ($rs->fetch()) { |
---|
| 61 | $months_combo[dt::str('%B %Y',$rs->ts())] = $rs->year().$rs->month(); |
---|
| 62 | if (($first_year == 0) || ($rs->year() < $first_year)) $first_year = $rs->year(); |
---|
| 63 | if (($last_year == 0) || ($rs->year() > $last_year)) $last_year = $rs->year(); |
---|
| 64 | } |
---|
| 65 | unset($rs); |
---|
| 66 | } catch (Exception $e) { } |
---|
| 67 | |
---|
| 68 | # Liste des pages -- Doit être pris en charge plus tard par le plugin ? |
---|
| 69 | $pages_combo = array(); |
---|
| 70 | try { |
---|
| 71 | $rs = $core->blog->getPosts(array('post_type'=>'page')); |
---|
| 72 | while ($rs->fetch()) { |
---|
| 73 | $pages_combo[$rs->post_title] = $rs->getURL(); |
---|
| 74 | } |
---|
| 75 | unset($rs); |
---|
| 76 | } catch (Exception $e) { } |
---|
| 77 | |
---|
| 78 | # Liste des tags -- Doit être pris en charge plus tard par le plugin ? |
---|
| 79 | $tags_combo = array(); |
---|
| 80 | try { |
---|
| 81 | $rs = $core->meta->getMetadata(array('meta_type' => 'tag')); |
---|
| 82 | $tags_combo[__('All tags')] = '-'; |
---|
| 83 | while ($rs->fetch()) { |
---|
| 84 | $tags_combo[$rs->meta_id] = $rs->meta_id; |
---|
| 85 | } |
---|
| 86 | unset($rs); |
---|
| 87 | } catch (Exception $e) { } |
---|
| 88 | |
---|
| 89 | # Liste des types d'item de menu |
---|
[597] | 90 | $items = new ArrayObject(); |
---|
| 91 | $items['home'] = new ArrayObject(array(__('Home'),false)); |
---|
[532] | 92 | |
---|
| 93 | if (count($langs_combo) > 1) { |
---|
[597] | 94 | $items['lang'] = new ArrayObject(array(__('Language'),true)); |
---|
[532] | 95 | } |
---|
| 96 | if (count($categories_combo)) { |
---|
[597] | 97 | $items['category'] = new ArrayObject(array(__('Category'),true)); |
---|
[532] | 98 | } |
---|
| 99 | if (count($months_combo) > 1) { |
---|
[597] | 100 | $items['archive'] = new ArrayObject(array(__('Archive'),true)); |
---|
[532] | 101 | } |
---|
| 102 | if ($core->plugins->moduleExists('pages')) { |
---|
| 103 | if(count($pages_combo)) |
---|
[597] | 104 | $items['pages'] = new ArrayObject(array(__('Page'),true)); |
---|
[532] | 105 | } |
---|
| 106 | if ($core->plugins->moduleExists('tags')) { |
---|
| 107 | if (count($tags_combo) > 1) |
---|
[597] | 108 | $items['tags'] = new ArrayObject(array(__('Tags'),true)); |
---|
[532] | 109 | } |
---|
[554] | 110 | |
---|
[555] | 111 | # --BEHAVIOR-- adminSimpleMenuAddType |
---|
[587] | 112 | # Should add an item to $items[<id>] as an array(<label>,<optional step (true or false)>) |
---|
[555] | 113 | $core->callBehavior('adminSimpleMenuAddType',$items); |
---|
| 114 | |
---|
[597] | 115 | $items['special'] = new ArrayObject(array(__('User defined'),false)); |
---|
[532] | 116 | |
---|
| 117 | $items_combo = array(); |
---|
| 118 | foreach ($items as $k => $v) { |
---|
| 119 | $items_combo[$v[0]] = $k; |
---|
| 120 | } |
---|
| 121 | |
---|
[534] | 122 | # Lecture menu existant |
---|
| 123 | $menu = $core->blog->settings->system->get('simpleMenu'); |
---|
| 124 | $menu = @unserialize($menu); |
---|
| 125 | if (!is_array($menu)) { |
---|
[538] | 126 | $menu = array(); |
---|
[534] | 127 | } |
---|
| 128 | |
---|
| 129 | # Récupération paramètres postés |
---|
| 130 | $item_type = isset($_POST['item_type']) ? $_POST['item_type'] : ''; |
---|
| 131 | $item_select = isset($_POST['item_select']) ? $_POST['item_select'] : ''; |
---|
[538] | 132 | $item_label = isset($_POST['item_label']) ? $_POST['item_label'] : ''; |
---|
| 133 | $item_descr = isset($_POST['item_descr']) ? $_POST['item_descr'] : ''; |
---|
| 134 | $item_url = isset($_POST['item_url']) ? $_POST['item_url'] : ''; |
---|
[534] | 135 | |
---|
[532] | 136 | # Traitement |
---|
| 137 | $step = (!empty($_GET['add']) ? (integer) $_GET['add'] : 0); |
---|
| 138 | if (($step > 4) || ($step < 0)) $step = 0; |
---|
| 139 | if ($step) { |
---|
| 140 | |
---|
| 141 | # Récupération libellés des choix |
---|
| 142 | $item_type_label = isset($items[$item_type]) ? $items[$item_type][0] : ''; |
---|
| 143 | |
---|
| 144 | switch ($step) { |
---|
| 145 | case 1: |
---|
[534] | 146 | // First step, menu item type to be selected |
---|
[532] | 147 | $item_type = $item_select = ''; |
---|
| 148 | break; |
---|
| 149 | case 2: |
---|
[556] | 150 | if ($items[$item_type][1]) { |
---|
[534] | 151 | // Second step (optional), menu item sub-type to be selected |
---|
[532] | 152 | $item_select = ''; |
---|
| 153 | break; |
---|
| 154 | } |
---|
| 155 | case 3: |
---|
[534] | 156 | // Third step, menu item attributes to be changed or completed if necessary |
---|
[532] | 157 | $item_select_label = ''; |
---|
[545] | 158 | $item_label = __('Label'); |
---|
[532] | 159 | $item_descr = __('Description'); |
---|
[534] | 160 | $item_url = $blog_url; |
---|
[532] | 161 | switch ($item_type) { |
---|
| 162 | case 'home': |
---|
| 163 | $item_label = __('Home'); |
---|
| 164 | $item_descr = __('Recent posts'); |
---|
| 165 | break; |
---|
| 166 | case 'lang': |
---|
| 167 | $item_select_label = array_search($item_select,$langs_combo); |
---|
| 168 | $item_label = $item_select_label; |
---|
| 169 | $item_descr = sprintf(__('Switch to %s language'),$item_select_label); |
---|
[776] | 170 | $item_url .= $core->url->getURLFor('lang',$item_select); |
---|
[532] | 171 | break; |
---|
| 172 | case 'category': |
---|
| 173 | $item_select_label = $categories_label[$item_select]; |
---|
| 174 | $item_label = $item_select_label; |
---|
| 175 | $item_descr = __('Recent Posts from this category'); |
---|
[776] | 176 | $item_url .= $core->url->getURLFor('category',$item_select); |
---|
[532] | 177 | break; |
---|
| 178 | case 'archive': |
---|
| 179 | $item_select_label = array_search($item_select,$months_combo); |
---|
| 180 | if ($item_select == '-') { |
---|
| 181 | $item_label = __('Archives'); |
---|
| 182 | $item_descr = $first_year.($first_year != $last_year ? ' - '.$last_year : ''); |
---|
[776] | 183 | $item_url .= $core->url->getURLFor('archive'); |
---|
[532] | 184 | } else { |
---|
| 185 | $item_label = $item_select_label; |
---|
| 186 | $item_descr = sprintf(__('Posts from %s'),$item_select_label); |
---|
[776] | 187 | $item_url .= $core->url->getURLFor('archive',substr($item_select,0,4).'/'.substr($item_select,-2)); |
---|
[532] | 188 | } |
---|
| 189 | break; |
---|
| 190 | case 'pages': |
---|
| 191 | $item_select_label = array_search($item_select,$pages_combo); |
---|
| 192 | $item_label = $item_select_label; |
---|
| 193 | $item_descr = ''; |
---|
| 194 | $item_url = html::stripHostURL($item_select); |
---|
| 195 | break; |
---|
| 196 | case 'tags': |
---|
| 197 | $item_select_label = array_search($item_select,$tags_combo); |
---|
| 198 | if ($item_select == '-') { |
---|
| 199 | $item_label = __('All tags'); |
---|
| 200 | $item_descr = ''; |
---|
[776] | 201 | $item_url .= $core->url->getURLFor('tags'); |
---|
[532] | 202 | } else { |
---|
| 203 | $item_label = $item_select_label; |
---|
| 204 | $item_descr = sprintf(__('Recent posts for %s tag'),$item_select_label); |
---|
[776] | 205 | $item_url .= $core->url->getURLFor('tag',$item_select); |
---|
[532] | 206 | } |
---|
| 207 | break; |
---|
| 208 | case 'special': |
---|
| 209 | break; |
---|
[556] | 210 | default: |
---|
| 211 | # --BEHAVIOR-- adminSimpleMenuBeforeEdit |
---|
| 212 | # Should modify if necessary $item_label, $item_descr and $item_url |
---|
| 213 | # Should set if necessary $item_select_label (displayed on further admin step only) |
---|
| 214 | $core->callBehavior('adminSimpleMenuBeforeEdit',$item_type,$item_select, |
---|
[598] | 215 | array(&$item_label,&$item_descr,&$item_url,&$item_select_label)); |
---|
[556] | 216 | break; |
---|
[532] | 217 | } |
---|
| 218 | break; |
---|
[534] | 219 | case 4: |
---|
| 220 | // Fourth step, menu item to be added |
---|
| 221 | try { |
---|
[538] | 222 | if (($item_label != '') && ($item_url != '')) |
---|
[534] | 223 | { |
---|
| 224 | // Add new item menu in menu array |
---|
| 225 | $menu[] = array( |
---|
| 226 | 'label' => $item_label, |
---|
| 227 | 'descr' => $item_descr, |
---|
| 228 | 'url' => $item_url |
---|
| 229 | ); |
---|
| 230 | // Save menu in blog settings |
---|
| 231 | $core->blog->settings->system->put('simpleMenu',serialize($menu)); |
---|
[571] | 232 | $core->blog->triggerBlog(); |
---|
[534] | 233 | |
---|
| 234 | // All done successfully, return to menu items list |
---|
| 235 | http::redirect($p_url.'&added=1'); |
---|
| 236 | } else { |
---|
| 237 | throw new Exception(__('Label and URL of menu item are mandatory.')); |
---|
| 238 | } |
---|
| 239 | } |
---|
| 240 | catch (Exception $e) { |
---|
| 241 | $core->error->add($e->getMessage()); |
---|
| 242 | } |
---|
| 243 | break; |
---|
[532] | 244 | } |
---|
[538] | 245 | } else { |
---|
[539] | 246 | |
---|
| 247 | # Remove selected menu items |
---|
[538] | 248 | if (!empty($_POST['removeaction'])) |
---|
| 249 | { |
---|
| 250 | try { |
---|
| 251 | if (!empty($_POST['items_selected'])) { |
---|
| 252 | foreach ($_POST['items_selected'] as $k => $v) { |
---|
[539] | 253 | $menu[$v]['label'] = ''; |
---|
[538] | 254 | } |
---|
| 255 | $newmenu = array(); |
---|
| 256 | foreach ($menu as $k => $v) { |
---|
| 257 | if ($v['label']) { |
---|
| 258 | $newmenu[] = array( |
---|
| 259 | 'label' => $v['label'], |
---|
| 260 | 'descr' => $v['descr'], |
---|
| 261 | 'url' => $v['url']); |
---|
| 262 | } |
---|
| 263 | } |
---|
| 264 | $menu = $newmenu; |
---|
| 265 | // Save menu in blog settings |
---|
| 266 | $core->blog->settings->system->put('simpleMenu',serialize($menu)); |
---|
[571] | 267 | $core->blog->triggerBlog(); |
---|
[538] | 268 | |
---|
| 269 | // All done successfully, return to menu items list |
---|
| 270 | http::redirect($p_url.'&removed=1'); |
---|
| 271 | } else { |
---|
| 272 | throw new Exception(__('No menu items selected.')); |
---|
| 273 | } |
---|
| 274 | } |
---|
| 275 | catch (Exception $e) { |
---|
| 276 | $core->error->add($e->getMessage()); |
---|
| 277 | } |
---|
| 278 | } |
---|
[539] | 279 | |
---|
| 280 | # Update menu items |
---|
[538] | 281 | if (!empty($_POST['updateaction'])) |
---|
| 282 | { |
---|
| 283 | try { |
---|
| 284 | foreach ($_POST['items_label'] as $k => $v) { |
---|
| 285 | if (!$v) throw new Exception(__('Label is mandatory.')); |
---|
| 286 | } |
---|
| 287 | foreach ($_POST['items_url'] as $k => $v) { |
---|
| 288 | if (!$v) throw new Exception(__('URL is mandatory.')); |
---|
| 289 | } |
---|
| 290 | $newmenu = array(); |
---|
| 291 | for ($i = 0; $i < count($_POST['items_label']); $i++) |
---|
| 292 | { |
---|
| 293 | $newmenu[] = array( |
---|
| 294 | 'label' => $_POST['items_label'][$i], |
---|
| 295 | 'descr' => $_POST['items_descr'][$i], |
---|
| 296 | 'url' => $_POST['items_url'][$i]); |
---|
| 297 | } |
---|
| 298 | $menu = $newmenu; |
---|
| 299 | // Save menu in blog settings |
---|
| 300 | $core->blog->settings->system->put('simpleMenu',serialize($menu)); |
---|
[571] | 301 | $core->blog->triggerBlog(); |
---|
[538] | 302 | |
---|
| 303 | // All done successfully, return to menu items list |
---|
| 304 | http::redirect($p_url.'&updated=1'); |
---|
| 305 | } |
---|
| 306 | catch (Exception $e) { |
---|
| 307 | $core->error->add($e->getMessage()); |
---|
| 308 | } |
---|
| 309 | } |
---|
| 310 | |
---|
| 311 | # Order menu items |
---|
| 312 | $order = array(); |
---|
| 313 | if (empty($_POST['im_order']) && !empty($_POST['order'])) { |
---|
| 314 | $order = $_POST['order']; |
---|
| 315 | asort($order); |
---|
| 316 | $order = array_keys($order); |
---|
| 317 | } elseif (!empty($_POST['im_order'])) { |
---|
[540] | 318 | $order = $_POST['im_order']; |
---|
| 319 | if (substr($order,-1) == ',') { |
---|
| 320 | $order = substr($order,0,strlen($order)-1); |
---|
| 321 | } |
---|
| 322 | $order = explode(',',$order); |
---|
[538] | 323 | } |
---|
| 324 | |
---|
[546] | 325 | if (!empty($_POST['updateaction']) && !empty($order)) |
---|
[538] | 326 | { |
---|
| 327 | try { |
---|
| 328 | $newmenu = array(); |
---|
| 329 | foreach ($order as $i => $k) { |
---|
| 330 | $newmenu[] = array( |
---|
| 331 | 'label' => $menu[$k]['label'], |
---|
| 332 | 'descr' => $menu[$k]['descr'], |
---|
| 333 | 'url' => $menu[$k]['url']); |
---|
| 334 | } |
---|
| 335 | $menu = $newmenu; |
---|
| 336 | // Save menu in blog settings |
---|
| 337 | $core->blog->settings->system->put('simpleMenu',serialize($menu)); |
---|
[571] | 338 | $core->blog->triggerBlog(); |
---|
[538] | 339 | |
---|
| 340 | // All done successfully, return to menu items list |
---|
| 341 | http::redirect($p_url.'&neworder=1'); |
---|
| 342 | } |
---|
| 343 | catch (Exception $e) { |
---|
| 344 | $core->error->add($e->getMessage()); |
---|
| 345 | } |
---|
| 346 | } |
---|
| 347 | |
---|
[532] | 348 | } |
---|
| 349 | |
---|
| 350 | # Display |
---|
| 351 | ?> |
---|
| 352 | |
---|
| 353 | <html> |
---|
| 354 | <head> |
---|
[538] | 355 | <title><?php echo $page_title; ?></title> |
---|
[1132] | 356 | <?php |
---|
| 357 | $core->auth->user_prefs->addWorkspace('accessibility'); |
---|
| 358 | if (!$core->auth->user_prefs->accessibility->nodragdrop) { |
---|
| 359 | echo |
---|
| 360 | dcPage::jsLoad('js/jquery/jquery-ui.custom.js'). |
---|
| 361 | dcPage::jsLoad('index.php?pf=simpleMenu/simplemenu.js'); |
---|
| 362 | } |
---|
[538] | 363 | ?> |
---|
[532] | 364 | </head> |
---|
| 365 | |
---|
| 366 | <body> |
---|
| 367 | |
---|
| 368 | <?php |
---|
| 369 | |
---|
[534] | 370 | if (!empty($_GET['added'])) { |
---|
[907] | 371 | dcPage::message(__('Menu item has been successfully added.')); |
---|
[534] | 372 | } |
---|
| 373 | if (!empty($_GET['removed'])) { |
---|
[907] | 374 | dcPage::message(__('Menu items have been successfully removed.')); |
---|
[534] | 375 | } |
---|
| 376 | if (!empty($_GET['neworder'])) { |
---|
[907] | 377 | dcPage::message(__('Menu items have been successfully updated.')); |
---|
[534] | 378 | } |
---|
[538] | 379 | if (!empty($_GET['updated'])) { |
---|
[907] | 380 | dcPage::message(__('Menu items have been successfully updated.')); |
---|
[538] | 381 | } |
---|
[534] | 382 | |
---|
[532] | 383 | if ($step) |
---|
| 384 | { |
---|
| 385 | // Formulaire d'ajout d'un item |
---|
| 386 | echo '<h2>'.html::escapeHTML($core->blog->name).' › <a href="'.$p_url.'">'.$page_title.'</a> › <span class="page-title">'.__('Add item').'</span></h2>'; |
---|
| 387 | |
---|
| 388 | switch ($step) { |
---|
| 389 | case 1: |
---|
| 390 | // Selection du type d'item |
---|
[1280] | 391 | echo '<form id="additem" action="'.$p_url.'&add=2" method="post">'; |
---|
[532] | 392 | echo '<fieldset><legend>'.__('Select type').'</legend>'; |
---|
[1008] | 393 | echo '<p class="field"><label for="item_type" class="classic">'.__('Type of item menu:').'</label>'.form::combo('item_type',$items_combo,'').'</p>'; |
---|
[751] | 394 | echo '<p>'.$core->formNonce().'<input type="submit" name="appendaction" value="'.__('Continue...').'" />'.'</p>'; |
---|
[532] | 395 | echo '</fieldset>'; |
---|
| 396 | echo '</form>'; |
---|
| 397 | break; |
---|
| 398 | case 2: |
---|
[556] | 399 | if ($items[$item_type][1]) { |
---|
[532] | 400 | // Choix à faire |
---|
[1280] | 401 | echo '<form id="additem" action="'.$p_url.'&add=3" method="post">'; |
---|
[532] | 402 | echo '<fieldset><legend>'.$item_type_label.'</legend>'; |
---|
| 403 | switch ($item_type) { |
---|
| 404 | case 'lang': |
---|
[1008] | 405 | echo '<p class="field"><label for="item_select" class="classic">'.__('Select language:').'</label>'. |
---|
[532] | 406 | form::combo('item_select',$langs_combo,''); |
---|
| 407 | break; |
---|
| 408 | case 'category': |
---|
[1008] | 409 | echo '<p class="field"><label for="item_select" class="classic">'.__('Select category:').'</label>'. |
---|
[532] | 410 | form::combo('item_select',$categories_combo,''); |
---|
| 411 | break; |
---|
| 412 | case 'archive': |
---|
[1008] | 413 | echo '<p class="field"><label for="item_select" class="classic">'.__('Select month (if necessary):').'</label>'. |
---|
[532] | 414 | form::combo('item_select',$months_combo,''); |
---|
| 415 | break; |
---|
| 416 | case 'pages': |
---|
[1008] | 417 | echo '<p class="field"><label for="item_select" class="classic">'.__('Select page:').'</label>'. |
---|
[532] | 418 | form::combo('item_select',$pages_combo,''); |
---|
| 419 | break; |
---|
| 420 | case 'tags': |
---|
[1008] | 421 | echo '<p class="field"><label for="item_select" class="classic">'.__('Select tag (if necessary):').'</label>'. |
---|
[532] | 422 | form::combo('item_select',$tags_combo,''); |
---|
| 423 | break; |
---|
[556] | 424 | default: |
---|
| 425 | echo |
---|
| 426 | # --BEHAVIOR-- adminSimpleMenuSelect |
---|
| 427 | # Optional step once $item_type known : should provide a field using 'item_select' as id |
---|
| 428 | $core->callBehavior('adminSimpleMenuSelect',$item_type,'item_select'); |
---|
[532] | 429 | } |
---|
| 430 | echo form::hidden('item_type',$item_type); |
---|
[751] | 431 | echo '<p>'.$core->formNonce().'<input type="submit" name="appendaction" value="'.__('Continue...').'" /></p>'; |
---|
[532] | 432 | echo '</fieldset>'; |
---|
| 433 | echo '</form>'; |
---|
| 434 | break; |
---|
| 435 | } |
---|
| 436 | case 3: |
---|
| 437 | // Libellé et description |
---|
[1280] | 438 | echo '<form id="additem" action="'.$p_url.'&add=4" method="post">'; |
---|
[532] | 439 | echo '<fieldset><legend>'.$item_type_label.($item_select_label != '' ? ' ('.$item_select_label.')' : '').'</legend>'; |
---|
[1008] | 440 | echo '<p class="field"><label for="item_label" class="classic required"><abbr title="'.__('Required field').'">*</abbr> '. |
---|
[539] | 441 | __('Label of item menu:').'</label>'.form::field('item_label',20,255,$item_label).'</p>'; |
---|
[1008] | 442 | echo '<p class="field"><label for="item_descr" class="classic">'. |
---|
[539] | 443 | __('Description of item menu:').'</label>'.form::field('item_descr',30,255,$item_descr).'</p>'; |
---|
[1008] | 444 | echo '<p class="field"><label for="item_url" class="classic required"><abbr title="'.__('Required field').'">*</abbr> '. |
---|
[539] | 445 | __('URL of item menu:').'</label>'.form::field('item_url',40,255,$item_url).'</p>'; |
---|
[532] | 446 | echo form::hidden('item_type',$item_type).form::hidden('item_select',$item_select); |
---|
[545] | 447 | echo '<p>'.$core->formNonce().'<input type="submit" name="appendaction" value="'.__('Add this item').'" /></p>'; |
---|
[532] | 448 | echo '</fieldset>'; |
---|
| 449 | echo '</form>'; |
---|
| 450 | break; |
---|
| 451 | } |
---|
[538] | 452 | } |
---|
| 453 | |
---|
| 454 | // Liste des items |
---|
| 455 | if (!$step) { |
---|
| 456 | echo '<h2>'.html::escapeHTML($core->blog->name).' › <span class="page-title">'.$page_title.'</span></h2>'; |
---|
| 457 | } |
---|
[573] | 458 | |
---|
| 459 | if (!$step) { |
---|
[1280] | 460 | echo '<form id="menuitemsappend" action="'.$p_url.'&add=1" method="post">'; |
---|
[573] | 461 | echo '<p>'.$core->formNonce().'<input class="add" type="submit" name="appendaction" value="'.__('Add an item').'" /></p>'; |
---|
| 462 | echo '</form>'; |
---|
| 463 | } |
---|
| 464 | |
---|
[538] | 465 | if (count($menu)) { |
---|
| 466 | if (!$step) { |
---|
| 467 | echo '<form id="menuitems" action="'.$p_url.'" method="post">'; |
---|
| 468 | } |
---|
| 469 | // Entête table |
---|
| 470 | echo |
---|
[540] | 471 | '<table class="maximal dragable">'. |
---|
[538] | 472 | '<caption>'.__('Menu items list').'</caption>'. |
---|
| 473 | '<thead>'. |
---|
| 474 | '<tr>'; |
---|
| 475 | if (!$step) { |
---|
[546] | 476 | echo '<th scope="col"></th>'; |
---|
[538] | 477 | echo '<th scope="col"></th>'; |
---|
| 478 | } |
---|
| 479 | echo |
---|
| 480 | '<th scope="col">'.__('Label').'</th>'. |
---|
| 481 | '<th scope="col">'.__('Description').'</th>'. |
---|
| 482 | '<th scope="col">'.__('URL').'</th>'. |
---|
| 483 | '</tr>'. |
---|
| 484 | '</thead>'. |
---|
[540] | 485 | '<tbody id="menuitemslist">'; |
---|
[538] | 486 | $count = 0; |
---|
| 487 | foreach ($menu as $i => $m) { |
---|
[540] | 488 | echo '<tr class="line" id="l_'.$i.'">'; |
---|
[538] | 489 | if (!$step) { |
---|
| 490 | $count++; |
---|
[546] | 491 | echo '<td class="handle minimal">'.form::field(array('order['.$i.']'),2,3,$count,'position','',false,'title="'.sprintf(__('position of %s'),__($m['label'])).'"'). |
---|
| 492 | form::hidden(array('dynorder[]','dynorder-'.$i),$i).'</td>'; |
---|
[540] | 493 | echo '<td class="minimal">'.form::checkbox(array('items_selected[]','ims-'.$i),$i).'</td>'; |
---|
[539] | 494 | echo '<td class="nowrap" scope="row">'.form::field(array('items_label[]','iml-'.$i),20,255,__($m['label'])).'</td>'; |
---|
| 495 | echo '<td class="nowrap">'.form::field(array('items_descr[]','imd-'.$i),30,255,__($m['descr'])).'</td>'; |
---|
| 496 | echo '<td class="nowrap">'.form::field(array('items_url[]','imu-'.$i),40,255,$m['url']).'</td>'; |
---|
[538] | 497 | } else { |
---|
| 498 | echo '<td class="nowrap" scope="row">'.__($m['label']).'</td>'; |
---|
| 499 | echo '<td class="nowrap">'.__($m['descr']).'</td>'; |
---|
| 500 | echo '<td class="nowrap">'.$m['url'].'</td>'; |
---|
| 501 | } |
---|
| 502 | echo '</tr>'; |
---|
| 503 | } |
---|
| 504 | echo '</tbody>'. |
---|
| 505 | '</table>'; |
---|
| 506 | if (!$step) { |
---|
[540] | 507 | echo '<div class="two-cols">'; |
---|
| 508 | echo '<p class="col">'.form::hidden('im_order','').$core->formNonce(); |
---|
[546] | 509 | echo '<input type="submit" name="updateaction" value="'.__('Update menu').'" />'.'</p>'; |
---|
[540] | 510 | echo '<p class="col right">'.'<input type="submit" class="delete" name="removeaction" '. |
---|
[538] | 511 | 'value="'.__('Delete selected menu items').'" '. |
---|
| 512 | 'onclick="return window.confirm(\''.html::escapeJS(__('Are you sure you want to remove selected menu items?')).'\');" />'. |
---|
| 513 | '</p>'; |
---|
[540] | 514 | echo '</div>'; |
---|
[538] | 515 | echo '</form>'; |
---|
| 516 | } |
---|
[532] | 517 | } else { |
---|
[538] | 518 | echo |
---|
| 519 | '<p>'.__('Currently no menu items').'</p>'; |
---|
| 520 | } |
---|
[532] | 521 | |
---|
[553] | 522 | dcPage::helpBlock('simpleMenu'); |
---|
[532] | 523 | ?> |
---|
| 524 | |
---|
| 525 | </body> |
---|
| 526 | </html> |
---|