Dotclear

Changeset 2230:e63e48e1c53b for inc


Ignore:
Timestamp:
10/03/13 16:00:46 (12 years ago)
Author:
Dsls
Branch:
default
Message:
  • New adminDashboardFavorites behavior introduced, adapted several plugins to it
  • Added ability to move the whole favorite with title_cb, now renamed dashboard_cb
  • new pages and pages shortcuts are now functional, closes #1727
  • Moved preferences.php to new notifications system
File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/admin/class.dc.favorites.php

    r2229 r2230  
    7878      public function setup() { 
    7979          $this->legacyFavorites(); 
     80          $this->core->callBehavior('adminDashboardFavorites', $this->core, $this); 
    8081          $this->setUserPrefs(); 
    8182     } 
     
    151152               $this->user_prefs = $this->getFavorites(array('new_post')); 
    152153          } 
    153  
     154          $u = explode('?',$_SERVER['REQUEST_URI']); 
    154155          // Loop over prefs to enable active favorites 
    155156          foreach ($this->user_prefs as $k=>&$v) { 
    156157               if (isset($v['active_cb']) && is_callable($v['active_cb'])) { 
    157158                    // 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); 
    159160               } else { 
    160161                    // Failback active detection. We test against URI name & parameters 
     
    324325     public function appendDashboardIcons($icons) { 
    325326          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'])); 
    332332               $this->core->callBehavior('adminDashboardFavsIcon',$this->core,$k,$icons[$k]); 
    333333          }          
     
    344344      *   'large-icon' => favorite large icon (for dashboard) 
    345345      *   '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 is 
     346      *   'dashboard_cb' => (optional) callback to modify title if dynamic, if not set : title is taken as is 
    347347      *   'active_cb' => (optional) callback to tell whether current page matches favorite or not, for complex pages 
    348348      * 
     
    410410                    'large-icon' => 'images/menu/entries-b.png', 
    411411                    'permissions' => 'usage,contentadmin', 
    412                     'title_cb' => array('defaultFavorites','postsTitle')), 
     412                    'dashboard_cb' => array('defaultFavorites','postsDashboard')), 
    413413               'comments' => array( 
    414414                    'title' => __('Comments'), 
     
    417417                    'large-icon' => 'images/menu/comments-b.png', 
    418418                    'permissions' => 'usage,contentadmin', 
    419                     'title_cb' => array('defaultFavorites','commentsTitle')), 
     419                    'dashboard_cb' => array('defaultFavorites','commentsDashboard')), 
    420420               'search' => array( 
    421421                    'title' => __('Search'), 
     
    477477     } 
    478478      
    479      public static function postsTitle($core) { 
     479     public static function postsDashboard($core,$v) { 
    480480          $post_count = $core->blog->getPosts(array(),true)->f(0); 
    481481          $str_entries = __('%d entry', '%d entries',$post_count); 
    482           return sprintf($str_entries,$post_count); 
    483      } 
    484       
    485      public static function commentsTitle($core) { 
     482          $v['title'] = sprintf($str_entries,$post_count); 
     483     } 
     484      
     485     public static function commentsDashboard($core,$v) { 
    486486          $comment_count = $core->blog->getComments(array(),true)->f(0); 
    487487          $str_comments = __('%d comments', '%d comments',$comment_count); 
    488           return sprintf($str_comments,$comment_count); 
     488          $v['title']= sprintf($str_comments,$comment_count); 
    489489     } 
    490490 
Note: See TracChangeset for help on using the changeset viewer.

Sites map