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