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