Changeset 2773:65aa733ce8a4
- Timestamp:
- 11/10/14 14:14:12 (11 years ago)
- Branch:
- default
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
locales/fr/plugins.po
r2663 r2773 112 112 msgstr "Liste de liens" 113 113 114 msgid "Enable simple menu for this blog" 115 msgstr "Acttiver le menu simple pour ce blog" 116 114 117 msgid "List of simple menu items" 115 118 msgstr "Liste des éléments de menu simple" -
plugins/simpleMenu/_define.php
r2662 r2773 16 16 /* Description*/ "Simple menu for Dotclear", 17 17 /* Author */ "Franck Paul", 18 /* Version */ '1. 2',18 /* Version */ '1.3', 19 19 array( 20 20 'permissions' => 'admin', -
plugins/simpleMenu/_install.php
r2566 r2773 24 24 ); 25 25 $core->blog->settings->system->put('simpleMenu',serialize($menu_default),'string','simpleMenu default menu',false,true); 26 $core->blog->settings->system->put('simpleMenu_active',true,'boolean','Active',false,true); 26 27 27 28 $core->setVersion('simpleMenu',$version); -
plugins/simpleMenu/_public.php
r2667 r2773 22 22 public static function simpleMenu($attr) 23 23 { 24 global $core; 25 26 if (!(boolean) $core->blog->settings->system->simpleMenu_active) 27 return ''; 28 24 29 $class = isset($attr['class']) ? trim($attr['class']) : ''; 25 30 $id = isset($attr['id']) ? trim($attr['id']) : ''; … … 42 47 global $core, $_ctx; 43 48 49 if (!(boolean) $core->blog->settings->system->simpleMenu_active) 50 return; 51 44 52 if (($w->homeonly == 1 && $core->url->type != 'default') || 45 53 ($w->homeonly == 2 && $core->url->type == 'default')) { … … 61 69 62 70 $ret = ''; 71 72 if (!(boolean) $core->blog->settings->system->simpleMenu_active) 73 return $ret; 63 74 64 75 $menu = $GLOBALS['core']->blog->settings->system->get('simpleMenu'); -
plugins/simpleMenu/index.php
r2701 r2773 111 111 } 112 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 = ''; 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 = ''; 137 152 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'); 153 case 2: 154 if ($items[$item_type][1]) { 155 // Second step (optional), menu item sub-type to be selected 156 $item_select = ''; 149 157 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'); 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); 168 241 } 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));242 $step = 3; 243 $item_select_label = $item_label; 244 dcPage::addErrorNotice(__('Label and URL of menu item are mandatory.')); 172 245 } 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); 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'] = ''; 190 261 } 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 ); 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; 214 272 // Save menu in blog settings 215 273 $core->blog->settings->system->put('simpleMenu',serialize($menu)); … … 217 275 218 276 // All done successfully, return to menu items list 219 dcPage::addSuccessNotice(__('Menu item has been successfully added.'));277 dcPage::addSuccessNotice(__('Menu items have been successfully removed.')); 220 278 http::redirect($p_url); 221 279 } else { 222 $step = 3; 223 $item_select_label = $item_label; 224 dcPage::addErrorNotice(__('Label and URL of menu item are mandatory.')); 280 throw new Exception(__('No menu items selected.')); 225 281 } 226 282 } … … 228 284 $core->error->add($e->getMessage()); 229 285 } 230 break;231 } 232 } else { 233 234 # Remove selected menu items235 if (!empty($_POST['removeaction']))236 {237 try {238 if (!empty($_POST['items_selected'])) {239 foreach ($_POST['items_ selected'] as $k => $v) {240 $menu[$v]['label'] = '';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.')); 241 297 } 242 298 $newmenu = array(); 243 foreach ($menu as $k => $v) { 244 if ($v['label']) { 245 $newmenu[] = array( 246 'label' => $v['label'], 247 'descr' => $v['descr'], 248 'url' => $v['url']); 249 } 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]); 250 305 } 251 306 $menu = $newmenu; … … 255 310 256 311 // All done successfully, return to menu items list 257 dcPage::addSuccessNotice(__('Menu items have been successfully removed.'));312 dcPage::addSuccessNotice(__('Menu items have been successfully updated.')); 258 313 http::redirect($p_url); 259 } else { 260 throw new Exception(__('No menu items selected.')); 261 } 262 } 263 catch (Exception $e) { 264 $core->error->add($e->getMessage()); 265 } 266 } 267 268 # Update menu items 269 if (!empty($_POST['updateaction'])) 270 { 271 try { 272 foreach ($_POST['items_label'] as $k => $v) { 273 if (!$v) throw new Exception(__('Label is mandatory.')); 274 } 275 foreach ($_POST['items_url'] as $k => $v) { 276 if (!$v) throw new Exception(__('URL is mandatory.')); 277 } 278 $newmenu = array(); 279 for ($i = 0; $i < count($_POST['items_label']); $i++) 280 { 281 $newmenu[] = array( 282 'label' => $_POST['items_label'][$i], 283 'descr' => $_POST['items_descr'][$i], 284 'url' => $_POST['items_url'][$i]); 285 } 286 $menu = $newmenu; 287 // Save menu in blog settings 288 $core->blog->settings->system->put('simpleMenu',serialize($menu)); 289 $core->blog->triggerBlog(); 290 291 // All done successfully, return to menu items list 292 dcPage::addSuccessNotice(__('Menu items have been successfully updated.')); 293 http::redirect($p_url); 294 } 295 catch (Exception $e) { 296 $core->error->add($e->getMessage()); 297 } 298 } 299 300 # Order menu items 301 $order = array(); 302 if (empty($_POST['im_order']) && !empty($_POST['order'])) { 303 $order = $_POST['order']; 304 asort($order); 305 $order = array_keys($order); 306 } elseif (!empty($_POST['im_order'])) { 307 $order = $_POST['im_order']; 308 if (substr($order,-1) == ',') { 309 $order = substr($order,0,strlen($order)-1); 310 } 311 $order = explode(',',$order); 312 } 313 314 if (!empty($_POST['updateaction']) && !empty($order)) 315 { 316 try { 317 $newmenu = array(); 318 foreach ($order as $i => $k) { 319 $newmenu[] = array( 320 'label' => $menu[$k]['label'], 321 'descr' => $menu[$k]['descr'], 322 'url' => $menu[$k]['url']); 323 } 324 $menu = $newmenu; 325 // Save menu in blog settings 326 $core->blog->settings->system->put('simpleMenu',serialize($menu)); 327 $core->blog->triggerBlog(); 328 329 // All done successfully, return to menu items list 330 dcPage::addSuccessNotice(__('Menu items have been successfully updated.')); 331 http::redirect($p_url); 332 } 333 catch (Exception $e) { 334 $core->error->add($e->getMessage()); 335 } 336 } 337 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 } 338 359 } 339 360 … … 397 418 dcPage::notices(); 398 419 } 420 399 421 if ($step) 400 422 { … … 464 486 break; 465 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>'; 466 497 } 467 498
Note: See TracChangeset
for help on using the changeset viewer.