Dotclear


Ignore:
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • plugins/simpleMenu/_public.php

    r534 r538  
    2020     { 
    2121          $class = isset($attr['class']) ? trim($attr['class']) : ''; 
     22          $id = isset($attr['id']) ? trim($attr['id']) : ''; 
    2223           
    2324          return '<?php echo tplSimpleMenu::displayMenu('. 
    24                     "'".addslashes($class)."'". 
     25                    "'".addslashes($class)."',". 
     26                    "'".addslashes($id)."'". 
    2527               '); ?>'; 
    2628     } 
    2729      
    28      public static function displayMenu($class) 
     30     public static function displayMenu($class,$id) 
    2931     { 
    3032          $ret = ''; 
     
    5961                         $active = true; 
    6062                    } 
    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>'. 
    6369                              '</li>'; 
    6470               } 
     
    6672               // Final rendering 
    6773               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>'; 
    6975               } 
    7076          } 
  • plugins/simpleMenu/index.php

    r534 r540  
    1919$p_url = 'plugin.php?p=simpleMenu'; 
    2020 
     21# Url du blog 
     22$blog_url = html::stripHostURL($core->blog->url); 
     23 
    2124# Liste des catégories 
    2225$categories_combo = array(); 
     
    111114} 
    112115 
    113 # Menu par défaut 
    114 $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  
    120116# Lecture menu existant 
    121117$menu = $core->blog->settings->system->get('simpleMenu'); 
    122118$menu = @unserialize($menu); 
    123119if (!is_array($menu)) { 
    124      $menu = $menu_default; 
    125      $core->blog->settings->system->put('simpleMenu',serialize($menu)); 
     120     $menu = array(); 
    126121} 
    127122 
     
    129124$item_type = isset($_POST['item_type']) ? $_POST['item_type'] : ''; 
    130125$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'] : ''; 
    131129 
    132130# Traitement 
     
    209207               // Fourth step, menu item to be added 
    210208               try { 
    211                     if ($item_label && $item_url)  
     209                    if (($item_label != '') && ($item_url != ''))  
    212210                    { 
    213211                         // Add new item menu in menu array 
     
    231229               break; 
    232230     } 
     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      
    233331} 
    234332 
     
    238336<html> 
    239337<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     --> 
    241391</head> 
    242392 
     
    252402} 
    253403if (!empty($_GET['neworder'])) { 
     404     echo '<p class="message">'.__('Menu items have been successfully updated.').'</p>'; 
     405} 
     406if (!empty($_GET['updated'])) { 
    254407     echo '<p class="message">'.__('Menu items have been successfully updated.').'</p>'; 
    255408} 
     
    266419               echo '<fieldset><legend>'.__('Select type').'</legend>'; 
    267420               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>'; 
    269422               echo '</fieldset>'; 
    270423               echo '</form>'; 
     
    298451                    } 
    299452                    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>'; 
    301454                    echo '</fieldset>'; 
    302455                    echo '</form>'; 
     
    307460               echo '<form id="additem" action="'.$p_url.'&add=4" method="post">'; 
    308461               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>'; 
    312468               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>'; 
    314470               echo '</fieldset>'; 
    315471               echo '</form>'; 
    316472               break; 
    317473     } 
     474} 
     475 
     476// Liste des items 
     477if (!$step) { 
     478     echo '<h2>'.html::escapeHTML($core->blog->name).' &rsaquo; <span class="page-title">'.$page_title.'</span></h2>'; 
     479} 
     480      
     481if (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     } 
    318540} else { 
    319      // Liste des items 
    320      echo '<h2>'.html::escapeHTML($core->blog->name).' &rsaquo; <span class="page-title">'.$page_title.'</span></h2>'; 
    321  
     541     echo 
     542          '<p>'.__('Currently no menu items').'</p>'; 
     543} 
     544 
     545if (!$step) { 
    322546     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>'; 
    324548     echo '</form>'; 
    325549} 
  • themes/ductile/tpl/_top.html

    r532 r541  
    1515     {{tpl:SysBehavior behavior="publicTopAfterContent"}} 
    1616 
    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"}} 
    2918      
    3019</div> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map