Changeset 3833:ea88f004549f for admin
- Timestamp:
- 08/30/18 16:26:16 (7 years ago)
- Branch:
- default
- Location:
- admin
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/index.php
r3781 r3833 115 115 if ($core->auth->user_prefs->dashboard->doclinks) { 116 116 if (!empty($__resources['doc'])) { 117 $doc_links = '<div class="box small dc-box" ><h3>' . __('Documentation and support') . '</h3><ul>';117 $doc_links = '<div class="box small dc-box" id="doc-and-support"><h3>' . __('Documentation and support') . '</h3><ul>'; 118 118 119 119 foreach ($__resources['doc'] as $k => $v) { … … 150 150 -------------------------------------------------------- */ 151 151 dcPage::open(__('Dashboard'), 152 dcPage::jsLoad('js/jquery/jquery-ui.custom.js') . 153 dcPage::jsLoad('js/jquery/jquery.ui.touch-punch.js') . 152 154 dcPage::jsLoad('js/_index.js') . 153 155 $admin_post_behavior . … … 244 246 } 245 247 246 # Dashboard items and contents (processed first, as we need to know the result before displaying the icons.) 247 $dashboardItems = ''; 248 foreach ($__dashboard_items as $i) { 249 foreach ($i as $v) { 250 $dashboardItems .= $v; 251 } 252 } 253 $dashboardContents = ''; 254 foreach ($__dashboard_contents as $i) { 255 foreach ($i as $v) { 256 $dashboardContents .= $v; 257 } 258 } 259 260 # Dashboard elements: icons then boxes (items then contents) 261 echo '<div id="dashboard-main">'; 262 248 # Get current main orders 249 $main_order = $core->auth->user_prefs->dashboard->main_order; 250 $main_order = ($main_order != '' ? explode(',', $main_order) : array()); 251 252 # Get current boxes orders 253 $boxes_order = $core->auth->user_prefs->dashboard->boxes_order; 254 $boxes_order = ($boxes_order != '' ? explode(',', $boxes_order) : array()); 255 256 # Get current boxes items orders 257 $boxes_items_order = $core->auth->user_prefs->dashboard->boxes_items_order; 258 $boxes_items_order = ($boxes_items_order != '' ? explode(',', $boxes_items_order) : array()); 259 260 # Get current boxes contents orders 261 $boxes_contents_order = $core->auth->user_prefs->dashboard->boxes_contents_order; 262 $boxes_contents_order = ($boxes_contents_order != '' ? explode(',', $boxes_contents_order) : array()); 263 264 $composeItems = function ($list, $blocks, $flat = false) { 265 266 $ret = array(); 267 $items = array(); 268 269 if ($flat) { 270 $items = $blocks; 271 } else { 272 foreach ($blocks as $i) { 273 foreach ($i as $v) { 274 $items[] = $v; 275 } 276 } 277 } 278 279 # First loop to find ordered indexes 280 $order = array(); 281 $index = 0; 282 foreach ($items as $v) { 283 if (preg_match('/<div.*?id="([^"].*?)".*?>/ms', $v, $match)) { 284 $id = $match[1]; 285 $position = array_search($id, $list, true); 286 if ($position !== false) { 287 $order[$position] = $index; 288 } 289 } 290 $index++; 291 } 292 293 # Second loop to combine ordered items 294 $index = 0; 295 foreach ($items as $v) { 296 $position = array_search($index, $order, true); 297 if ($position !== false) { 298 $ret[$position] = $v; 299 } 300 $index++; 301 } 302 # Reorder items on their position (key) 303 ksort($ret); 304 305 # Third loop to combine unordered items 306 $index = 0; 307 foreach ($items as $v) { 308 $position = array_search($index, $order, true); 309 if ($position === false) { 310 $ret[count($ret)] = $v; 311 } 312 $index++; 313 } 314 315 return join('', $ret); 316 }; 317 318 # Compose dashboard items (doc, …) 319 $dashboardItems = $composeItems($boxes_items_order, $__dashboard_items); 320 # Compose dashboard contents (plugin's modules) 321 $dashboardContents = $composeItems($boxes_contents_order, $__dashboard_contents); 322 323 $__dashboard_boxes = array(); 324 if ($dashboardItems != '') { 325 $__dashboard_boxes[] = '<div class="db-items" id="db-items">' . $dashboardItems . '</div>'; 326 } 327 if ($dashboardContents != '') { 328 $__dashboard_boxes[] = '<div class="db-contents" id="db-contents">' . $dashboardContents . '</div>'; 329 } 330 $dashboardBoxes = $composeItems($boxes_order, $__dashboard_boxes, true); 331 332 # Compose main area 333 $__dashboard_main = array(); 263 334 if (!$core->auth->user_prefs->dashboard->nofavicons) { 264 335 # Dashboard icons 265 echo'<div id="icons">';336 $dashboardIcons = '<div id="icons">'; 266 337 foreach ($__dashboard_icons as $i) { 267 echo 268 '<p><a href="' . $i[1] . '"><img src="' . dc_admin_icon_url($i[2]) . '" alt="" />' . 338 $dashboardIcons .= '<p><a href="' . $i[1] . '"><img src="' . dc_admin_icon_url($i[2]) . '" alt="" />' . 269 339 '<br /><span class="db-icon-title">' . $i[0] . '</span></a></p>'; 270 340 } 271 echo'</div>';272 } 273 341 $dashboardIcons .= '</div>'; 342 $__dashboard_main[] = $dashboardIcons; 343 } 274 344 if ($core->auth->user_prefs->dashboard->quickentry) { 275 345 if ($core->auth->check('usage,contentadmin', $core->blog->id)) { … … 279 349 ); 280 350 281 echo351 $dashboardQuickEntry = 282 352 '<div id="quick">' . 283 353 '<h3>' . __('Quick entry') . sprintf(' › %s', $core->auth->getOption('post_format')) . '</h3>' . … … 320 390 '</form>' . 321 391 '</div>'; 322 } 323 } 324 325 if ($dashboardContents != '' || $dashboardItems != '') { 326 echo 327 '<div id="dashboard-boxes">' . 328 ($dashboardItems != '' ? '<div class="db-items">' . $dashboardItems . '</div>' : '') . 329 ($dashboardContents != '' ? '<div class="db-contents">' . $dashboardContents . '</div>' : '') . 330 '</div>'; 331 } 332 333 echo '</div>'; #end dashboard-main 392 $__dashboard_main[] = $dashboardQuickEntry; 393 } 394 } 395 if ($dashboardBoxes != '') { 396 $__dashboard_main[] = '<div id="dashboard-boxes">' . $dashboardBoxes . '</div>'; 397 } 398 $dashboardMain = $composeItems($main_order, $__dashboard_main, true); 399 400 # Dashboard elements 401 echo '<div id="dashboard-main">' . $dashboardMain . '</div>'; 402 334 403 dcPage::helpBlock('core_dashboard'); 335 404 dcPage::close(); -
admin/js/_index.js
r3820 r3833 199 199 } 200 200 // Posts 201 var icon_ com= $('#dashboard-main #icons p a[href="posts.php"]');202 if (icon_ com.length) {201 var icon_post = $('#dashboard-main #icons p a[href="posts.php"]'); 202 if (icon_post.length) { 203 203 // Icon exists on dashboard 204 204 // First pass … … 207 207 dotclear.dbPostsCount_Timer = setInterval(dotclear.dbCommentsPost, 600 * 1000); 208 208 } 209 210 // Dashboard boxes and their children are sortable 211 var set_positions = function(sel, id) { 212 var list = $(sel).sortable("toArray").join(); 213 // Save positions (via services) for id 214 var params = { 215 f: 'setDashboardPositions', 216 xd_check: dotclear.nonce, 217 id: id, 218 list: list 219 }; 220 $.post('services.php', params, function() {}); 221 }; 222 // Wait 5 seconds before activating ordering capabilities on dashboard 223 setTimeout(function() { 224 $('#dashboard-main').sortable({ 225 cursor: 'move', 226 opacity: 0.5, 227 tolerance: "pointer", 228 update: function() { 229 set_positions(this, 'main_order'); 230 } 231 }); 232 $('#dashboard-boxes').sortable({ 233 cursor: 'move', 234 opacity: 0.5, 235 tolerance: "pointer", 236 update: function() { 237 set_positions(this, 'boxes_order'); 238 } 239 }); 240 $('#db-items').sortable({ 241 cursor: 'move', 242 opacity: 0.5, 243 tolerance: "pointer", 244 update: function() { 245 set_positions(this, 'boxes_items_order'); 246 } 247 }); 248 $('#db-contents').sortable({ 249 cursor: 'move', 250 opacity: 0.5, 251 tolerance: "pointer", 252 update: function() { 253 set_positions(this, 'boxes_contents_order'); 254 } 255 }); 256 }, 5000); 257 209 258 }); -
admin/services.php
r3819 r3833 25 25 $core->rest->addFunction('setSectionFold', array('dcRestMethods', 'setSectionFold')); 26 26 $core->rest->addFunction('getModuleById', array('dcRestMethods', 'getModuleById')); 27 $core->rest->addFunction('setDashboardPositions', array('dcRestMethods', 'setDashboardPositions')); 27 28 28 29 $core->rest->serve(); … … 566 567 } 567 568 569 public static function setDashboardPositions($core, $get, $post) 570 { 571 if (empty($post['id'])) { 572 throw new Exception('No zone name'); 573 } 574 if (empty($post['list'])) { 575 throw new Exception('No sorted list of id'); 576 } 577 578 if ($core->auth->user_prefs->dashboard === null) { 579 $core->auth->user_prefs->addWorkspace('dashboard'); 580 } 581 582 $zone = $post['id']; 583 $order = $post['list']; 584 585 $core->auth->user_prefs->dashboard->put($zone, $order); 586 return true; 587 } 588 568 589 public static function getModuleById($core, $get, $post) 569 590 {
Note: See TracChangeset
for help on using the changeset viewer.