Changeset 3709:c88e69474c34 for plugins/widgets/index.php
- Timestamp:
- 02/18/18 18:16:29 (8 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/widgets/index.php
r3421 r3709 10 10 # 11 11 # -- END LICENSE BLOCK ----------------------------------------- 12 if (!defined('DC_CONTEXT_ADMIN')) { return;}13 14 include dirname(__FILE__) .'/_default_widgets.php';12 if (!defined('DC_CONTEXT_ADMIN')) {return;} 13 14 include dirname(__FILE__) . '/_default_widgets.php'; 15 15 16 16 # Loading navigation, extra widgets and custom widgets 17 17 $widgets_nav = null; 18 18 if ($core->blog->settings->widgets->widgets_nav) { 19 19 $widgets_nav = dcWidgets::load($core->blog->settings->widgets->widgets_nav); 20 20 } 21 21 $widgets_extra = null; 22 22 if ($core->blog->settings->widgets->widgets_extra) { 23 23 $widgets_extra = dcWidgets::load($core->blog->settings->widgets->widgets_extra); 24 24 } 25 25 $widgets_custom = null; 26 26 if ($core->blog->settings->widgets->widgets_custom) { 27 27 $widgets_custom = dcWidgets::load($core->blog->settings->widgets->widgets_custom); 28 28 } 29 29 30 30 $append_combo = array( 31 '-'=> 0,32 33 __('extra')=> 'extra',34 __('custom')=> 'custom'31 '-' => 0, 32 __('navigation') => 'nav', 33 __('extra') => 'extra', 34 __('custom') => 'custom' 35 35 ); 36 36 37 37 function literalNullString($v) 38 38 { 39 40 return '<'.__('empty string').'>';41 42 39 if ($v == '') { 40 return '<' . __('empty string') . '>'; 41 } 42 return $v; 43 43 } 44 44 45 45 # Adding widgets to sidebars 46 if (!empty($_POST['append']) && is_array($_POST['addw'])) 47 { 48 # Filter selection 49 $addw = array(); 50 foreach ($_POST['addw'] as $k => $v) { 51 if (($v == 'extra' || $v == 'nav' || $v == 'custom') && $__widgets->{$k} !== null ) { 52 $addw[$k] = $v; 53 } 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 } 62 63 # Append widgets 64 if (!empty($addw)) 65 { 66 if (!($widgets_nav instanceof dcWidgets)) { 67 $widgets_nav = new dcWidgets; 68 } 69 if (!($widgets_extra instanceof dcWidgets)) { 70 $widgets_extra = new dcWidgets(); 71 } 72 if (!($widgets_custom instanceof dcWidgets)) { 73 $widgets_custom = new dcWidgets(); 74 } 75 76 foreach ($addw as $k => $v) 77 { 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 } 91 } 92 } 93 94 try { 95 $core->blog->settings->addNamespace('widgets'); 96 $core->blog->settings->widgets->put('widgets_nav',$widgets_nav->store()); 97 $core->blog->settings->widgets->put('widgets_extra',$widgets_extra->store()); 98 $core->blog->settings->widgets->put('widgets_custom',$widgets_custom->store()); 99 $core->blog->triggerBlog(); 100 http::redirect($p_url); 101 } catch (Exception $e) { 102 $core->error->add($e->getMessage()); 103 } 104 } 46 if (!empty($_POST['append']) && is_array($_POST['addw'])) { 47 # Filter selection 48 $addw = array(); 49 foreach ($_POST['addw'] as $k => $v) { 50 if (($v == 'extra' || $v == 'nav' || $v == 'custom') && $__widgets->{$k} !== null) { 51 $addw[$k] = $v; 52 } 53 } 54 55 # Append 1 widget 56 $wid = false; 57 if (gettype($_POST['append']) == 'array' && count($_POST['append']) == 1) { 58 $wid = array_keys($_POST['append']); 59 $wid = $wid[0]; 60 } 61 62 # Append widgets 63 if (!empty($addw)) { 64 if (!($widgets_nav instanceof dcWidgets)) { 65 $widgets_nav = new dcWidgets; 66 } 67 if (!($widgets_extra instanceof dcWidgets)) { 68 $widgets_extra = new dcWidgets(); 69 } 70 if (!($widgets_custom instanceof dcWidgets)) { 71 $widgets_custom = new dcWidgets(); 72 } 73 74 foreach ($addw as $k => $v) { 75 if (!$wid || $wid == $k) { 76 switch ($v) { 77 case 'nav': 78 $widgets_nav->append($__widgets->{$k}); 79 break; 80 case 'extra': 81 $widgets_extra->append($__widgets->{$k}); 82 break; 83 case 'custom': 84 $widgets_custom->append($__widgets->{$k}); 85 break; 86 } 87 } 88 } 89 90 try { 91 $core->blog->settings->addNamespace('widgets'); 92 $core->blog->settings->widgets->put('widgets_nav', $widgets_nav->store()); 93 $core->blog->settings->widgets->put('widgets_extra', $widgets_extra->store()); 94 $core->blog->settings->widgets->put('widgets_custom', $widgets_custom->store()); 95 $core->blog->triggerBlog(); 96 http::redirect($p_url); 97 } catch (Exception $e) { 98 $core->error->add($e->getMessage()); 99 } 100 } 105 101 } 106 102 107 103 # Removing ? 108 104 $removing = false; 109 if ( isset($_POST['w']) && is_array($_POST['w'])) {110 111 112 113 114 115 116 117 105 if (isset($_POST['w']) && is_array($_POST['w'])) { 106 foreach ($_POST['w'] as $nsid => $nsw) { 107 foreach ($nsw as $i => $v) { 108 if (!empty($v['_rem'])) { 109 $removing = true; 110 break 2; 111 } 112 } 113 } 118 114 } 119 115 120 116 # Move ? 121 117 $move = false; 122 if ( isset($_POST['w']) && is_array($_POST['w'])) {123 124 125 126 127 128 if( isset($_POST['w'][$nsid][$neworder])) {129 $_POST['w'][$nsid][$i]['order']= $neworder;130 131 $move= true;132 133 134 135 136 137 if( isset($_POST['w'][$nsid][$neworder])) {138 $_POST['w'][$nsid][$i]['order']= $neworder;139 140 $move= true;141 142 143 144 118 if (isset($_POST['w']) && is_array($_POST['w'])) { 119 foreach ($_POST['w'] as $nsid => $nsw) { 120 foreach ($nsw as $i => $v) { 121 if (!empty($v['_down'])) { 122 $oldorder = $_POST['w'][$nsid][$i]['order']; 123 $neworder = $oldorder + 1; 124 if (isset($_POST['w'][$nsid][$neworder])) { 125 $_POST['w'][$nsid][$i]['order'] = $neworder; 126 $_POST['w'][$nsid][$neworder]['order'] = $oldorder; 127 $move = true; 128 } 129 } 130 if (!empty($v['_up'])) { 131 $oldorder = $_POST['w'][$nsid][$i]['order']; 132 $neworder = $oldorder - 1; 133 if (isset($_POST['w'][$nsid][$neworder])) { 134 $_POST['w'][$nsid][$i]['order'] = $neworder; 135 $_POST['w'][$nsid][$neworder]['order'] = $oldorder; 136 $move = true; 137 } 138 } 139 } 140 } 145 141 } 146 142 147 143 # Update sidebars 148 if (!empty($_POST['wup']) || $removing || $move ) 149 { 150 if (!isset($_POST['w']) || !is_array($_POST['w'])) { 151 $_POST['w'] = array(); 152 } 153 154 try 155 { 156 # Removing mark as _rem widgets 157 foreach ($_POST['w'] as $nsid => $nsw) { 158 foreach ($nsw as $i => $v) { 159 if (!empty($v['_rem'])) { 160 unset($_POST['w'][$nsid][$i]); 161 continue; 162 } 163 } 164 } 165 166 if (!isset($_POST['w']['nav'])) { 167 $_POST['w']['nav'] = array(); 168 } 169 if (!isset($_POST['w']['extra'])) { 170 $_POST['w']['extra'] = array(); 171 } 172 if (!isset($_POST['w']['custom'])) { 173 $_POST['w']['custom'] = array(); 174 } 175 176 $widgets_nav = dcWidgets::loadArray($_POST['w']['nav'],$__widgets); 177 $widgets_extra = dcWidgets::loadArray($_POST['w']['extra'],$__widgets); 178 $widgets_custom = dcWidgets::loadArray($_POST['w']['custom'],$__widgets); 179 180 $core->blog->settings->addNamespace('widgets'); 181 $core->blog->settings->widgets->put('widgets_nav',$widgets_nav->store()); 182 $core->blog->settings->widgets->put('widgets_extra',$widgets_extra->store()); 183 $core->blog->settings->widgets->put('widgets_custom',$widgets_custom->store()); 184 $core->blog->triggerBlog(); 185 186 dcPage::addSuccessNotice(__('Sidebars and their widgets have been saved.')); 187 http::redirect($p_url); 188 } 189 catch (Exception $e) 190 { 191 $core->error->add($e->getMessage()); 192 } 193 } 194 elseif (!empty($_POST['wreset'])) 195 { 196 try 197 { 198 $core->blog->settings->addNamespace('widgets'); 199 $core->blog->settings->widgets->put('widgets_nav',''); 200 $core->blog->settings->widgets->put('widgets_extra',''); 201 $core->blog->settings->widgets->put('widgets_custom',''); 202 $core->blog->triggerBlog(); 203 204 dcPage::addSuccessNotice(__('Sidebars have been resetting.')); 205 http::redirect($p_url); 206 } 207 catch (Exception $e) 208 { 209 $core->error->add($e->getMessage()); 210 } 144 if (!empty($_POST['wup']) || $removing || $move) { 145 if (!isset($_POST['w']) || !is_array($_POST['w'])) { 146 $_POST['w'] = array(); 147 } 148 149 try 150 { 151 # Removing mark as _rem widgets 152 foreach ($_POST['w'] as $nsid => $nsw) { 153 foreach ($nsw as $i => $v) { 154 if (!empty($v['_rem'])) { 155 unset($_POST['w'][$nsid][$i]); 156 continue; 157 } 158 } 159 } 160 161 if (!isset($_POST['w']['nav'])) { 162 $_POST['w']['nav'] = array(); 163 } 164 if (!isset($_POST['w']['extra'])) { 165 $_POST['w']['extra'] = array(); 166 } 167 if (!isset($_POST['w']['custom'])) { 168 $_POST['w']['custom'] = array(); 169 } 170 171 $widgets_nav = dcWidgets::loadArray($_POST['w']['nav'], $__widgets); 172 $widgets_extra = dcWidgets::loadArray($_POST['w']['extra'], $__widgets); 173 $widgets_custom = dcWidgets::loadArray($_POST['w']['custom'], $__widgets); 174 175 $core->blog->settings->addNamespace('widgets'); 176 $core->blog->settings->widgets->put('widgets_nav', $widgets_nav->store()); 177 $core->blog->settings->widgets->put('widgets_extra', $widgets_extra->store()); 178 $core->blog->settings->widgets->put('widgets_custom', $widgets_custom->store()); 179 $core->blog->triggerBlog(); 180 181 dcPage::addSuccessNotice(__('Sidebars and their widgets have been saved.')); 182 http::redirect($p_url); 183 } catch (Exception $e) { 184 $core->error->add($e->getMessage()); 185 } 186 } elseif (!empty($_POST['wreset'])) { 187 try 188 { 189 $core->blog->settings->addNamespace('widgets'); 190 $core->blog->settings->widgets->put('widgets_nav', ''); 191 $core->blog->settings->widgets->put('widgets_extra', ''); 192 $core->blog->settings->widgets->put('widgets_custom', ''); 193 $core->blog->triggerBlog(); 194 195 dcPage::addSuccessNotice(__('Sidebars have been resetting.')); 196 http::redirect($p_url); 197 } catch (Exception $e) { 198 $core->error->add($e->getMessage()); 199 } 211 200 } 212 201 ?> … … 214 203 <head> 215 204 <title><?php echo __('Widgets'); ?></title> 216 <?php echo dcPage::cssLoad(dcPage::getPF('widgets/style.css'));?> 217 <?php 218 echo 219 dcPage::jsLoad('js/jquery/jquery-ui.custom.js'). 220 dcPage::jsLoad('js/jquery/jquery.ui.touch-punch.js'). 221 dcPage::jsLoad(dcPage::getPF('widgets/widgets.js')); 222 ?> 223 <?php 224 $core->auth->user_prefs->addWorkspace('accessibility'); 225 $user_dm_nodragdrop = $core->auth->user_prefs->accessibility->nodragdrop; 226 ?> 227 <?php if (!$user_dm_nodragdrop) : ?> 228 <?php echo dcPage::jsLoad(dcPage::getPF('widgets/dragdrop.js'));?> 229 <?php endif; ?> 230 <script type="text/javascript"> 231 <?php echo dcPage::jsVar('dotclear.msg.confirm_widgets_reset', 232 __('Are you sure you want to reset sidebars?')); ?> 233 </script> 234 <?php 235 $widget_editor = $core->auth->getOption('editor'); 236 $rte_flag = true; 237 $rte_flags = @$core->auth->user_prefs->interface->rte_flags; 238 if (is_array($rte_flags) && in_array('widgets_text',$rte_flags)) { 239 $rte_flag = $rte_flags['widgets_text']; 240 } 241 if ($rte_flag) { 242 echo $core->callBehavior('adminPostEditor',$widget_editor['xhtml'],'widget',array('#sidebarsWidgets textarea'),'xhtml'); 243 } 244 ?> 245 <?php echo(dcPage::jsConfirmClose('sidebarsWidgets')); ?> 205 <?php 206 echo dcPage::cssLoad(dcPage::getPF('widgets/style.css')) . 207 dcPage::jsLoad('js/jquery/jquery-ui.custom.js') . 208 dcPage::jsLoad('js/jquery/jquery.ui.touch-punch.js') . 209 dcPage::jsLoad(dcPage::getPF('widgets/js/widgets.js')); 210 211 $core->auth->user_prefs->addWorkspace('accessibility'); 212 $user_dm_nodragdrop = $core->auth->user_prefs->accessibility->nodragdrop; 213 if (!$user_dm_nodragdrop) { 214 echo dcPage::jsLoad(dcPage::getPF('widgets/js/dragdrop.js')); 215 } 216 echo dcPage::jsVars(array('dotclear.msg.confirm_widgets_reset' => __('Are you sure you want to reset sidebars?'))); 217 218 $widget_editor = $core->auth->getOption('editor'); 219 $rte_flag = true; 220 $rte_flags = @$core->auth->user_prefs->interface->rte_flags; 221 if (is_array($rte_flags) && in_array('widgets_text', $rte_flags)) { 222 $rte_flag = $rte_flags['widgets_text']; 223 } 224 if ($rte_flag) { 225 echo $core->callBehavior('adminPostEditor', $widget_editor['xhtml'], 'widget', array('#sidebarsWidgets textarea'), 'xhtml'); 226 } 227 echo (dcPage::jsConfirmClose('sidebarsWidgets')); 228 ?> 246 229 </head> 247 230 <body> 248 231 <?php 249 232 echo dcPage::breadcrumb( 250 251 252 __('Widgets')=> ''253 )).254 233 array( 234 html::escapeHTML($core->blog->name) => '', 235 __('Widgets') => '' 236 )) . 237 dcPage::notices(); 255 238 256 239 # All widgets 257 240 echo 258 '<form id="listWidgets" action="' .$p_url.'" method="post" class="widgets">'.259 '<h3>' .__('Available widgets').'</h3>'.260 '<p>' .__('Drag widgets from this list to one of the sidebars, for add.').'</p>'.261 '<ul id="widgets-ref">';241 '<form id="listWidgets" action="' . $p_url . '" method="post" class="widgets">' . 242 '<h3>' . __('Available widgets') . '</h3>' . 243 '<p>' . __('Drag widgets from this list to one of the sidebars, for add.') . '</p>' . 244 '<ul id="widgets-ref">'; 262 245 263 246 $j = 0; 264 247 foreach ($__widgets->elements(true) as $w) { 265 266 '<li>'.form::hidden(array('w[void][0][id]'),html::escapeHTML($w->id())).267 '<p class="widget-name">'.form::field(array('w[void][0][order]'),2,3,0,'hide','',0,'title="'.__('order').'"').' '.$w->name().268 ($w->desc() != '' ? ' <span class="form-note">'.__($w->desc()).'</span>' : '').'</p>'.269 '<p class="manual-move remove-if-drag"><label class="classic">'.__('Append to:').'</label> '.270 form::combo(array('addw['.$w->id().']'),$append_combo).271 '<input type="submit" name="append['.$w->id().']" value="'.__('Add').'" /></p>'.272 '<div class="widgetSettings hidden-if-drag">'.$w->formSettings('w[void][0]',$j).'</div>'.273 274 275 } 276 277 echo 278 '</ul>' .279 '<p>' .$core->formNonce().'</p>'.280 '<p class="remove-if-drag"><input type="submit" name="append" value="' .__('Add widgets to sidebars').'" /></p>'.281 '</form>';282 283 echo '<form id="sidebarsWidgets" action="' .$p_url.'" method="post">';248 echo 249 '<li>' . form::hidden(array('w[void][0][id]'), html::escapeHTML($w->id())) . 250 '<p class="widget-name">' . form::field(array('w[void][0][order]'), 2, 3, 0, 'hide', '', 0, 'title="' . __('order') . '"') . ' ' . $w->name() . 251 ($w->desc() != '' ? ' <span class="form-note">' . __($w->desc()) . '</span>' : '') . '</p>' . 252 '<p class="manual-move remove-if-drag"><label class="classic">' . __('Append to:') . '</label> ' . 253 form::combo(array('addw[' . $w->id() . ']'), $append_combo) . 254 '<input type="submit" name="append[' . $w->id() . ']" value="' . __('Add') . '" /></p>' . 255 '<div class="widgetSettings hidden-if-drag">' . $w->formSettings('w[void][0]', $j) . '</div>' . 256 '</li>'; 257 $j++; 258 } 259 260 echo 261 '</ul>' . 262 '<p>' . $core->formNonce() . '</p>' . 263 '<p class="remove-if-drag"><input type="submit" name="append" value="' . __('Add widgets to sidebars') . '" /></p>' . 264 '</form>'; 265 266 echo '<form id="sidebarsWidgets" action="' . $p_url . '" method="post">'; 284 267 # Nav sidebar 285 268 echo 286 '<div id="sidebarNav" class="widgets fieldset">' .287 sidebarWidgets('dndnav', __('Navigation sidebar'),$widgets_nav,'nav',$__default_widgets['nav'],$j);269 '<div id="sidebarNav" class="widgets fieldset">' . 270 sidebarWidgets('dndnav', __('Navigation sidebar'), $widgets_nav, 'nav', $__default_widgets['nav'], $j); 288 271 echo '</div>'; 289 272 290 273 # Extra sidebar 291 274 echo 292 '<div id="sidebarExtra" class="widgets fieldset">' .293 sidebarWidgets('dndextra', __('Extra sidebar'),$widgets_extra,'extra',$__default_widgets['extra'],$j);275 '<div id="sidebarExtra" class="widgets fieldset">' . 276 sidebarWidgets('dndextra', __('Extra sidebar'), $widgets_extra, 'extra', $__default_widgets['extra'], $j); 294 277 echo '</div>'; 295 278 296 279 # Custom sidebar 297 280 echo 298 '<div id="sidebarCustom" class="widgets fieldset">' .299 sidebarWidgets('dndcustom', __('Custom sidebar'),$widgets_custom,'custom',$__default_widgets['custom'],$j);281 '<div id="sidebarCustom" class="widgets fieldset">' . 282 sidebarWidgets('dndcustom', __('Custom sidebar'), $widgets_custom, 'custom', $__default_widgets['custom'], $j); 300 283 echo '</div>'; 301 284 302 285 echo 303 '<p id="sidebarsControl">' .304 $core->formNonce() .305 '<input type="submit" name="wup" value="' .__('Update sidebars').'" /> '.306 '<input type="submit" class="reset" name="wreset" value="' .__('Reset sidebars').'" /></p>'.307 '</form>';308 309 $widget_elements = new stdClass;286 '<p id="sidebarsControl">' . 287 $core->formNonce() . 288 '<input type="submit" name="wup" value="' . __('Update sidebars') . '" /> ' . 289 '<input type="submit" class="reset" name="wreset" value="' . __('Reset sidebars') . '" /></p>' . 290 '</form>'; 291 292 $widget_elements = new stdClass; 310 293 $widget_elements->content = '<dl>'; 311 foreach ($__widgets->elements() as $w) 294 foreach ($__widgets->elements() as $w) { 295 $widget_elements->content .= 296 '<dt><strong>' . html::escapeHTML($w->name()) . '</strong> (' . 297 __('Widget ID:') . ' <strong>' . html::escapeHTML($w->id()) . '</strong>)' . 298 ($w->desc() != '' ? ' <span class="form-note">' . __($w->desc()) . '</span>' : '') . '</dt>' . 299 '<dd>'; 300 301 $w_settings = $w->settings(); 302 if (empty($w_settings)) { 303 $widget_elements->content .= '<p>' . __('No setting for this widget') . '</p>'; 304 } else { 305 $widget_elements->content .= '<ul>'; 306 foreach ($w->settings() as $n => $s) { 307 switch ($s['type']) { 308 case 'check': 309 $s_type = __('boolean') . ", " . __('possible values:') . " <code>0</code> " . __('or') . " <code>1</code>"; 310 break; 311 case 'combo': 312 $s['options'] = array_map("literalNullString", $s['options']); 313 $s_type = __('listitem') . ", " . __('possible values:') . " <code>" . implode('</code>, <code>', $s['options']) . "</code>"; 314 break; 315 case 'text': 316 case 'textarea': 317 default: 318 $s_type = __('string'); 319 break; 320 } 321 322 $widget_elements->content .= 323 '<li>' . 324 __('Setting name:') . ' <strong>' . html::escapeHTML($n) . '</strong>' . 325 ' (' . $s_type . ')' . 326 '</li>'; 327 } 328 $widget_elements->content .= '</ul>'; 329 } 330 $widget_elements->content .= '</dd>'; 331 } 332 $widget_elements->content .= '</dl></div>'; 333 334 dcPage::helpBlock('widgets', $widget_elements); 335 336 function sidebarWidgets($id, $title, $widgets, $pr, $default_widgets, &$j) 312 337 { 313 $widget_elements->content .= 314 '<dt><strong>'.html::escapeHTML($w->name()).'</strong> ('. 315 __('Widget ID:').' <strong>'.html::escapeHTML($w->id()).'</strong>)'. 316 ($w->desc() != '' ? ' <span class="form-note">'.__($w->desc()).'</span>' : '').'</dt>'. 317 '<dd>'; 318 319 $w_settings = $w->settings(); 320 if (empty($w_settings)) 321 { 322 $widget_elements->content .= '<p>'.__('No setting for this widget').'</p>'; 323 } 324 else 325 { 326 $widget_elements->content .= '<ul>'; 327 foreach ($w->settings() as $n => $s) 328 { 329 switch ($s['type']) { 330 case 'check': 331 $s_type = __('boolean').", ".__('possible values:')." <code>0</code> ".__('or')." <code>1</code>"; 332 break; 333 case 'combo': 334 $s['options'] = array_map("literalNullString", $s['options']); 335 $s_type = __('listitem').", ".__('possible values:')." <code>".implode('</code>, <code>',$s['options'])."</code>"; 336 break; 337 case 'text': 338 case 'textarea': 339 default: 340 $s_type = __('string'); 341 break; 342 } 343 344 $widget_elements->content .= 345 '<li>'. 346 __('Setting name:').' <strong>'.html::escapeHTML($n).'</strong>'. 347 ' ('.$s_type.')'. 348 '</li>'; 349 } 350 $widget_elements->content .= '</ul>'; 351 } 352 $widget_elements->content .= '</dd>'; 353 } 354 $widget_elements->content .= '</dl></div>'; 355 356 dcPage::helpBlock('widgets',$widget_elements); 357 358 function sidebarWidgets($id,$title,$widgets,$pr,$default_widgets,&$j) 359 { 360 $res = '<h3>'.$title.'</h3>'; 361 362 if (!($widgets instanceof dcWidgets)) 363 { 364 $widgets = $default_widgets; 365 } 366 367 $res .= '<ul id="'.$id.'" class="connected">'; 368 369 $res .= '<li class="empty-widgets" '.(!$widgets->isEmpty() ? 'style="display: none;"' : '').'>'.__('No widget as far.').'</li>'; 370 371 $i = 0; 372 foreach ($widgets->elements() as $w) 373 { 374 $upDisabled = $i == 0 ? ' disabled" src="images/disabled_' : '" src="images/'; 375 $downDisabled = $i == count($widgets->elements())-1 ? ' disabled" src="images/disabled_' : '" src="images/'; 376 $altUp = $i == 0 ? ' alt=""' : ' alt="'.__('Up the widget').'"'; 377 $altDown = $i == count($widgets->elements())-1 ? ' alt=""' : ' alt="'.__('Down the widget').'"'; 378 379 $iname = 'w['.$pr.']['.$i.']'; 380 381 $res .= 382 '<li>'.form::hidden(array($iname.'[id]'),html::escapeHTML($w->id())). 383 '<p class="widget-name">'.form::field(array($iname.'[order]'),2,3,(string) $i,'hidden','',0,'title="'.__('order').'"'). 384 ' '.$w->name(). 385 ($w->desc() != '' ? ' <span class="form-note">'.__($w->desc()).'</span>' : ''). 386 '<span class="toolsWidget remove-if-drag">'. 387 '<input type="image" class="upWidget'.$upDisabled.'up.png" name="'.$iname.'[_up]" value="'.__('Up the widget').'"'.$altUp.' /> '. 388 '<input type="image" class="downWidget'.$downDisabled.'down.png" name="'.$iname.'[_down]" value="'.__('Down the widget').'"'.$altDown.' /> '.' '. 389 '<input type="image" class="removeWidget" src="images/trash.png" name="'.$iname.'[_rem]" value="'.__('Remove widget').'" alt="'.__('Remove the widget').'" />'. 390 '</span>'. 391 '<br class="clear"/></p>'. 392 '<div class="widgetSettings hidden-if-drag">'.$w->formSettings($iname,$j).'</div>'. 393 '</li>'; 394 395 $i++; 396 $j++; 397 } 398 399 $res .= '</ul>'; 400 401 $res .= '<ul class="sortable-delete"'.($i > 0 ? '':' style="display: none;"').'><li class="sortable-delete-placeholder">'. 402 __('Drag widgets here to remove.').'</li></ul>'; 403 404 return $res; 338 $res = '<h3>' . $title . '</h3>'; 339 340 if (!($widgets instanceof dcWidgets)) { 341 $widgets = $default_widgets; 342 } 343 344 $res .= '<ul id="' . $id . '" class="connected">'; 345 346 $res .= '<li class="empty-widgets" ' . (!$widgets->isEmpty() ? 'style="display: none;"' : '') . '>' . __('No widget as far.') . '</li>'; 347 348 $i = 0; 349 foreach ($widgets->elements() as $w) { 350 $upDisabled = $i == 0 ? ' disabled" src="images/disabled_' : '" src="images/'; 351 $downDisabled = $i == count($widgets->elements()) - 1 ? ' disabled" src="images/disabled_' : '" src="images/'; 352 $altUp = $i == 0 ? ' alt=""' : ' alt="' . __('Up the widget') . '"'; 353 $altDown = $i == count($widgets->elements()) - 1 ? ' alt=""' : ' alt="' . __('Down the widget') . '"'; 354 355 $iname = 'w[' . $pr . '][' . $i . ']'; 356 357 $res .= 358 '<li>' . form::hidden(array($iname . '[id]'), html::escapeHTML($w->id())) . 359 '<p class="widget-name">' . form::field(array($iname . '[order]'), 2, 3, (string) $i, 'hidden', '', 0, 'title="' . __('order') . '"') . 360 ' ' . $w->name() . 361 ($w->desc() != '' ? ' <span class="form-note">' . __($w->desc()) . '</span>' : '') . 362 '<span class="toolsWidget remove-if-drag">' . 363 '<input type="image" class="upWidget' . $upDisabled . 'up.png" name="' . $iname . '[_up]" value="' . __('Up the widget') . '"' . $altUp . ' /> ' . 364 '<input type="image" class="downWidget' . $downDisabled . 'down.png" name="' . $iname . '[_down]" value="' . __('Down the widget') . '"' . $altDown . ' /> ' . ' ' . 365 '<input type="image" class="removeWidget" src="images/trash.png" name="' . $iname . '[_rem]" value="' . __('Remove widget') . '" alt="' . __('Remove the widget') . '" />' . 366 '</span>' . 367 '<br class="clear"/></p>' . 368 '<div class="widgetSettings hidden-if-drag">' . $w->formSettings($iname, $j) . '</div>' . 369 '</li>'; 370 371 $i++; 372 $j++; 373 } 374 375 $res .= '</ul>'; 376 377 $res .= '<ul class="sortable-delete"' . ($i > 0 ? '' : ' style="display: none;"') . '><li class="sortable-delete-placeholder">' . 378 __('Drag widgets here to remove.') . '</li></ul>'; 379 380 return $res; 405 381 } 406 382 ?>
Note: See TracChangeset
for help on using the changeset viewer.