Changes in [535:66f118a563a5:542:d544ad6b3e5e]
- Files:
-
- 1 added
- 3 edited
-
plugins/simpleMenu/_install.php (added)
-
plugins/simpleMenu/_public.php (modified) (3 diffs)
-
plugins/simpleMenu/index.php (modified) (10 diffs)
-
themes/ductile/tpl/_top.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
plugins/simpleMenu/_public.php
r534 r538 20 20 { 21 21 $class = isset($attr['class']) ? trim($attr['class']) : ''; 22 $id = isset($attr['id']) ? trim($attr['id']) : ''; 22 23 23 24 return '<?php echo tplSimpleMenu::displayMenu('. 24 "'".addslashes($class)."'". 25 "'".addslashes($class)."',". 26 "'".addslashes($id)."'". 25 27 '); ?>'; 26 28 } 27 29 28 public static function displayMenu($class )30 public static function displayMenu($class,$id) 29 31 { 30 32 $ret = ''; … … 59 61 $active = true; 60 62 } 61 $ret .= '<li class="li'.$i.($active ? ' active' : '').'">'. 62 '<a href="'.$href.'">'.$m['label'].($m['descr'] ? '<span>'.$m['descr'].'</span>' : '').'</a>'. 63 $ret .= '<li class="li'.($i+1). 64 ($active ? ' active' : ''). 65 ($i == 0 ? ' li-first' : ''). 66 ($i == count($menu)-1 ? ' li-last' : ''). 67 '">'. 68 '<a href="'.$href.'">'.__($m['label']).($m['descr'] ? '<span>'.__($m['descr']).'</span>' : '').'</a>'. 63 69 '</li>'; 64 70 } … … 66 72 // Final rendering 67 73 if ($ret) { 68 $ret = '<ul class="simple-menu'.($class ? ' '.$class : '').'">'."\n".$ret."\n".'</ul>';74 $ret = '<ul '.($id ? 'id="'.$id.'"' : '').' class="simple-menu'.($class ? ' '.$class : '').'">'."\n".$ret."\n".'</ul>'; 69 75 } 70 76 } -
plugins/simpleMenu/index.php
r534 r540 19 19 $p_url = 'plugin.php?p=simpleMenu'; 20 20 21 # Url du blog 22 $blog_url = html::stripHostURL($core->blog->url); 23 21 24 # Liste des catégories 22 25 $categories_combo = array(); … … 111 114 } 112 115 113 # Menu par défaut114 $blog_url = html::stripHostURL($core->blog->url);115 $menu_default = array(116 array('label' => __('Home'), 'descr' => __('Recent posts'), 'url' => $blog_url),117 array('label' => __('Archives'), 'descr' => __('Old posts'), 'url' => $blog_url.$core->url->getBase('archive'))118 );119 120 116 # Lecture menu existant 121 117 $menu = $core->blog->settings->system->get('simpleMenu'); 122 118 $menu = @unserialize($menu); 123 119 if (!is_array($menu)) { 124 $menu = $menu_default; 125 $core->blog->settings->system->put('simpleMenu',serialize($menu)); 120 $menu = array(); 126 121 } 127 122 … … 129 124 $item_type = isset($_POST['item_type']) ? $_POST['item_type'] : ''; 130 125 $item_select = isset($_POST['item_select']) ? $_POST['item_select'] : ''; 126 $item_label = isset($_POST['item_label']) ? $_POST['item_label'] : ''; 127 $item_descr = isset($_POST['item_descr']) ? $_POST['item_descr'] : ''; 128 $item_url = isset($_POST['item_url']) ? $_POST['item_url'] : ''; 131 129 132 130 # Traitement … … 209 207 // Fourth step, menu item to be added 210 208 try { 211 if ( $item_label && $item_url)209 if (($item_label != '') && ($item_url != '')) 212 210 { 213 211 // Add new item menu in menu array … … 231 229 break; 232 230 } 231 } else { 232 233 # Remove selected menu items 234 if (!empty($_POST['removeaction'])) 235 { 236 try { 237 if (!empty($_POST['items_selected'])) { 238 foreach ($_POST['items_selected'] as $k => $v) { 239 $menu[$v]['label'] = ''; 240 } 241 $newmenu = array(); 242 foreach ($menu as $k => $v) { 243 if ($v['label']) { 244 $newmenu[] = array( 245 'label' => $v['label'], 246 'descr' => $v['descr'], 247 'url' => $v['url']); 248 } 249 } 250 $menu = $newmenu; 251 // Save menu in blog settings 252 $core->blog->settings->system->put('simpleMenu',serialize($menu)); 253 254 // All done successfully, return to menu items list 255 http::redirect($p_url.'&removed=1'); 256 } else { 257 throw new Exception(__('No menu items selected.')); 258 } 259 } 260 catch (Exception $e) { 261 $core->error->add($e->getMessage()); 262 } 263 } 264 265 # Update menu items 266 if (!empty($_POST['updateaction'])) 267 { 268 try { 269 foreach ($_POST['items_label'] as $k => $v) { 270 if (!$v) throw new Exception(__('Label is mandatory.')); 271 } 272 foreach ($_POST['items_url'] as $k => $v) { 273 if (!$v) throw new Exception(__('URL is mandatory.')); 274 } 275 $newmenu = array(); 276 for ($i = 0; $i < count($_POST['items_label']); $i++) 277 { 278 $newmenu[] = array( 279 'label' => $_POST['items_label'][$i], 280 'descr' => $_POST['items_descr'][$i], 281 'url' => $_POST['items_url'][$i]); 282 } 283 $menu = $newmenu; 284 // Save menu in blog settings 285 $core->blog->settings->system->put('simpleMenu',serialize($menu)); 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['saveorder']) && !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 323 // All done successfully, return to menu items list 324 http::redirect($p_url.'&neworder=1'); 325 } 326 catch (Exception $e) { 327 $core->error->add($e->getMessage()); 328 } 329 } 330 233 331 } 234 332 … … 238 336 <html> 239 337 <head> 240 <title><?php echo $page_title; ?></title> 338 <title><?php echo $page_title; ?></title> 339 <?php 340 echo 341 dcPage::jsToolMan(); 342 ?> 343 <?php 344 $core->auth->user_prefs->addWorkspace('accessibility'); 345 $user_dm_nodragdrop = $core->auth->user_prefs->accessibility->nodragdrop; 346 ?> 347 <?php if (!$user_dm_nodragdrop) : ?> 348 <script type="text/javascript"> 349 //<![CDATA[ 350 351 var dragsort = ToolMan.dragsort(); 352 $(function() { 353 dragsort.makeTableSortable($("#menuitemslist").get(0), 354 dotclear.sortable.setHandle,dotclear.sortable.saveOrder); 355 356 $('.checkboxes-helpers').each(function() { 357 dotclear.checkboxesHelpers(this); 358 }); 359 }); 360 361 dotclear.sortable = { 362 setHandle: function(item) { 363 var handle = $(item).find('td.handle').get(0); 364 while (handle.firstChild) { 365 handle.removeChild(handle.firstChild); 366 } 367 368 item.toolManDragGroup.setHandle(handle); 369 handle.className = handle.className+' handler'; 370 }, 371 372 saveOrder: function(item) { 373 var group = item.toolManDragGroup; 374 var order = document.getElementById('im_order'); 375 group.register('dragend', function() { 376 order.value = ''; 377 items = item.parentNode.getElementsByTagName('tr'); 378 379 for (var i=0; i<items.length; i++) { 380 order.value += items[i].id.substr(2)+','; 381 } 382 }); 383 } 384 }; 385 //]]> 386 </script> 387 <?php endif; ?> 388 <!-- 389 <link rel="stylesheet" type="text/css" href="index.php?pf=simpleMenu/style.css" /> 390 --> 241 391 </head> 242 392 … … 252 402 } 253 403 if (!empty($_GET['neworder'])) { 404 echo '<p class="message">'.__('Menu items have been successfully updated.').'</p>'; 405 } 406 if (!empty($_GET['updated'])) { 254 407 echo '<p class="message">'.__('Menu items have been successfully updated.').'</p>'; 255 408 } … … 266 419 echo '<fieldset><legend>'.__('Select type').'</legend>'; 267 420 echo '<p class="field"><label for"item_type" class="classic">'.__('Type of item menu:').'</label>'.form::combo('item_type',$items_combo,'').'</p>'; 268 echo '<p>'.$core->formNonce().'<input type="submit" name="append " value="'.__('Continue').'" />'.'</p>';421 echo '<p>'.$core->formNonce().'<input type="submit" name="appendaction" value="'.__('Continue').'" />'.'</p>'; 269 422 echo '</fieldset>'; 270 423 echo '</form>'; … … 298 451 } 299 452 echo form::hidden('item_type',$item_type); 300 echo '<p>'.$core->formNonce().'<input type="submit" name="append " value="'.__('Continue').'" /></p>';453 echo '<p>'.$core->formNonce().'<input type="submit" name="appendaction" value="'.__('Continue').'" /></p>'; 301 454 echo '</fieldset>'; 302 455 echo '</form>'; … … 307 460 echo '<form id="additem" action="'.$p_url.'&add=4" method="post">'; 308 461 echo '<fieldset><legend>'.$item_type_label.($item_select_label != '' ? ' ('.$item_select_label.')' : '').'</legend>'; 309 echo '<p class="field"><label for"item_label" class="classic">'.__('Label of item menu:').'</label>'.form::field('item_label',10,255,$item_label).'</p>'; 310 echo '<p class="field"><label for"item_descr" class="classic">'.__('Description of item menu:').'</label>'.form::field('item_label',20,255,$item_descr).'</p>'; 311 echo '<p class="field"><label for"item_url" class="classic">'.__('URL of item menu:').'</label>'.form::field('item_url',40,255,$item_url).'</p>'; 462 echo '<p class="field"><label for"item_label" class="classic required"><abbr title="'.__('Required field').'">*</abbr> '. 463 __('Label of item menu:').'</label>'.form::field('item_label',20,255,$item_label).'</p>'; 464 echo '<p class="field"><label for"item_descr" class="classic">'. 465 __('Description of item menu:').'</label>'.form::field('item_descr',30,255,$item_descr).'</p>'; 466 echo '<p class="field"><label for"item_url" class="classic required"><abbr title="'.__('Required field').'">*</abbr> '. 467 __('URL of item menu:').'</label>'.form::field('item_url',40,255,$item_url).'</p>'; 312 468 echo form::hidden('item_type',$item_type).form::hidden('item_select',$item_select); 313 echo '<p>'.$core->formNonce().'<input type="submit" name="append " value="'.__('Add item').'" /></p>';469 echo '<p>'.$core->formNonce().'<input type="submit" name="appendaction" value="'.__('Add item').'" /></p>'; 314 470 echo '</fieldset>'; 315 471 echo '</form>'; 316 472 break; 317 473 } 474 } 475 476 // Liste des items 477 if (!$step) { 478 echo '<h2>'.html::escapeHTML($core->blog->name).' › <span class="page-title">'.$page_title.'</span></h2>'; 479 } 480 481 if (count($menu)) { 482 if (!$step) { 483 echo '<form id="menuitems" action="'.$p_url.'" method="post">'; 484 } 485 // Entête table 486 echo 487 '<table class="maximal dragable">'. 488 '<caption>'.__('Menu items list').'</caption>'. 489 '<thead>'. 490 '<tr>'; 491 if (!$step) { 492 if (count($menu) > 1) { 493 echo '<th scope="col"></th>'; 494 } 495 echo '<th scope="col"></th>'; 496 } 497 echo 498 '<th scope="col">'.__('Label').'</th>'. 499 '<th scope="col">'.__('Description').'</th>'. 500 '<th scope="col">'.__('URL').'</th>'. 501 '</tr>'. 502 '</thead>'. 503 '<tbody id="menuitemslist">'; 504 $count = 0; 505 foreach ($menu as $i => $m) { 506 echo '<tr class="line" id="l_'.$i.'">'; 507 if (!$step) { 508 $count++; 509 if (count($menu) > 1) { 510 echo '<td class="handle minimal">'.form::field(array('order['.$i.']'),2,3,$count,'position','',false,'title="'.sprintf(__('position of %s'),__($m['label'])).'"'). 511 form::hidden(array('dynorder[]','dynorder-'.$i),$i).'</td>'; 512 } 513 echo '<td class="minimal">'.form::checkbox(array('items_selected[]','ims-'.$i),$i).'</td>'; 514 echo '<td class="nowrap" scope="row">'.form::field(array('items_label[]','iml-'.$i),20,255,__($m['label'])).'</td>'; 515 echo '<td class="nowrap">'.form::field(array('items_descr[]','imd-'.$i),30,255,__($m['descr'])).'</td>'; 516 echo '<td class="nowrap">'.form::field(array('items_url[]','imu-'.$i),40,255,$m['url']).'</td>'; 517 } else { 518 echo '<td class="nowrap" scope="row">'.__($m['label']).'</td>'; 519 echo '<td class="nowrap">'.__($m['descr']).'</td>'; 520 echo '<td class="nowrap">'.$m['url'].'</td>'; 521 } 522 echo '</tr>'; 523 } 524 echo '</tbody>'. 525 '</table>'; 526 if (!$step) { 527 echo '<div class="two-cols">'; 528 echo '<p class="col">'.form::hidden('im_order','').$core->formNonce(); 529 if (count($menu) > 1) { 530 echo '<input type="submit" name="saveorder" value="'.__('Save order').'" /> '; 531 } 532 echo '<input type="submit" name="updateaction" value="'.__('Update menu items').'" />'.'</p>'; 533 echo '<p class="col right">'.'<input type="submit" class="delete" name="removeaction" '. 534 'value="'.__('Delete selected menu items').'" '. 535 'onclick="return window.confirm(\''.html::escapeJS(__('Are you sure you want to remove selected menu items?')).'\');" />'. 536 '</p>'; 537 echo '</div>'; 538 echo '</form>'; 539 } 318 540 } else { 319 // Liste des items 320 echo '<h2>'.html::escapeHTML($core->blog->name).' › <span class="page-title">'.$page_title.'</span></h2>'; 321 541 echo 542 '<p>'.__('Currently no menu items').'</p>'; 543 } 544 545 if (!$step) { 322 546 echo '<form id="menuitems" action="'.$p_url.'&add=1" method="post">'; 323 echo '<p>'.$core->formNonce().'<input type="submit" name="append" value="'.__('Add an item').'" /></p>';547 echo '<p>'.$core->formNonce().'<input class="add" type="submit" name="appendaction" value="'.__('Add an item').'" /></p>'; 324 548 echo '</form>'; 325 549 } -
themes/ductile/tpl/_top.html
r532 r541 15 15 {{tpl:SysBehavior behavior="publicTopAfterContent"}} 16 16 17 <!-- Pour Franck: 18 Ajouter une classe incrémental (ex: li<n>) 19 Par défaut : accueil, archives (rien dans le span) 20 --> 21 <ul id="sn-top" class="supranav nosmall"> 22 <li class="li1" class="active"><a href="{{tpl:BlogURL}}">Accueil<span> articles récents</span></a></li> 23 <li class="li2"><a href="#">Construire un thème<span> tutoriels</span></a></li> 24 <li class="li3"><a href="#">Maquettes<span> projets graphiques</span></a></li> 25 <li class="li4"><a href="{{tpl:BlogURL}}archive">Archives<span> 2005-2011</span></a></li> 26 </ul> 27 28 <!-- {{tpl:SimpleMenu class="supranav nosmall"}} --> 17 {{tpl:SimpleMenu id="sn-top" class="supranav nosmall"}} 29 18 30 19 </div>
Note: See TracChangeset
for help on using the changeset viewer.
