Dotclear


Ignore:
Timestamp:
10/17/13 07:18:33 (12 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
2.6
Parents:
2394:d7117f1bbfc5 (diff), 2413:6af4dde5a9c0 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge last PR from default branch

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • plugins/widgets/index.php

    r2369 r2415  
    5353          } 
    5454     } 
     55           
     56     # Append 1 widget 
     57     $wid = false; 
     58     if( gettype($_POST['append']) == 'array' && count($_POST['append']) == 1 ) { 
     59          $wid = array_keys($_POST['append']); 
     60          $wid = $wid[0]; 
     61     } 
    5562      
    5663     # Append widgets 
     
    6976          foreach ($addw as $k => $v) 
    7077          { 
    71                switch ($v) { 
    72                     case 'nav': 
    73                          $widgets_nav->append($__widgets->{$k}); 
    74                          break; 
    75                     case 'extra': 
    76                          $widgets_extra->append($__widgets->{$k}); 
    77                          break; 
    78                     case 'custom': 
    79                          $widgets_custom->append($__widgets->{$k}); 
    80                          break; 
     78               if( !$wid || $wid == $k ) 
     79               { 
     80                    switch ($v) { 
     81                         case 'nav': 
     82                              $widgets_nav->append($__widgets->{$k}); 
     83                              break; 
     84                         case 'extra': 
     85                              $widgets_extra->append($__widgets->{$k}); 
     86                              break; 
     87                         case 'custom': 
     88                              $widgets_custom->append($__widgets->{$k}); 
     89                              break; 
     90                    } 
    8191               } 
    8292          } 
     
    95105} 
    96106 
     107# Removing ? 
     108$removing = false; 
     109if ( isset($_POST['w']) && is_array($_POST['w']) ) { 
     110     foreach ($_POST['w'] as $nsid => $nsw) { 
     111          foreach ($nsw as $i => $v) { 
     112               if (!empty($v['_rem'])) { 
     113                    $removing = true; 
     114                    break 2; 
     115               } 
     116          } 
     117     } 
     118} 
     119 
     120# Move ? 
     121$move = false; 
     122if ( isset($_POST['w']) && is_array($_POST['w']) ) { 
     123     foreach ($_POST['w'] as $nsid => $nsw) { 
     124          foreach ($nsw as $i => $v) { 
     125               if (!empty($v['_down'])) { 
     126                    $oldorder = $_POST['w'][$nsid][$i]['order']; 
     127                    $neworder = $oldorder + 1; 
     128                    if( isset($_POST['w'][$nsid][$neworder]) ) { 
     129                         $_POST['w'][$nsid][$i]['order'] = $neworder; 
     130                         $_POST['w'][$nsid][$neworder]['order'] = $oldorder; 
     131                         $move = true; 
     132                    } 
     133               } 
     134               if (!empty($v['_up'])) { 
     135                    $oldorder = $_POST['w'][$nsid][$i]['order']; 
     136                    $neworder = $oldorder - 1; 
     137                    if( isset($_POST['w'][$nsid][$neworder]) ) { 
     138                         $_POST['w'][$nsid][$i]['order'] = $neworder; 
     139                         $_POST['w'][$nsid][$neworder]['order'] = $oldorder; 
     140                         $move = true; 
     141                    } 
     142               } 
     143          } 
     144     } 
     145} 
     146 
    97147# Update sidebars 
    98 if (!empty($_POST['wup'])) 
     148if (!empty($_POST['wup']) || $removing || $move ) 
    99149{ 
    100150     if (!isset($_POST['w']) || !is_array($_POST['w'])) { 
     
    198248'<form id="listWidgets" action="'.$p_url.'" method="post"  class="widgets">'. 
    199249'<h3>'.__('Available widgets').'</h3>'. 
    200 '<p>'.__('Move widgets from this list to one of the sidebars.').'</p>'. 
     250'<p>'.__('Drag widgets from this list to one of the sidebars, for add.').'</p>'. 
    201251'<ul id="widgets-ref">'; 
    202252 
     
    208258     ($w->desc() != '' ? ' <span class="form-note">'.__($w->desc()).'</span>' : '').'</p>'. 
    209259     '<p class="manual-move remove-if-drag"><label class="classic">'.__('Append to:').'</label> '. 
    210      form::combo(array('addw['.$w->id().']'),$append_combo).'</p>'. 
     260     form::combo(array('addw['.$w->id().']'),$append_combo). 
     261     '<input type="submit" name="append['.$w->id().']" value="'.__('Add').'" /></p>'. 
    211262     '<div class="widgetSettings hidden-if-drag">'.$w->formSettings('w[void][0]',$j).'</div>'. 
    212263     '</li>'; 
     
    304355     } 
    305356      
    306      $res .= '<p class="empty-widgets" '.(!$widgets->isEmpty() ? 'style="display: none;"' : '').'>'.__('No widget.').'</p>'; 
    307       
    308357     $res .= '<ul id="'.$id.'" class="connected">'; 
     358      
     359     $res .= '<li class="empty-widgets" '.(!$widgets->isEmpty() ? 'style="display: none;"' : '').'>'.__('No widget for now.').'</li>'; 
    309360      
    310361     $i = 0; 
    311362     foreach ($widgets->elements() as $w) 
    312363     { 
     364          $upDisabled = $i == 0 ? '" disabled="" src="images/disabled_' : '" src="images/'; 
     365          $downDisabled = $i == count($widgets->elements())-1 ? '" disabled="" src="images/disabled_' : '" src="images/'; 
     366           
    313367          $iname = 'w['.$pr.']['.$i.']'; 
    314368           
    315369          $res .= 
    316370          '<li>'.form::hidden(array($iname.'[id]'),html::escapeHTML($w->id())). 
    317           '<p class="widget-name">'.form::field(array($iname.'[order]'),2,3,(string) $i,'hidden-if-drag','',0,'title="'.__('order').'"').' '.$w->name(). 
    318           ($w->desc() != '' ? ' <span class="form-note">'.__($w->desc()).'</span>' : '').'</p>'. 
    319           '<p class="removeWidget remove-if-drag"><label class="classic">'. 
    320           form::checkbox(array($iname.'[_rem]'),'1',0).' '.__('Remove widget'). 
    321           '</label></p>'. 
     371          '<p class="widget-name">'.form::field(array($iname.'[order]'),2,3,(string) $i,'hidden','',0,'title="'.__('order').'"'). 
     372          ' '.$w->name(). 
     373          ($w->desc() != '' ? ' <span class="form-note">'.__($w->desc()).'</span>' : ''). 
     374          '<span class="toolsWidget remove-if-drag">'. 
     375          '<input type="image" class="upWidget'.$upDisabled.'up.png" name="'.$iname.'[_up]" value="'.__('Up the widget').'" />'. 
     376          '<input type="image" class="downWidget'.$downDisabled.'down.png" name="'.$iname.'[_down]" value="'.__('Down the widget').'" />'.' '. 
     377          '<input type="image" class="removeWidget" src="images/trash.png" name="'.$iname.'[_rem]" value="'.__('Remove widget').'" />'. 
     378          '</span>'. 
     379          '<br class="clear"/></p>'. 
    322380          '<div class="widgetSettings hidden-if-drag">'.$w->formSettings($iname,$j).'</div>'. 
    323381          '</li>'; 
     
    328386      
    329387     $res .= '</ul>'; 
    330  
    331      if ($i > 0) { 
    332           $res .= '<ul class="sortable-delete"><li class="sortable-delete-placeholder">'. 
    333                __('Drag widgets here to remove them from this sidebar.').'</li></ul>'; 
    334      } 
     388      
     389     $res .= '<ul class="sortable-delete"'.($i > 0 ? '':' style="display: none;"').'><li class="sortable-delete-placeholder">'. 
     390               __('Drag widgets here to remove.').'</li></ul>'; 
    335391      
    336392     return $res; 
  • plugins/widgets/index.php

    r2412 r2415  
    298298 
    299299$widget_elements = new stdClass; 
    300 $widget_elements->content = 
    301 '<h4>'.__('Use of widgets').'</h4>'. 
    302 '<p>'.__('Widgets may be used to add various blocks of content to be displayed on your public pages. To add a widget, '. 
    303 'drag it from the Available widgets list on the left to one of the sidebars on the right of this page. You can order '. 
    304 'your widgets in a sidebar by dragging them up or down. You must update sidebars to apply your changes.').'</p>'. 
    305 '<p>'.__('Once included in a sidebar, widgets have configuration options that you can reach by clicking on the arrow next '. 
    306 'to their name.').'</p>'. 
    307 '<p>'.__('Reset sidebars to get back to default widgets installation.').'</p>'. 
    308 '<h4>'.__('Widget templates tags').'</h4>'. 
    309 '<div id="widgets-tpl">'. 
    310 '<p>'.__('If you are allowed to edit your theme templates, you can directly add widgets as '. 
    311 'templates tags, with their own configuration.').'</p>'. 
    312 '<p>'.__('To add a widget in your template, you need to write code like this:').'</p>'. 
    313 '<pre>&lt;tpl:Widget id="<strong>'.__('Widget ID').'</strong>"&gt; 
    314   &lt;setting name="<strong>'.__('Setting name').'</strong>"&gt;<strong>'.__('Setting value').'</strong>&lt;/setting&gt; 
    315   ... 
    316 &lt;/tpl:Widget&gt;</pre>'. 
    317 '<p>'.__('Here are the following available widgets for your blog:').'</p>'; 
    318  
    319 $widget_elements->content .= '<dl>'; 
     300$widget_elements->content = '<dl>'; 
    320301foreach ($__widgets->elements() as $w) 
    321302{ 
     
    363344$widget_elements->content .= '</dl></div>'; 
    364345 
    365 dcPage::helpBlock($widget_elements); 
     346dcPage::helpBlock('widgets',$widget_elements); 
    366347 
    367348function sidebarWidgets($id,$title,$widgets,$pr,$default_widgets,&$j) 
Note: See TracChangeset for help on using the changeset viewer.

Sites map