Changeset 2415:16da02d6c108 for plugins/widgets/index.php
- Timestamp:
- 10/17/13 07:18:33 (12 years ago)
- 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. - Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/widgets/index.php
r2369 r2415 53 53 } 54 54 } 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 } 55 62 56 63 # Append widgets … … 69 76 foreach ($addw as $k => $v) 70 77 { 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 } 81 91 } 82 92 } … … 95 105 } 96 106 107 # Removing ? 108 $removing = false; 109 if ( 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; 122 if ( 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 97 147 # Update sidebars 98 if (!empty($_POST['wup']) )148 if (!empty($_POST['wup']) || $removing || $move ) 99 149 { 100 150 if (!isset($_POST['w']) || !is_array($_POST['w'])) { … … 198 248 '<form id="listWidgets" action="'.$p_url.'" method="post" class="widgets">'. 199 249 '<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>'. 201 251 '<ul id="widgets-ref">'; 202 252 … … 208 258 ($w->desc() != '' ? ' <span class="form-note">'.__($w->desc()).'</span>' : '').'</p>'. 209 259 '<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>'. 211 262 '<div class="widgetSettings hidden-if-drag">'.$w->formSettings('w[void][0]',$j).'</div>'. 212 263 '</li>'; … … 304 355 } 305 356 306 $res .= '<p class="empty-widgets" '.(!$widgets->isEmpty() ? 'style="display: none;"' : '').'>'.__('No widget.').'</p>';307 308 357 $res .= '<ul id="'.$id.'" class="connected">'; 358 359 $res .= '<li class="empty-widgets" '.(!$widgets->isEmpty() ? 'style="display: none;"' : '').'>'.__('No widget for now.').'</li>'; 309 360 310 361 $i = 0; 311 362 foreach ($widgets->elements() as $w) 312 363 { 364 $upDisabled = $i == 0 ? '" disabled="" src="images/disabled_' : '" src="images/'; 365 $downDisabled = $i == count($widgets->elements())-1 ? '" disabled="" src="images/disabled_' : '" src="images/'; 366 313 367 $iname = 'w['.$pr.']['.$i.']'; 314 368 315 369 $res .= 316 370 '<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>'. 322 380 '<div class="widgetSettings hidden-if-drag">'.$w->formSettings($iname,$j).'</div>'. 323 381 '</li>'; … … 328 386 329 387 $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>'; 335 391 336 392 return $res; -
plugins/widgets/index.php
r2412 r2415 298 298 299 299 $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><tpl:Widget id="<strong>'.__('Widget ID').'</strong>"> 314 <setting name="<strong>'.__('Setting name').'</strong>"><strong>'.__('Setting value').'</strong></setting> 315 ... 316 </tpl:Widget></pre>'. 317 '<p>'.__('Here are the following available widgets for your blog:').'</p>'; 318 319 $widget_elements->content .= '<dl>'; 300 $widget_elements->content = '<dl>'; 320 301 foreach ($__widgets->elements() as $w) 321 302 { … … 363 344 $widget_elements->content .= '</dl></div>'; 364 345 365 dcPage::helpBlock( $widget_elements);346 dcPage::helpBlock('widgets',$widget_elements); 366 347 367 348 function sidebarWidgets($id,$title,$widgets,$pr,$default_widgets,&$j)
Note: See TracChangeset
for help on using the changeset viewer.