Changeset 2230:e63e48e1c53b for inc
- Timestamp:
- 10/03/13 16:00:46 (12 years ago)
- Branch:
- default
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
inc/admin/class.dc.favorites.php
r2229 r2230 78 78 public function setup() { 79 79 $this->legacyFavorites(); 80 $this->core->callBehavior('adminDashboardFavorites', $this->core, $this); 80 81 $this->setUserPrefs(); 81 82 } … … 151 152 $this->user_prefs = $this->getFavorites(array('new_post')); 152 153 } 153 154 $u = explode('?',$_SERVER['REQUEST_URI']); 154 155 // Loop over prefs to enable active favorites 155 156 foreach ($this->user_prefs as $k=>&$v) { 156 157 if (isset($v['active_cb']) && is_callable($v['active_cb'])) { 157 158 // Use callback if defined to match whether favorite is active or not 158 $v['active'] = call_user_func($v['active_cb'],$ _SERVER['REQUEST_URI'],$_REQUEST);159 $v['active'] = call_user_func($v['active_cb'],$u[0],$_REQUEST); 159 160 } else { 160 161 // Failback active detection. We test against URI name & parameters … … 324 325 public function appendDashboardIcons($icons) { 325 326 foreach ($this->user_prefs as $k=>$v) { 326 if (isset($v['title_cb']) && is_callable($v['title_cb'])) { 327 $title = call_user_func($v['title_cb'],$this->core); 328 } else { 329 $title = $v['title']; 330 } 331 $icons[$k]=new ArrayObject(array($title,$v['url'],$v['large-icon'])); 327 if (isset($v['dashboard_cb']) && is_callable($v['dashboard_cb'])) { 328 $v = new ArrayObject($v); 329 call_user_func($v['dashboard_cb'],$this->core,$v); 330 } 331 $icons[$k]=new ArrayObject(array($v['title'],$v['url'],$v['large-icon'])); 332 332 $this->core->callBehavior('adminDashboardFavsIcon',$this->core,$k,$icons[$k]); 333 333 } … … 344 344 * 'large-icon' => favorite large icon (for dashboard) 345 345 * 'permissions' => (optional) comma-separated list of permissions for thie fav, if not set : no restriction 346 * ' title_cb' => (optional) callback to modify title if dynamic, if not set : title is taken as is346 * 'dashboard_cb' => (optional) callback to modify title if dynamic, if not set : title is taken as is 347 347 * 'active_cb' => (optional) callback to tell whether current page matches favorite or not, for complex pages 348 348 * … … 410 410 'large-icon' => 'images/menu/entries-b.png', 411 411 'permissions' => 'usage,contentadmin', 412 ' title_cb' => array('defaultFavorites','postsTitle')),412 'dashboard_cb' => array('defaultFavorites','postsDashboard')), 413 413 'comments' => array( 414 414 'title' => __('Comments'), … … 417 417 'large-icon' => 'images/menu/comments-b.png', 418 418 'permissions' => 'usage,contentadmin', 419 ' title_cb' => array('defaultFavorites','commentsTitle')),419 'dashboard_cb' => array('defaultFavorites','commentsDashboard')), 420 420 'search' => array( 421 421 'title' => __('Search'), … … 477 477 } 478 478 479 public static function posts Title($core) {479 public static function postsDashboard($core,$v) { 480 480 $post_count = $core->blog->getPosts(array(),true)->f(0); 481 481 $str_entries = __('%d entry', '%d entries',$post_count); 482 returnsprintf($str_entries,$post_count);483 } 484 485 public static function comments Title($core) {482 $v['title'] = sprintf($str_entries,$post_count); 483 } 484 485 public static function commentsDashboard($core,$v) { 486 486 $comment_count = $core->blog->getComments(array(),true)->f(0); 487 487 $str_comments = __('%d comments', '%d comments',$comment_count); 488 returnsprintf($str_comments,$comment_count);488 $v['title']= sprintf($str_comments,$comment_count); 489 489 } 490 490
Note: See TracChangeset
for help on using the changeset viewer.