| 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 = 'plugin.php?p=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 paramètres postés | 
|---|
| 114 | $item_type = isset($_POST['item_type']) ? $_POST['item_type'] : ''; | 
|---|
| 115 | $item_select = isset($_POST['item_select']) ? $_POST['item_select'] : ''; | 
|---|
| 116 | $item_label = isset($_POST['item_label']) ? $_POST['item_label'] : ''; | 
|---|
| 117 | $item_descr = isset($_POST['item_descr']) ? $_POST['item_descr'] : ''; | 
|---|
| 118 | $item_url = isset($_POST['item_url']) ? $_POST['item_url'] : ''; | 
|---|
| 119 |  | 
|---|
| 120 | # Traitement | 
|---|
| 121 | $step = (!empty($_GET['add']) ? (integer) $_GET['add'] : 0); | 
|---|
| 122 | if (($step > 4) || ($step < 0)) $step = 0; | 
|---|
| 123 | if ($step) { | 
|---|
| 124 |  | 
|---|
| 125 |      # Récupération libellés des choix | 
|---|
| 126 |      $item_type_label = isset($items[$item_type]) ? $items[$item_type][0] : ''; | 
|---|
| 127 |  | 
|---|
| 128 |      switch ($step) { | 
|---|
| 129 |           case 1: | 
|---|
| 130 |                // First step, menu item type to be selected | 
|---|
| 131 |                $item_type = $item_select = ''; | 
|---|
| 132 |                break; | 
|---|
| 133 |           case 2: | 
|---|
| 134 |                if ($items[$item_type][1]) { | 
|---|
| 135 |                     // Second step (optional), menu item sub-type to be selected | 
|---|
| 136 |                     $item_select = ''; | 
|---|
| 137 |                     break; | 
|---|
| 138 |                } | 
|---|
| 139 |           case 3: | 
|---|
| 140 |                // Third step, menu item attributes to be changed or completed if necessary | 
|---|
| 141 |                $item_select_label = ''; | 
|---|
| 142 |                $item_label = __('Label'); | 
|---|
| 143 |                $item_descr = __('Description'); | 
|---|
| 144 |                $item_url = $blog_url; | 
|---|
| 145 |                switch ($item_type) { | 
|---|
| 146 |                     case 'home': | 
|---|
| 147 |                          $item_label = __('Home'); | 
|---|
| 148 |                          $item_descr = __('Recent posts'); | 
|---|
| 149 |                          break; | 
|---|
| 150 |                     case 'lang': | 
|---|
| 151 |                          $item_select_label = array_search($item_select,$langs_combo); | 
|---|
| 152 |                          $item_label = $item_select_label; | 
|---|
| 153 |                          $item_descr = sprintf(__('Switch to %s language'),$item_select_label); | 
|---|
| 154 |                          $item_url .= $core->url->getURLFor('lang',$item_select); | 
|---|
| 155 |                          break; | 
|---|
| 156 |                     case 'category': | 
|---|
| 157 |                          $item_select_label = $categories_label[$item_select]; | 
|---|
| 158 |                          $item_label = $item_select_label; | 
|---|
| 159 |                          $item_descr = __('Recent Posts from this category'); | 
|---|
| 160 |                          $item_url .= $core->url->getURLFor('category',$item_select); | 
|---|
| 161 |                          break; | 
|---|
| 162 |                     case 'archive': | 
|---|
| 163 |                          $item_select_label = array_search($item_select,$months_combo); | 
|---|
| 164 |                          if ($item_select == '-') { | 
|---|
| 165 |                               $item_label = __('Archives'); | 
|---|
| 166 |                               $item_descr = $first_year.($first_year != $last_year ? ' - '.$last_year : ''); | 
|---|
| 167 |                               $item_url .= $core->url->getURLFor('archive'); | 
|---|
| 168 |                          } else { | 
|---|
| 169 |                               $item_label = $item_select_label; | 
|---|
| 170 |                               $item_descr = sprintf(__('Posts from %s'),$item_select_label); | 
|---|
| 171 |                               $item_url .= $core->url->getURLFor('archive',substr($item_select,0,4).'/'.substr($item_select,-2)); | 
|---|
| 172 |                          } | 
|---|
| 173 |                          break; | 
|---|
| 174 |                     case 'pages': | 
|---|
| 175 |                          $item_select_label = array_search($item_select,$pages_combo); | 
|---|
| 176 |                          $item_label = $item_select_label; | 
|---|
| 177 |                          $item_descr = ''; | 
|---|
| 178 |                          $item_url = html::stripHostURL($item_select); | 
|---|
| 179 |                          break; | 
|---|
| 180 |                     case 'tags': | 
|---|
| 181 |                          $item_select_label = array_search($item_select,$tags_combo); | 
|---|
| 182 |                          if ($item_select == '-') { | 
|---|
| 183 |                               $item_label = __('All tags'); | 
|---|
| 184 |                               $item_descr = ''; | 
|---|
| 185 |                               $item_url .= $core->url->getURLFor('tags'); | 
|---|
| 186 |                          } else { | 
|---|
| 187 |                               $item_label = $item_select_label; | 
|---|
| 188 |                               $item_descr = sprintf(__('Recent posts for %s tag'),$item_select_label); | 
|---|
| 189 |                               $item_url .= $core->url->getURLFor('tag',$item_select); | 
|---|
| 190 |                          } | 
|---|
| 191 |                          break; | 
|---|
| 192 |                     case 'special': | 
|---|
| 193 |                          break; | 
|---|
| 194 |                     default: | 
|---|
| 195 |                          # --BEHAVIOR-- adminSimpleMenuBeforeEdit | 
|---|
| 196 |                          # Should modify if necessary $item_label, $item_descr and $item_url | 
|---|
| 197 |                          # Should set if necessary $item_select_label (displayed on further admin step only) | 
|---|
| 198 |                          $core->callBehavior('adminSimpleMenuBeforeEdit',$item_type,$item_select, | 
|---|
| 199 |                               array(&$item_label,&$item_descr,&$item_url,&$item_select_label)); | 
|---|
| 200 |                          break; | 
|---|
| 201 |                } | 
|---|
| 202 |                break; | 
|---|
| 203 |           case 4: | 
|---|
| 204 |                // Fourth step, menu item to be added | 
|---|
| 205 |                try { | 
|---|
| 206 |                     if (($item_label != '') && ($item_url != ''))  | 
|---|
| 207 |                     { | 
|---|
| 208 |                          // Add new item menu in menu array | 
|---|
| 209 |                          $menu[] = array( | 
|---|
| 210 |                               'label' => $item_label, | 
|---|
| 211 |                               'descr' => $item_descr, | 
|---|
| 212 |                               'url' => $item_url | 
|---|
| 213 |                          ); | 
|---|
| 214 |                          // Save menu in blog settings | 
|---|
| 215 |                          $core->blog->settings->system->put('simpleMenu',serialize($menu)); | 
|---|
| 216 |                          $core->blog->triggerBlog(); | 
|---|
| 217 |                      | 
|---|
| 218 |                          // All done successfully, return to menu items list | 
|---|
| 219 |                          http::redirect($p_url.'&added=1'); | 
|---|
| 220 |                     } else { | 
|---|
| 221 |                          throw new Exception(__('Label and URL of menu item are mandatory.')); | 
|---|
| 222 |                     } | 
|---|
| 223 |                } | 
|---|
| 224 |                catch (Exception $e) { | 
|---|
| 225 |                     $core->error->add($e->getMessage()); | 
|---|
| 226 |                } | 
|---|
| 227 |                break; | 
|---|
| 228 |      } | 
|---|
| 229 | } else { | 
|---|
| 230 |       | 
|---|
| 231 |      # Remove selected menu items | 
|---|
| 232 |      if (!empty($_POST['removeaction'])) | 
|---|
| 233 |      { | 
|---|
| 234 |           try { | 
|---|
| 235 |                if (!empty($_POST['items_selected'])) { | 
|---|
| 236 |                     foreach ($_POST['items_selected'] as $k => $v) { | 
|---|
| 237 |                          $menu[$v]['label'] = ''; | 
|---|
| 238 |                     } | 
|---|
| 239 |                     $newmenu = array(); | 
|---|
| 240 |                     foreach ($menu as $k => $v) { | 
|---|
| 241 |                          if ($v['label']) { | 
|---|
| 242 |                               $newmenu[] = array( | 
|---|
| 243 |                                    'label' => $v['label'], | 
|---|
| 244 |                                    'descr' => $v['descr'], | 
|---|
| 245 |                                    'url' => $v['url']); | 
|---|
| 246 |                          } | 
|---|
| 247 |                     } | 
|---|
| 248 |                     $menu = $newmenu; | 
|---|
| 249 |                     // Save menu in blog settings | 
|---|
| 250 |                     $core->blog->settings->system->put('simpleMenu',serialize($menu)); | 
|---|
| 251 |                     $core->blog->triggerBlog(); | 
|---|
| 252 |                      | 
|---|
| 253 |                     // All done successfully, return to menu items list | 
|---|
| 254 |                     http::redirect($p_url.'&removed=1'); | 
|---|
| 255 |                } else { | 
|---|
| 256 |                     throw new Exception(__('No menu items selected.')); | 
|---|
| 257 |                } | 
|---|
| 258 |           } | 
|---|
| 259 |           catch (Exception $e) { | 
|---|
| 260 |                $core->error->add($e->getMessage()); | 
|---|
| 261 |           } | 
|---|
| 262 |      } | 
|---|
| 263 |  | 
|---|
| 264 |      # Update menu items | 
|---|
| 265 |      if (!empty($_POST['updateaction'])) | 
|---|
| 266 |      { | 
|---|
| 267 |           try { | 
|---|
| 268 |                foreach ($_POST['items_label'] as $k => $v) { | 
|---|
| 269 |                     if (!$v) throw new Exception(__('Label is mandatory.')); | 
|---|
| 270 |                } | 
|---|
| 271 |                foreach ($_POST['items_url'] as $k => $v) { | 
|---|
| 272 |                     if (!$v) throw new Exception(__('URL is mandatory.')); | 
|---|
| 273 |                } | 
|---|
| 274 |                $newmenu = array(); | 
|---|
| 275 |                for ($i = 0; $i < count($_POST['items_label']); $i++) | 
|---|
| 276 |                { | 
|---|
| 277 |                     $newmenu[] = array( | 
|---|
| 278 |                          'label' => $_POST['items_label'][$i], | 
|---|
| 279 |                          'descr' => $_POST['items_descr'][$i], | 
|---|
| 280 |                          'url' => $_POST['items_url'][$i]); | 
|---|
| 281 |                } | 
|---|
| 282 |                $menu = $newmenu; | 
|---|
| 283 |                // Save menu in blog settings | 
|---|
| 284 |                $core->blog->settings->system->put('simpleMenu',serialize($menu)); | 
|---|
| 285 |                $core->blog->triggerBlog(); | 
|---|
| 286 |  | 
|---|
| 287 |                // All done successfully, return to menu items list | 
|---|
| 288 |                http::redirect($p_url.'&updated=1'); | 
|---|
| 289 |           } | 
|---|
| 290 |           catch (Exception $e) { | 
|---|
| 291 |                $core->error->add($e->getMessage()); | 
|---|
| 292 |           } | 
|---|
| 293 |      } | 
|---|
| 294 |       | 
|---|
| 295 |      # Order menu items | 
|---|
| 296 |      $order = array(); | 
|---|
| 297 |      if (empty($_POST['im_order']) && !empty($_POST['order'])) { | 
|---|
| 298 |           $order = $_POST['order']; | 
|---|
| 299 |           asort($order); | 
|---|
| 300 |           $order = array_keys($order); | 
|---|
| 301 |      } elseif (!empty($_POST['im_order'])) { | 
|---|
| 302 |           $order = $_POST['im_order']; | 
|---|
| 303 |           if (substr($order,-1) == ',') { | 
|---|
| 304 |                $order = substr($order,0,strlen($order)-1); | 
|---|
| 305 |           } | 
|---|
| 306 |           $order = explode(',',$order); | 
|---|
| 307 |      } | 
|---|
| 308 |  | 
|---|
| 309 |      if (!empty($_POST['updateaction']) && !empty($order)) | 
|---|
| 310 |      { | 
|---|
| 311 |           try { | 
|---|
| 312 |                $newmenu = array(); | 
|---|
| 313 |                foreach ($order as $i => $k) { | 
|---|
| 314 |                     $newmenu[] = array( | 
|---|
| 315 |                          'label' => $menu[$k]['label'], | 
|---|
| 316 |                          'descr' => $menu[$k]['descr'], | 
|---|
| 317 |                          'url' => $menu[$k]['url']); | 
|---|
| 318 |                } | 
|---|
| 319 |                $menu = $newmenu; | 
|---|
| 320 |                // Save menu in blog settings | 
|---|
| 321 |                $core->blog->settings->system->put('simpleMenu',serialize($menu)); | 
|---|
| 322 |                $core->blog->triggerBlog(); | 
|---|
| 323 |  | 
|---|
| 324 |                // All done successfully, return to menu items list | 
|---|
| 325 |                http::redirect($p_url.'&neworder=1'); | 
|---|
| 326 |           }  | 
|---|
| 327 |           catch (Exception $e) { | 
|---|
| 328 |                $core->error->add($e->getMessage()); | 
|---|
| 329 |           } | 
|---|
| 330 |      } | 
|---|
| 331 |       | 
|---|
| 332 | } | 
|---|
| 333 |  | 
|---|
| 334 | # Display | 
|---|
| 335 | ?> | 
|---|
| 336 |  | 
|---|
| 337 | <html> | 
|---|
| 338 | <head> | 
|---|
| 339 |      <title><?php echo $page_title; ?></title> | 
|---|
| 340 |      <?php  | 
|---|
| 341 |           $core->auth->user_prefs->addWorkspace('accessibility'); | 
|---|
| 342 |           if (!$core->auth->user_prefs->accessibility->nodragdrop) { | 
|---|
| 343 |                echo | 
|---|
| 344 |                     dcPage::jsLoad('js/jquery/jquery-ui.custom.js'). | 
|---|
| 345 |                     dcPage::jsLoad('index.php?pf=simpleMenu/simplemenu.js'); | 
|---|
| 346 |           } | 
|---|
| 347 |      ?> | 
|---|
| 348 | </head> | 
|---|
| 349 |  | 
|---|
| 350 | <body> | 
|---|
| 351 |  | 
|---|
| 352 | <?php | 
|---|
| 353 |  | 
|---|
| 354 | if ($step) { | 
|---|
| 355 |      switch ($step) { | 
|---|
| 356 |           case 1: | 
|---|
| 357 |                $step_label = __('Step #1'); | 
|---|
| 358 |                break; | 
|---|
| 359 |           case 2: | 
|---|
| 360 |                if ($items[$item_type][1]) { | 
|---|
| 361 |                     $step_label = __('Step #2'); | 
|---|
| 362 |                     break; | 
|---|
| 363 |                } | 
|---|
| 364 |           case 3: | 
|---|
| 365 |                if ($items[$item_type][1]) { | 
|---|
| 366 |                     $step_label = __('Step #3'); | 
|---|
| 367 |                } else { | 
|---|
| 368 |                     $step_label = __('Step #2'); | 
|---|
| 369 |                } | 
|---|
| 370 |                break; | 
|---|
| 371 |      } | 
|---|
| 372 |      echo dcPage::breadcrumb( | 
|---|
| 373 |           array( | 
|---|
| 374 |                html::escapeHTML($core->blog->name) => '', | 
|---|
| 375 |                $page_title => $p_url, | 
|---|
| 376 |                __('Add item') => '', | 
|---|
| 377 |                $step_label => '' | 
|---|
| 378 |           ), | 
|---|
| 379 |           array( | 
|---|
| 380 |                'hl_pos' => -2) | 
|---|
| 381 |      ); | 
|---|
| 382 | } else { | 
|---|
| 383 |      echo dcPage::breadcrumb( | 
|---|
| 384 |           array( | 
|---|
| 385 |                html::escapeHTML($core->blog->name) => '', | 
|---|
| 386 |                $page_title => '' | 
|---|
| 387 |           )); | 
|---|
| 388 | } | 
|---|
| 389 |  | 
|---|
| 390 | if (!empty($_GET['added'])) { | 
|---|
| 391 |      dcPage::success(__('Menu item has been successfully added.')); | 
|---|
| 392 | } | 
|---|
| 393 | if (!empty($_GET['removed'])) { | 
|---|
| 394 |      dcPage::success(__('Menu items have been successfully removed.')); | 
|---|
| 395 | } | 
|---|
| 396 | if (!empty($_GET['neworder'])) { | 
|---|
| 397 |      dcPage::success(__('Menu items have been successfully updated.')); | 
|---|
| 398 | } | 
|---|
| 399 | if (!empty($_GET['updated'])) { | 
|---|
| 400 |      dcPage::success(__('Menu items have been successfully updated.')); | 
|---|
| 401 | } | 
|---|
| 402 | if ($step) | 
|---|
| 403 | { | 
|---|
| 404 |      // Formulaire d'ajout d'un item | 
|---|
| 405 |      switch ($step) { | 
|---|
| 406 |           case 1: | 
|---|
| 407 |                // Selection du type d'item | 
|---|
| 408 |                echo '<form id="additem" action="'.$p_url.'&add=2" method="post">'; | 
|---|
| 409 |                echo '<fieldset><legend>'.__('Select type').'</legend>'; | 
|---|
| 410 |                echo '<p class="field"><label for="item_type" class="classic">'.__('Type of item menu:').'</label>'.form::combo('item_type',$items_combo,'').'</p>'; | 
|---|
| 411 |                echo '<p>'.$core->formNonce().'<input type="submit" name="appendaction" value="'.__('Continue...').'" />'.'</p>'; | 
|---|
| 412 |                echo '</fieldset>'; | 
|---|
| 413 |                echo '</form>'; | 
|---|
| 414 |                break; | 
|---|
| 415 |           case 2: | 
|---|
| 416 |                if ($items[$item_type][1]) { | 
|---|
| 417 |                     // Choix à faire | 
|---|
| 418 |                     echo '<form id="additem" action="'.$p_url.'&add=3" method="post">'; | 
|---|
| 419 |                     echo '<fieldset><legend>'.$item_type_label.'</legend>'; | 
|---|
| 420 |                     switch ($item_type) { | 
|---|
| 421 |                          case 'lang': | 
|---|
| 422 |                               echo '<p class="field"><label for="item_select" class="classic">'.__('Select language:').'</label>'. | 
|---|
| 423 |                                    form::combo('item_select',$langs_combo,''); | 
|---|
| 424 |                               break; | 
|---|
| 425 |                          case 'category': | 
|---|
| 426 |                               echo '<p class="field"><label for="item_select" class="classic">'.__('Select category:').'</label>'. | 
|---|
| 427 |                                    form::combo('item_select',$categories_combo,''); | 
|---|
| 428 |                               break; | 
|---|
| 429 |                          case 'archive': | 
|---|
| 430 |                               echo '<p class="field"><label for="item_select" class="classic">'.__('Select month (if necessary):').'</label>'. | 
|---|
| 431 |                                    form::combo('item_select',$months_combo,''); | 
|---|
| 432 |                               break; | 
|---|
| 433 |                          case 'pages': | 
|---|
| 434 |                               echo '<p class="field"><label for="item_select" class="classic">'.__('Select page:').'</label>'. | 
|---|
| 435 |                                    form::combo('item_select',$pages_combo,''); | 
|---|
| 436 |                               break; | 
|---|
| 437 |                          case 'tags': | 
|---|
| 438 |                               echo '<p class="field"><label for="item_select" class="classic">'.__('Select tag (if necessary):').'</label>'. | 
|---|
| 439 |                                    form::combo('item_select',$tags_combo,''); | 
|---|
| 440 |                               break; | 
|---|
| 441 |                          default: | 
|---|
| 442 |                               echo | 
|---|
| 443 |                                    # --BEHAVIOR-- adminSimpleMenuSelect | 
|---|
| 444 |                                    # Optional step once $item_type known : should provide a field using 'item_select' as id | 
|---|
| 445 |                                    $core->callBehavior('adminSimpleMenuSelect',$item_type,'item_select'); | 
|---|
| 446 |                     } | 
|---|
| 447 |                     echo form::hidden('item_type',$item_type); | 
|---|
| 448 |                     echo '<p>'.$core->formNonce().'<input type="submit" name="appendaction" value="'.__('Continue...').'" /></p>'; | 
|---|
| 449 |                     echo '</fieldset>'; | 
|---|
| 450 |                     echo '</form>'; | 
|---|
| 451 |                     break; | 
|---|
| 452 |                } | 
|---|
| 453 |           case 3: | 
|---|
| 454 |                // Libellé et description | 
|---|
| 455 |                echo '<form id="additem" action="'.$p_url.'&add=4" method="post">'; | 
|---|
| 456 |                echo '<fieldset><legend>'.$item_type_label.($item_select_label != '' ? ' ('.$item_select_label.')' : '').'</legend>'; | 
|---|
| 457 |                echo '<p class="field"><label for="item_label" class="classic required"><abbr title="'.__('Required field').'">*</abbr> '. | 
|---|
| 458 |                     __('Label of item menu:').'</label>'.form::field('item_label',20,255,$item_label).'</p>'; | 
|---|
| 459 |                echo '<p class="field"><label for="item_descr" class="classic">'. | 
|---|
| 460 |                     __('Description of item menu:').'</label>'.form::field('item_descr',30,255,$item_descr).'</p>'; | 
|---|
| 461 |                echo '<p class="field"><label for="item_url" class="classic required"><abbr title="'.__('Required field').'">*</abbr> '. | 
|---|
| 462 |                     __('URL of item menu:').'</label>'.form::field('item_url',40,255,$item_url).'</p>'; | 
|---|
| 463 |                echo form::hidden('item_type',$item_type).form::hidden('item_select',$item_select); | 
|---|
| 464 |                echo '<p>'.$core->formNonce().'<input type="submit" name="appendaction" value="'.__('Add this item').'" /></p>'; | 
|---|
| 465 |                echo '</fieldset>'; | 
|---|
| 466 |                echo '</form>'; | 
|---|
| 467 |                break; | 
|---|
| 468 |      } | 
|---|
| 469 | } | 
|---|
| 470 |  | 
|---|
| 471 | // Liste des items | 
|---|
| 472 | if (!$step) { | 
|---|
| 473 |      echo '<form id="menuitemsappend" action="'.$p_url.'&add=1" method="post">'; | 
|---|
| 474 |      echo '<p class="top-add">'.$core->formNonce().'<input class="button add" type="submit" name="appendaction" value="'.__('Add an item').'" /></p>'; | 
|---|
| 475 |      echo '</form>'; | 
|---|
| 476 | } | 
|---|
| 477 |  | 
|---|
| 478 | if (count($menu)) { | 
|---|
| 479 |      if (!$step) { | 
|---|
| 480 |           echo '<form id="menuitems" action="'.$p_url.'" method="post">'; | 
|---|
| 481 |      } | 
|---|
| 482 |      // Entête table | 
|---|
| 483 |      echo  | 
|---|
| 484 |           '<div class="table-outer">'. | 
|---|
| 485 |           '<table class="dragable">'. | 
|---|
| 486 |           '<caption>'.__('Menu items list').'</caption>'. | 
|---|
| 487 |           '<thead>'. | 
|---|
| 488 |           '<tr>'; | 
|---|
| 489 |      if (!$step) { | 
|---|
| 490 |           echo '<th scope="col"></th>'; | 
|---|
| 491 |           echo '<th scope="col"></th>'; | 
|---|
| 492 |      } | 
|---|
| 493 |      echo | 
|---|
| 494 |           '<th scope="col">'.__('Label').'</th>'. | 
|---|
| 495 |           '<th scope="col">'.__('Description').'</th>'. | 
|---|
| 496 |           '<th scope="col">'.__('URL').'</th>'. | 
|---|
| 497 |           '</tr>'. | 
|---|
| 498 |           '</thead>'. | 
|---|
| 499 |           '<tbody '.(!$step ? 'id="menuitemslist"' : '>'); | 
|---|
| 500 |      $count = 0; | 
|---|
| 501 |      foreach ($menu as $i => $m) { | 
|---|
| 502 |           echo '<tr class="line" id="l_'.$i.'">'; | 
|---|
| 503 |           if (!$step) { | 
|---|
| 504 |                $count++; | 
|---|
| 505 |                echo '<td class="handle minimal">'.form::field(array('order['.$i.']'),2,3,$count,'position','',false,'title="'.sprintf(__('position of %s'),__($m['label'])).'"'). | 
|---|
| 506 |                     form::hidden(array('dynorder[]','dynorder-'.$i),$i).'</td>'; | 
|---|
| 507 |                echo '<td class="minimal">'.form::checkbox(array('items_selected[]','ims-'.$i),$i).'</td>'; | 
|---|
| 508 |                echo '<td class="nowrap" scope="row">'.form::field(array('items_label[]','iml-'.$i),'',255,__($m['label'])).'</td>'; | 
|---|
| 509 |                echo '<td class="nowrap">'.form::field(array('items_descr[]','imd-'.$i),'30',255,__($m['descr'])).'</td>'; | 
|---|
| 510 |                echo '<td class="nowrap">'.form::field(array('items_url[]','imu-'.$i),'30',255,$m['url']).'</td>'; | 
|---|
| 511 |           } else { | 
|---|
| 512 |                echo '<td class="nowrap" scope="row">'.__($m['label']).'</td>'; | 
|---|
| 513 |                echo '<td class="nowrap">'.__($m['descr']).'</td>'; | 
|---|
| 514 |                echo '<td class="nowrap">'.$m['url'].'</td>'; | 
|---|
| 515 |           } | 
|---|
| 516 |           echo '</tr>'; | 
|---|
| 517 |      } | 
|---|
| 518 |      echo '</tbody>'. | 
|---|
| 519 |           '</table></div>'; | 
|---|
| 520 |      if (!$step) { | 
|---|
| 521 |           echo '<div class="two-cols">'; | 
|---|
| 522 |           echo '<p class="col">'.form::hidden('im_order','').$core->formNonce(); | 
|---|
| 523 |           echo '<input type="submit" name="updateaction" value="'.__('Update menu').'" />'.'</p>'; | 
|---|
| 524 |           echo '<p class="col right">'.'<input type="submit" class="delete" name="removeaction" '. | 
|---|
| 525 |                     'value="'.__('Delete selected menu items').'" '. | 
|---|
| 526 |                     'onclick="return window.confirm(\''.html::escapeJS(__('Are you sure you want to remove selected menu items?')).'\');" />'. | 
|---|
| 527 |                '</p>'; | 
|---|
| 528 |           echo '</div>'; | 
|---|
| 529 |           echo '</form>'; | 
|---|
| 530 |      } | 
|---|
| 531 | } else { | 
|---|
| 532 |      echo | 
|---|
| 533 |           '<p>'.__('No menu items so far.').'</p>'; | 
|---|
| 534 | } | 
|---|
| 535 |  | 
|---|
| 536 | dcPage::helpBlock('simpleMenu'); | 
|---|
| 537 | ?> | 
|---|
| 538 |  | 
|---|
| 539 | </body> | 
|---|
| 540 | </html> | 
|---|