Changeset 3874:ab8368569446 for plugins/simpleMenu
- Timestamp:
- 09/14/18 12:16:17 (7 years ago)
- Branch:
- default
- Location:
- plugins/simpleMenu
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/simpleMenu/_admin.php
r3731 r3874 16 16 function simpleMenu_dashboard($core, $icons) 17 17 { 18 $icons['simpleMenu'] = new ArrayObject( array(__('Simple menu'),18 $icons['simpleMenu'] = new ArrayObject([__('Simple menu'), 19 19 $core->adminurl->get('admin.plugin.simpleMenu'), 20 dcPage::getPF('simpleMenu/icon.png') ));20 dcPage::getPF('simpleMenu/icon.png')]); 21 21 } 22 22 function simpleMenu_dashboard_favs($core, $favs) 23 23 { 24 $favs->register('simpleMenu', array(24 $favs->register('simpleMenu', [ 25 25 'title' => __('Simple menu'), 26 26 'url' => $core->adminurl->get('admin.plugin.simpleMenu'), … … 28 28 'large-icon' => dcPage::getPF('simpleMenu/icon.png'), 29 29 'permissions' => 'usage,contentadmin' 30 ));30 ]); 31 31 } 32 32 -
plugins/simpleMenu/_define.php
r3731 r3874 17 17 "Franck Paul", // Author 18 18 '1.5', // Version 19 array(19 [ 20 20 'permissions' => 'admin', 21 21 'type' => 'plugin', 22 'settings' => array(22 'settings' => [ 23 23 'self' => '' 24 )25 )24 ] 25 ] 26 26 ); -
plugins/simpleMenu/_install.php
r3731 r3874 19 19 # Menu par défaut 20 20 $blog_url = html::stripHostURL($core->blog->url); 21 $menu_default = array(22 array('label' => 'Home', 'descr' => 'Recent posts', 'url' => $blog_url, 'targetBlank' => false),23 array('label' => 'Archives', 'descr' => '', 'url' => $blog_url . $core->url->getURLFor('archive'), 'targetBlank' => false)24 );21 $menu_default = [ 22 ['label' => 'Home', 'descr' => 'Recent posts', 'url' => $blog_url, 'targetBlank' => false], 23 ['label' => 'Archives', 'descr' => '', 'url' => $blog_url . $core->url->getURLFor('archive'), 'targetBlank' => false] 24 ]; 25 25 $core->blog->settings->system->put('simpleMenu', $menu_default, 'array', 'simpleMenu default menu', false, true); 26 26 $core->blog->settings->system->put('simpleMenu_active', true, 'boolean', 'Active', false, true); -
plugins/simpleMenu/_public.php
r3731 r3874 15 15 16 16 # Simple menu template functions 17 $core->tpl->addValue('SimpleMenu', array('tplSimpleMenu', 'simpleMenu'));17 $core->tpl->addValue('SimpleMenu', ['tplSimpleMenu', 'simpleMenu']); 18 18 19 19 class tplSimpleMenu … … 48 48 global $core, $_ctx; 49 49 50 $descr_type = array(0 => 'span', 1 => 'title', 2 => 'both', 3 => 'none');50 $descr_type = [0 => 'span', 1 => 'title', 2 => 'both', 3 => 'none']; 51 51 52 52 if (!(boolean) $core->blog->settings->system->simpleMenu_active) { … … 145 145 $label = html::escapeHTML(__($m['label'])); 146 146 147 $item = new ArrayObject( array(147 $item = new ArrayObject([ 148 148 'url' => $href, // URL 149 149 'label' => $label, // <a> link label … … 152 152 'active' => $active, // status (true/false) 153 153 'class' => '' // additional <li> class (optional) 154 ));154 ]); 155 155 156 156 # --BEHAVIOR-- publicSimpleMenuItem -
plugins/simpleMenu/_widgets.php
r3731 r3874 12 12 if (!defined('DC_RC_PATH')) {return;} 13 13 14 $core->addBehavior('initWidgets', array('simpleMenuWidgets', 'initWidgets'));14 $core->addBehavior('initWidgets', ['simpleMenuWidgets', 'initWidgets']); 15 15 16 16 class simpleMenuWidgets … … 18 18 public static function initWidgets($w) 19 19 { 20 $w->create('simplemenu', __('Simple menu'), array('tplSimpleMenu', 'simpleMenuWidget'), null, 'List of simple menu items');20 $w->create('simplemenu', __('Simple menu'), ['tplSimpleMenu', 'simpleMenuWidget'], null, 'List of simple menu items'); 21 21 $w->simplemenu->setting('title', __('Title (optional)') . ' :', __('Menu')); 22 22 $w->simplemenu->setting('description', __('Item description'), 0, 'combo', 23 array(23 [ 24 24 __('Displayed in link') => 0, // span 25 25 __('Used as link title') => 1, // title 26 26 __('Displayed in link and used as title') => 2, // both 27 27 __('Not displayed nor used') => 3 // none 28 )28 ] 29 29 ); 30 30 $w->simplemenu->setting('homeonly', __('Display on:'), 0, 'combo', 31 array(31 [ 32 32 __('All pages') => 0, 33 33 __('Home page only') => 1, 34 34 __('Except on home page') => 2 35 )35 ] 36 36 ); 37 37 $w->simplemenu->setting('content_only', __('Content only'), 0, 'check'); -
plugins/simpleMenu/index.php
r3731 r3874 23 23 24 24 # Liste des catégories 25 $categories_label = array();26 $rs = $core->blog->getCategories( array('post_type' => 'post'));25 $categories_label = []; 26 $rs = $core->blog->getCategories(['post_type' => 'post']); 27 27 $categories_combo = dcAdminCombos::getCategoriesCombo($rs, false, true); 28 28 $rs->moveStart(); … … 33 33 # Liste des langues utilisées 34 34 $langs_combo = dcAdminCombos::getLangscombo( 35 $core->blog->getLangs( array('order' => 'asc'))35 $core->blog->getLangs(['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(['type' => 'month']); 40 40 $months_combo = array_merge( 41 array(__('All months') => '-'),41 [__('All months') => '-'], 42 42 dcAdmincombos::getDatesCombo($rs) 43 43 ); … … 57 57 58 58 # Liste des pages -- Doit être pris en charge plus tard par le plugin ? 59 $pages_combo = array();59 $pages_combo = []; 60 60 try { 61 $rs = $core->blog->getPosts( array('post_type' => 'page'));61 $rs = $core->blog->getPosts(['post_type' => 'page']); 62 62 while ($rs->fetch()) { 63 63 $pages_combo[$rs->post_title] = $rs->getURL(); … … 67 67 68 68 # Liste des tags -- Doit être pris en charge plus tard par le plugin ? 69 $tags_combo = array();69 $tags_combo = []; 70 70 try { 71 $rs = $core->meta->getMetadata( array('meta_type' => 'tag'));71 $rs = $core->meta->getMetadata(['meta_type' => 'tag']); 72 72 $tags_combo[__('All tags')] = '-'; 73 73 while ($rs->fetch()) { … … 79 79 # Liste des types d'item de menu 80 80 $items = new ArrayObject(); 81 $items['home'] = new ArrayObject( array(__('Home'), false));81 $items['home'] = new ArrayObject([__('Home'), false]); 82 82 83 83 if (count($langs_combo) > 1) { 84 $items['lang'] = new ArrayObject( array(__('Language'), true));84 $items['lang'] = new ArrayObject([__('Language'), true]); 85 85 } 86 86 if (count($categories_combo)) { 87 $items['category'] = new ArrayObject( array(__('Category'), true));87 $items['category'] = new ArrayObject([__('Category'), true]); 88 88 } 89 89 if (count($months_combo) > 1) { 90 $items['archive'] = new ArrayObject( array(__('Archive'), true));90 $items['archive'] = new ArrayObject([__('Archive'), true]); 91 91 } 92 92 if ($core->plugins->moduleExists('pages')) { 93 93 if (count($pages_combo)) { 94 $items['pages'] = new ArrayObject( array(__('Page'), true));94 $items['pages'] = new ArrayObject([__('Page'), true]); 95 95 } 96 96 … … 98 98 if ($core->plugins->moduleExists('tags')) { 99 99 if (count($tags_combo) > 1) { 100 $items['tags'] = new ArrayObject( array(__('Tags'), true));100 $items['tags'] = new ArrayObject([__('Tags'), true]); 101 101 } 102 102 … … 104 104 105 105 # --BEHAVIOR-- adminSimpleMenuAddType 106 # Should add an item to $items[<id>] as an array(<label>,<optional step (true or false)>)106 # Should add an item to $items[<id>] as an [<label>,<optional step (true or false)>] 107 107 $core->callBehavior('adminSimpleMenuAddType', $items); 108 108 109 $items['special'] = new ArrayObject( array(__('User defined'), false));110 111 $items_combo = array();109 $items['special'] = new ArrayObject([__('User defined'), false]); 110 111 $items_combo = []; 112 112 foreach ($items as $k => $v) { 113 113 $items_combo[$v[0]] = $k; … … 117 117 $menu = $core->blog->settings->system->get('simpleMenu'); 118 118 if (!is_array($menu)) { 119 $menu = array();119 $menu = []; 120 120 } 121 121 … … 227 227 # Should set if necessary $item_select_label (displayed on further admin step only) 228 228 $core->callBehavior('adminSimpleMenuBeforeEdit', $item_type, $item_select, 229 array(&$item_label, &$item_descr, &$item_url, &$item_select_label));229 [&$item_label, &$item_descr, &$item_url, &$item_select_label]); 230 230 break; 231 231 } … … 236 236 if (($item_label != '') && ($item_url != '')) { 237 237 // Add new item menu in menu array 238 $menu[] = array(238 $menu[] = [ 239 239 'label' => $item_label, 240 240 'descr' => $item_descr, 241 241 'url' => $item_url, 242 242 'targetBlank' => $item_targetBlank 243 );243 ]; 244 244 245 245 // Save menu in blog settings … … 269 269 $menu[$v]['label'] = ''; 270 270 } 271 $newmenu = array();271 $newmenu = []; 272 272 foreach ($menu as $k => $v) { 273 273 if ($v['label']) { 274 $newmenu[] = array(274 $newmenu[] = [ 275 275 'label' => $v['label'], 276 276 'descr' => $v['descr'], 277 277 'url' => $v['url'], 278 278 'targetBlank' => $v['targetBlank'] 279 );279 ]; 280 280 } 281 281 } … … 311 311 312 312 } 313 $newmenu = array();313 $newmenu = []; 314 314 for ($i = 0; $i < count($_POST['items_label']); $i++) { 315 $newmenu[] = array(315 $newmenu[] = [ 316 316 'label' => $_POST['items_label'][$i], 317 317 'descr' => $_POST['items_descr'][$i], 318 318 'url' => $_POST['items_url'][$i], 319 319 'targetBlank' => (empty($_POST['items_targetBlank' . $i])) ? false : true 320 );320 ]; 321 321 } 322 322 $menu = $newmenu; … … 334 334 335 335 # Order menu items 336 $order = array();336 $order = []; 337 337 if (empty($_POST['im_order']) && !empty($_POST['order'])) { 338 338 $order = $_POST['order']; … … 349 349 if (!empty($_POST['updateaction']) && !empty($order)) { 350 350 try { 351 $newmenu = array();351 $newmenu = []; 352 352 foreach ($order as $i => $k) { 353 $newmenu[] = array(353 $newmenu[] = [ 354 354 'label' => $menu[$k]['label'], 355 355 'descr' => $menu[$k]['descr'], 356 'url' => $menu[$k]['url'] );356 'url' => $menu[$k]['url']]; 357 357 } 358 358 $menu = $newmenu; … … 413 413 } 414 414 echo dcPage::breadcrumb( 415 array(415 [ 416 416 html::escapeHTML($core->blog->name) => '', 417 417 $page_title => $p_url, 418 418 __('Add item') => '', 419 419 $step_label => '' 420 ),421 array(422 'hl_pos' => -2 )420 ], 421 [ 422 'hl_pos' => -2] 423 423 ) . 424 424 dcPage::notices(); 425 425 } else { 426 426 echo dcPage::breadcrumb( 427 array(427 [ 428 428 html::escapeHTML($core->blog->name) => '', 429 429 $page_title => '' 430 )) .430 ]) . 431 431 dcPage::notices(); 432 432 } … … 488 488 echo '<p class="field"><label for="item_label" class="classic required"><abbr title="' . __('Required field') . '">*</abbr> ' . 489 489 __('Label of item menu:') . '</label>' . 490 form::field('item_label', 20, 255, array(490 form::field('item_label', 20, 255, [ 491 491 'default' => $item_label, 492 492 'extra_html' => 'required placeholder="' . __('Label') . '"' 493 )) .493 ]) . 494 494 '</p>'; 495 495 echo '<p class="field"><label for="item_descr" class="classic">' . … … 497 497 echo '<p class="field"><label for="item_url" class="classic required"><abbr title="' . __('Required field') . '">*</abbr> ' . 498 498 __('URL of item menu:') . '</label>' . 499 form::field('item_url', 40, 255, array(499 form::field('item_url', 40, 255, [ 500 500 'default' => $item_url, 501 501 'extra_html' => 'required placeholder="' . __('URL') . '"' 502 )) .502 ]) . 503 503 '</p>'; 504 504 echo form::hidden('item_type', $item_type) . form::hidden('item_select', $item_select); … … 567 567 $count++; 568 568 echo '<td class="handle minimal">' . 569 form::number( array('order[' . $i . ']'), array(569 form::number(['order[' . $i . ']'], [ 570 570 'min' => 1, 571 571 'default' => $count, 572 572 'class' => 'position', 573 573 'extra_html' => 'title="' . sprintf(__('position of %s'), html::escapeHTML(__($m['label']))) . '"' 574 )) .575 form::hidden( array('dynorder[]', 'dynorder-' . $i), $i) . '</td>';576 echo '<td class="minimal">' . form::checkbox( array('items_selected[]', 'ims-' . $i), $i) . '</td>';577 echo '<td class="nowrap" scope="row">' . form::field( array('items_label[]', 'iml-' . $i), '', 255, html::escapeHTML(__($m['label']))) . '</td>';578 echo '<td class="nowrap">' . form::field( array('items_descr[]', 'imd-' . $i), '30', 255, html::escapeHTML(__($m['descr']))) . '</td>';579 echo '<td class="nowrap">' . form::field( array('items_url[]', 'imu-' . $i), '30', 255, html::escapeHTML($m['url'])) . '</td>';574 ]) . 575 form::hidden(['dynorder[]', 'dynorder-' . $i], $i) . '</td>'; 576 echo '<td class="minimal">' . form::checkbox(['items_selected[]', 'ims-' . $i], $i) . '</td>'; 577 echo '<td class="nowrap" scope="row">' . form::field(['items_label[]', 'iml-' . $i], '', 255, html::escapeHTML(__($m['label']))) . '</td>'; 578 echo '<td class="nowrap">' . form::field(['items_descr[]', 'imd-' . $i], '30', 255, html::escapeHTML(__($m['descr']))) . '</td>'; 579 echo '<td class="nowrap">' . form::field(['items_url[]', 'imu-' . $i], '30', 255, html::escapeHTML($m['url'])) . '</td>'; 580 580 echo '<td class="nowrap">' . form::checkbox('items_targetBlank' . $i, 'blank', $targetBlank) . '</td>'; 581 581 } else {
Note: See TracChangeset
for help on using the changeset viewer.