Changeset 2398:c06651a81e7e for plugins/widgets/index.php
- Timestamp:
- 10/05/13 17:56:12 (12 years ago)
- Branch:
- widgets
- Parents:
- 2397:effa61ef2c4b (diff), 2278:e4c8da04bec4 (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
r2256 r2398 13 13 14 14 include dirname(__FILE__).'/_default_widgets.php'; 15 16 # Loading navigation, extra widgets and custom widgets17 $widgets_nav = null;18 if ($core->blog->settings->widgets->widgets_nav) {19 $widgets_nav = dcWidgets::load($core->blog->settings->widgets->widgets_nav);20 }21 $widgets_extra = null;22 if ($core->blog->settings->widgets->widgets_extra) {23 $widgets_extra = dcWidgets::load($core->blog->settings->widgets->widgets_extra);24 }25 $widgets_custom = null;26 if ($core->blog->settings->widgets->widgets_custom) {27 $widgets_custom = dcWidgets::load($core->blog->settings->widgets->widgets_custom);28 }29 30 $append_combo = array(31 '-' => 0,32 __('navigation') => 'nav',33 __('extra') => 'extra',34 __('custom') => 'custom'35 );36 37 function literalNullString($v)38 {39 if ($v == '') {40 return '<'.__('empty string').'>';41 }42 return $v;43 }44 45 # Adding widgets to sidebars46 if (!empty($_POST['append']) && is_array($_POST['addw']))47 {48 # Filter selection49 $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 widgets57 if (!empty($addw))58 {59 if (!($widgets_nav instanceof dcWidgets)) {60 $widgets_nav = new dcWidgets;61 }62 if (!($widgets_extra instanceof dcWidgets)) {63 $widgets_extra = new dcWidgets();64 }65 if (!($widgets_custom instanceof dcWidgets)) {66 $widgets_custom = new dcWidgets();67 }68 69 foreach ($addw as $k => $v)70 {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;81 }82 }83 84 try {85 $core->blog->settings->addNamespace('widgets');86 $core->blog->settings->widgets->put('widgets_nav',$widgets_nav->store());87 $core->blog->settings->widgets->put('widgets_extra',$widgets_extra->store());88 $core->blog->settings->widgets->put('widgets_custom',$widgets_custom->store());89 $core->blog->triggerBlog();90 http::redirect($p_url);91 } catch (Exception $e) {92 $core->error->add($e->getMessage());93 }94 }95 }96 97 # Update sidebars98 if (!empty($_POST['wup']))99 {100 if (!isset($_POST['w']) || !is_array($_POST['w'])) {101 $_POST['w'] = array();102 }103 104 try105 {106 # Removing mark as _rem widgets107 foreach ($_POST['w'] as $nsid => $nsw) {108 foreach ($nsw as $i => $v) {109 if (!empty($v['_rem'])) {110 unset($_POST['w'][$nsid][$i]);111 continue;112 }113 }114 }115 116 if (!isset($_POST['w']['nav'])) {117 $_POST['w']['nav'] = array();118 }119 if (!isset($_POST['w']['extra'])) {120 $_POST['w']['extra'] = array();121 }122 if (!isset($_POST['w']['custom'])) {123 $_POST['w']['custom'] = array();124 }125 126 $widgets_nav = dcWidgets::loadArray($_POST['w']['nav'],$__widgets);127 $widgets_extra = dcWidgets::loadArray($_POST['w']['extra'],$__widgets);128 $widgets_custom = dcWidgets::loadArray($_POST['w']['custom'],$__widgets);129 130 $core->blog->settings->addNamespace('widgets');131 $core->blog->settings->widgets->put('widgets_nav',$widgets_nav->store());132 $core->blog->settings->widgets->put('widgets_extra',$widgets_extra->store());133 $core->blog->settings->widgets->put('widgets_custom',$widgets_custom->store());134 $core->blog->triggerBlog();135 136 http::redirect($p_url);137 }138 catch (Exception $e)139 {140 $core->error->add($e->getMessage());141 }142 }143 elseif (!empty($_POST['wreset']))144 {145 try146 {147 $core->blog->settings->addNamespace('widgets');148 $core->blog->settings->widgets->put('widgets_nav','');149 $core->blog->settings->widgets->put('widgets_extra','');150 $core->blog->settings->widgets->put('widgets_custom','');151 $core->blog->triggerBlog();152 153 http::redirect($p_url);154 }155 catch (Exception $e)156 {157 $core->error->add($e->getMessage());158 }159 }160 15 ?> 161 16 <html> … … 187 42 <body> 188 43 <?php 44 # Loading navigation, extra widgets and custom widgets 45 $widgets_nav = null; 46 if ($core->blog->settings->widgets->widgets_nav) { 47 $widgets_nav = dcWidgets::load($core->blog->settings->widgets->widgets_nav); 48 } 49 $widgets_extra = null; 50 if ($core->blog->settings->widgets->widgets_extra) { 51 $widgets_extra = dcWidgets::load($core->blog->settings->widgets->widgets_extra); 52 } 53 $widgets_custom = null; 54 if ($core->blog->settings->widgets->widgets_custom) { 55 $widgets_custom = dcWidgets::load($core->blog->settings->widgets->widgets_custom); 56 } 57 58 $append_combo = array( 59 '-' => 0, 60 __('navigation') => 'nav', 61 __('extra') => 'extra', 62 __('custom') => 'custom' 63 ); 64 65 function literalNullString($v) 66 { 67 if ($v == '') { 68 return '<'.__('empty string').'>'; 69 } 70 return $v; 71 } 72 73 # Adding widgets to sidebars 74 if (!empty($_POST['append']) && is_array($_POST['addw'])) 75 { 76 # Filter selection 77 $addw = array(); 78 foreach ($_POST['addw'] as $k => $v) { 79 if (($v == 'extra' || $v == 'nav' || $v == 'custom') && $__widgets->{$k} !== null ) { 80 $addw[$k] = $v; 81 } 82 } 83 84 # Append 1 widget 85 $wid = false; 86 if( gettype($_POST['append']) == 'array' && count($_POST['append']) == 1 ) { 87 $wid = array_keys($_POST['append']); 88 $wid = $wid[0]; 89 } 90 91 # Append widgets 92 if (!empty($addw)) 93 { 94 if (!($widgets_nav instanceof dcWidgets)) { 95 $widgets_nav = new dcWidgets; 96 } 97 if (!($widgets_extra instanceof dcWidgets)) { 98 $widgets_extra = new dcWidgets(); 99 } 100 if (!($widgets_custom instanceof dcWidgets)) { 101 $widgets_custom = new dcWidgets(); 102 } 103 104 foreach ($addw as $k => $v) 105 { 106 if( !$wid || $wid == $k ) 107 { 108 switch ($v) { 109 case 'nav': 110 $widgets_nav->append($__widgets->{$k}); 111 break; 112 case 'extra': 113 $widgets_extra->append($__widgets->{$k}); 114 break; 115 case 'custom': 116 $widgets_custom->append($__widgets->{$k}); 117 break; 118 } 119 } 120 121 } 122 123 try { 124 $core->blog->settings->addNamespace('widgets'); 125 $core->blog->settings->widgets->put('widgets_nav',$widgets_nav->store()); 126 $core->blog->settings->widgets->put('widgets_extra',$widgets_extra->store()); 127 $core->blog->settings->widgets->put('widgets_custom',$widgets_custom->store()); 128 $core->blog->triggerBlog(); 129 http::redirect($p_url); 130 } catch (Exception $e) { 131 $core->error->add($e->getMessage()); 132 } 133 } 134 } 135 136 # Update sidebars 137 if (!empty($_POST['wup'])) 138 { 139 if (!isset($_POST['w']) || !is_array($_POST['w'])) { 140 $_POST['w'] = array(); 141 } 142 143 try 144 { 145 # Removing mark as _rem widgets 146 foreach ($_POST['w'] as $nsid => $nsw) { 147 foreach ($nsw as $i => $v) { 148 if (!empty($v['_rem'])) { 149 unset($_POST['w'][$nsid][$i]); 150 continue; 151 } 152 } 153 } 154 155 if (!isset($_POST['w']['nav'])) { 156 $_POST['w']['nav'] = array(); 157 } 158 if (!isset($_POST['w']['extra'])) { 159 $_POST['w']['extra'] = array(); 160 } 161 if (!isset($_POST['w']['custom'])) { 162 $_POST['w']['custom'] = array(); 163 } 164 165 $widgets_nav = dcWidgets::loadArray($_POST['w']['nav'],$__widgets); 166 $widgets_extra = dcWidgets::loadArray($_POST['w']['extra'],$__widgets); 167 $widgets_custom = dcWidgets::loadArray($_POST['w']['custom'],$__widgets); 168 169 $core->blog->settings->addNamespace('widgets'); 170 $core->blog->settings->widgets->put('widgets_nav',$widgets_nav->store()); 171 $core->blog->settings->widgets->put('widgets_extra',$widgets_extra->store()); 172 $core->blog->settings->widgets->put('widgets_custom',$widgets_custom->store()); 173 $core->blog->triggerBlog(); 174 175 http::redirect($p_url); 176 } 177 catch (Exception $e) 178 { 179 $core->error->add($e->getMessage()); 180 } 181 } 182 elseif (!empty($_POST['wreset'])) 183 { 184 try 185 { 186 $core->blog->settings->addNamespace('widgets'); 187 $core->blog->settings->widgets->put('widgets_nav',''); 188 $core->blog->settings->widgets->put('widgets_extra',''); 189 $core->blog->settings->widgets->put('widgets_custom',''); 190 $core->blog->triggerBlog(); 191 192 http::redirect($p_url); 193 } 194 catch (Exception $e) 195 { 196 $core->error->add($e->getMessage()); 197 } 198 } 199 /*?> 200 <html> 201 <head> 202 <title><?php echo __('Widgets'); ?></title> 203 <style type="text/css"> 204 <?php echo file_get_contents(dirname(__FILE__).'/style.css'); ?> 205 </style> 206 <?php 207 echo 208 dcPage::jsLoad('js/jquery/jquery-ui.custom.js'). 209 dcPage::jsLoad('index.php?pf=widgets/widgets.js'); 210 ?> 211 <?php 212 $core->auth->user_prefs->addWorkspace('accessibility'); 213 $user_dm_nodragdrop = $core->auth->user_prefs->accessibility->nodragdrop; 214 ?> 215 <?php if (!$user_dm_nodragdrop) : ?> 216 <script type="text/javascript" src="index.php?pf=widgets/dragdrop.js"></script> 217 <?php endif; ?> 218 <script type="text/javascript"> 219 //<![CDATA[ 220 <?php echo dcPage::jsVar('dotclear.msg.confirm_widgets_reset', 221 __('Are you sure you want to reset sidebars?')); ?> 222 //]]> 223 </script> 224 <?php echo(dcPage::jsConfirmClose('sidebarsWidgets')); ?> 225 </head> 226 <body> 227 <?php*/ 189 228 echo dcPage::breadcrumb( 190 229 array( … … 198 237 '<form id="listWidgets" action="'.$p_url.'" method="post" class="widgets">'. 199 238 '<h3>'.__('Available widgets').'</h3>'. 200 '<p>'.__(' Move widgets from this list to one of the sidebars.').'</p>'.239 '<p>'.__('Drag widgets from this list to one of the sidebars, for add.').'</p>'. 201 240 '<ul id="widgets-ref">'; 202 241 … … 208 247 ($w->desc() != '' ? ' <span class="form-note">'.__($w->desc()).'</span>' : '').'</p>'. 209 248 '<p class="manual-move remove-if-drag"><label class="classic">'.__('Append to:').'</label> '. 210 form::combo(array('addw['.$w->id().']'),$append_combo).'</p>'. 249 form::combo(array('addw['.$w->id().']'),$append_combo). 250 '<input type="submit" name="append['.$w->id().']" value="'.__('Add').'" /></p>'. 211 251 '<div class="widgetSettings hidden-if-drag">'.$w->formSettings('w[void][0]',$j).'</div>'. 212 252 '</li>'; … … 323 363 } 324 364 325 $res .= '<p class="empty-widgets" '.(!$widgets->isEmpty() ? 'style="display: none;"' : '').'>'.__('No widget.').'</p>';326 327 365 $res .= '<ul id="'.$id.'" class="connected">'; 366 367 $res .= '<li class="empty-widgets" '.(!$widgets->isEmpty() ? 'style="display: none;"' : '').'>'.__('No widget for now.').'</li>'; 328 368 329 369 $i = 0; … … 347 387 348 388 $res .= '</ul>'; 349 350 if ($i > 0) { 351 $res .= '<ul class="sortable-delete"><li class="sortable-delete-placeholder">'. 352 __('Drag widgets here to remove them from this sidebar.').'</li></ul>'; 353 } 389 390 $res .= '<ul class="sortable-delete"'.($i > 0 ? '':' style="display: none;"').'><li class="sortable-delete-placeholder">'. 391 __('Drag widgets here to remove.').'</li></ul>'; 354 392 355 393 return $res; -
plugins/widgets/index.php
r2395 r2398 229 229 array( 230 230 html::escapeHTML($core->blog->name) => '', 231 '<span class="page-title">'.__('Widgets').'</span>' => '' 232 )); 231 __('Widgets') => '' 232 )). 233 dcPage::notices(); 233 234 234 235 # All widgets
Note: See TracChangeset
for help on using the changeset viewer.