[2229] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
| 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
| 7 | # Licensed under the GPL version 2.0 license. |
---|
| 8 | # See LICENSE file or |
---|
| 9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
---|
| 10 | # |
---|
| 11 | # -- END LICENSE BLOCK ----------------------------------------- |
---|
| 12 | if (!defined('DC_RC_PATH')) { return; } |
---|
| 13 | |
---|
| 14 | /** |
---|
| 15 | * dcFavorites -- Favorites handling facilities |
---|
| 16 | * |
---|
| 17 | */ |
---|
| 18 | class dcFavorites |
---|
| 19 | { |
---|
| 20 | /** @var dcCore dotclear core instance */ |
---|
| 21 | protected $core; |
---|
[2566] | 22 | |
---|
[2229] | 23 | /** @var array list of favorite definitions */ |
---|
| 24 | protected $fav_defs; |
---|
[2566] | 25 | |
---|
[2229] | 26 | /** @var dcWorkspace current favorite landing workspace */ |
---|
| 27 | protected $ws; |
---|
[2566] | 28 | |
---|
[2229] | 29 | /** @var array list of user-defined favorite ids */ |
---|
| 30 | protected $local_prefs; |
---|
| 31 | |
---|
| 32 | /** @var array list of globally-defined favorite ids */ |
---|
| 33 | protected $global_prefs; |
---|
[2566] | 34 | |
---|
| 35 | /** @var array list of user preferences (either one of the 2 above, or not!) */ |
---|
[2229] | 36 | protected $user_prefs; |
---|
[2566] | 37 | |
---|
[2229] | 38 | /** |
---|
| 39 | * Class constructor |
---|
[2566] | 40 | * |
---|
[2229] | 41 | * @param mixed $core dotclear core |
---|
| 42 | * |
---|
| 43 | * @access public |
---|
| 44 | * |
---|
| 45 | * @return mixed Value. |
---|
| 46 | */ |
---|
| 47 | public function __construct($core) { |
---|
| 48 | $this->core = $core; |
---|
| 49 | $this->fav_defs = new ArrayObject(); |
---|
| 50 | $this->ws = $core->auth->user_prefs->addWorkspace('dashboard'); |
---|
| 51 | $this->user_prefs = array(); |
---|
[2566] | 52 | |
---|
[2229] | 53 | if ($this->ws->prefExists('favorites')) { |
---|
[3161] | 54 | $this->local_prefs = $this->ws->getLocal('favorites'); |
---|
| 55 | $this->global_prefs = $this->ws->getGlobal('favorites'); |
---|
[2229] | 56 | // Since we never know what user puts through user:preferences ... |
---|
| 57 | if (!is_array($this->local_prefs)) { |
---|
| 58 | $this->local_prefs = array(); |
---|
| 59 | } |
---|
| 60 | if (!is_array($this->global_prefs)) { |
---|
| 61 | $this->global_prefs = array(); |
---|
| 62 | } |
---|
| 63 | } else { |
---|
| 64 | // No favorite defined ? Huhu, let's go for a migration |
---|
| 65 | $this->migrateFavorites(); |
---|
[2566] | 66 | } |
---|
[2229] | 67 | } |
---|
[2566] | 68 | |
---|
| 69 | |
---|
[2229] | 70 | /** |
---|
| 71 | * setup - sets up favorites, fetch user favorites (against his permissions) |
---|
| 72 | * This method is to be called after loading plugins |
---|
| 73 | * |
---|
| 74 | * @access public |
---|
| 75 | * |
---|
| 76 | */ |
---|
| 77 | public function setup() { |
---|
[2725] | 78 | defaultFavorites::initDefaultFavorites($this); |
---|
[2229] | 79 | $this->legacyFavorites(); |
---|
[2230] | 80 | $this->core->callBehavior('adminDashboardFavorites', $this->core, $this); |
---|
[2229] | 81 | $this->setUserPrefs(); |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | /** |
---|
| 85 | * getFavorite - retrieves a favorite (complete description) from its id. |
---|
[2566] | 86 | * |
---|
[2229] | 87 | * @param string $id the favorite id, or an array having 1 key 'name' set to id, ther keys are merged to favorite. |
---|
| 88 | * |
---|
| 89 | * @access public |
---|
| 90 | * |
---|
| 91 | * @return array the favorite, false if not found (or not permitted) |
---|
| 92 | */ |
---|
| 93 | public function getFavorite($p) { |
---|
| 94 | if (is_array($p)) { |
---|
| 95 | $fname=$p['name']; |
---|
| 96 | if (!isset($this->fav_defs[$fname])) { |
---|
| 97 | return false; |
---|
| 98 | } |
---|
| 99 | $fattr = $p; |
---|
| 100 | unset($fattr['name']); |
---|
| 101 | $fattr = array_merge($this->fav_defs[$fname],$fattr); |
---|
| 102 | } else { |
---|
| 103 | if (!isset($this->fav_defs[$p])) { |
---|
| 104 | return false; |
---|
| 105 | } |
---|
| 106 | $fattr = $this->fav_defs[$p]; |
---|
| 107 | } |
---|
[3161] | 108 | $fattr = array_merge(array('id' => null,'class' => null),$fattr); |
---|
[2234] | 109 | if (isset($fattr['permissions'])) { |
---|
| 110 | if (is_bool($fattr['permissions']) && !$fattr['permissions'] ) { |
---|
| 111 | return false; |
---|
| 112 | } |
---|
| 113 | if (!$this->core->auth->check($fattr['permissions'],$this->core->blog->id)) { |
---|
| 114 | return false; |
---|
| 115 | } |
---|
[2229] | 116 | } |
---|
[2234] | 117 | return $fattr; |
---|
[2229] | 118 | } |
---|
[2566] | 119 | |
---|
[2229] | 120 | /** |
---|
| 121 | * getFavorites - retrieves a list of favorites. |
---|
[2566] | 122 | * |
---|
[2229] | 123 | * @param string $ids an array of ids, as defined in getFavorite. |
---|
| 124 | * |
---|
| 125 | * @access public |
---|
| 126 | * |
---|
| 127 | * @return array array of favorites, can be empty if ids are not found (or not permitted) |
---|
| 128 | */ |
---|
| 129 | public function getFavorites($ids) { |
---|
| 130 | $prefs = array(); |
---|
| 131 | foreach ($ids as $id) { |
---|
| 132 | $f = $this->getFavorite($id); |
---|
| 133 | if ($f !== false) { |
---|
| 134 | $prefs[$id]=$f; |
---|
| 135 | } |
---|
| 136 | } |
---|
| 137 | return $prefs; |
---|
| 138 | } |
---|
[2566] | 139 | |
---|
[2229] | 140 | /** |
---|
| 141 | * setUserPrefs - get user favorites from settings. These are complete favorites, not ids only |
---|
| 142 | * returned favorites are the first non-empty list from : |
---|
| 143 | * * user-defined favorites |
---|
| 144 | * * globally-defined favorites |
---|
| 145 | * * a failback list "new post" (shall never be empty) |
---|
| 146 | * This method is called by ::setup() |
---|
| 147 | * @access protected |
---|
| 148 | * |
---|
| 149 | */ |
---|
| 150 | protected function setUserPrefs() { |
---|
| 151 | $this->user_prefs = $this->getFavorites($this->local_prefs); |
---|
| 152 | if (!count($this->user_prefs)) { |
---|
| 153 | $this->user_prefs = $this->getFavorites($this->global_prefs); |
---|
| 154 | } |
---|
| 155 | if (!count($this->user_prefs)) { |
---|
| 156 | $this->user_prefs = $this->getFavorites(array('new_post')); |
---|
| 157 | } |
---|
[2230] | 158 | $u = explode('?',$_SERVER['REQUEST_URI']); |
---|
[2229] | 159 | // Loop over prefs to enable active favorites |
---|
[3161] | 160 | foreach ($this->user_prefs as $k => &$v) { |
---|
[2229] | 161 | if (isset($v['active_cb']) && is_callable($v['active_cb'])) { |
---|
| 162 | // Use callback if defined to match whether favorite is active or not |
---|
[2230] | 163 | $v['active'] = call_user_func($v['active_cb'],$u[0],$_REQUEST); |
---|
[2229] | 164 | } else { |
---|
| 165 | // Failback active detection. We test against URI name & parameters |
---|
[3161] | 166 | $v['active'] = true; // true until something proves it is false |
---|
[2229] | 167 | $u = explode('?',$v['url'],2); |
---|
| 168 | if (!preg_match('/'.preg_quote($u[0],"/").'/',$_SERVER['REQUEST_URI'])) { |
---|
| 169 | $v['active'] = false; // no URI match |
---|
| 170 | } |
---|
| 171 | if (count($u) == 2) { |
---|
| 172 | parse_str($u[1],$p); |
---|
| 173 | // test against each request parameter. |
---|
| 174 | foreach ($p as $k2 => $v2) { |
---|
| 175 | if (!isset($_REQUEST[$k2]) || $_REQUEST[$k2] !== $v2) { |
---|
| 176 | $v['active'] = false; |
---|
| 177 | } |
---|
| 178 | } |
---|
| 179 | } |
---|
| 180 | } |
---|
| 181 | } |
---|
[2566] | 182 | |
---|
[2229] | 183 | } |
---|
[2566] | 184 | |
---|
[2229] | 185 | /** |
---|
| 186 | * migrateFavorites - migrate dc < 2.6 favorites to new format |
---|
| 187 | * |
---|
| 188 | * @access protected |
---|
| 189 | * |
---|
| 190 | */ |
---|
| 191 | protected function migrateFavorites() { |
---|
| 192 | $fav_ws = $this->core->auth->user_prefs->addWorkspace('favorites'); |
---|
| 193 | $this->local_prefs=array(); |
---|
| 194 | $this->global_prefs=array(); |
---|
| 195 | foreach ($fav_ws->dumpPrefs() as $k => $v) { |
---|
| 196 | $fav = @unserialize($v['value']); |
---|
| 197 | if (is_array($fav)) { |
---|
| 198 | if ($v['global']) { |
---|
| 199 | $this->global_prefs[] = $fav['name']; |
---|
| 200 | } else { |
---|
| 201 | $this->local_prefs[] = $fav['name']; |
---|
| 202 | } |
---|
| 203 | } |
---|
| 204 | } |
---|
[3161] | 205 | $this->ws->put('favorites',$this->global_prefs,'array','User favorites',true,true); |
---|
| 206 | $this->ws->put('favorites',$this->local_prefs); |
---|
[2229] | 207 | $this->user_prefs = $this->getFavorites($this->local_prefs); |
---|
| 208 | } |
---|
| 209 | |
---|
[2566] | 210 | |
---|
| 211 | |
---|
[2229] | 212 | /** |
---|
| 213 | * legacyFavorites - handle legacy favorites using adminDashboardFavs behavior |
---|
| 214 | * |
---|
| 215 | * @access protected |
---|
| 216 | * |
---|
| 217 | */ |
---|
| 218 | protected function legacyFavorites() { |
---|
| 219 | $f = new ArrayObject(); |
---|
| 220 | $this->core->callBehavior('adminDashboardFavs', $this->core, $f); |
---|
| 221 | foreach ($f as $k => $v) { |
---|
| 222 | $fav = array ( |
---|
| 223 | 'title' => __($v[1]), |
---|
| 224 | 'url' => $v[2], |
---|
| 225 | 'small-icon' => $v[3], |
---|
| 226 | 'large-icon' => $v[4], |
---|
[2276] | 227 | 'permissions' => $v[5], |
---|
| 228 | 'id' => $v[6], |
---|
| 229 | 'class' => $v[7] |
---|
[2229] | 230 | ); |
---|
| 231 | $this->register ($v[0], $fav); |
---|
| 232 | } |
---|
[2566] | 233 | |
---|
[2229] | 234 | } |
---|
[2566] | 235 | |
---|
[2229] | 236 | /** |
---|
| 237 | * getUserFavorites - returns favorites that correspond to current user |
---|
| 238 | * (may be local, global, or failback favorites) |
---|
| 239 | * |
---|
| 240 | * @access public |
---|
| 241 | * |
---|
| 242 | * @return array array of favorites (enriched) |
---|
| 243 | */ |
---|
| 244 | public function getUserFavorites() { |
---|
| 245 | return $this->user_prefs; |
---|
| 246 | } |
---|
[2566] | 247 | |
---|
[2229] | 248 | |
---|
| 249 | /** |
---|
| 250 | * getFavoriteIDs - returns user-defined or global favorites ids list |
---|
| 251 | * shall not be called outside preferences.php... |
---|
| 252 | * |
---|
| 253 | * @param boolean $global if true, retrieve global favs, user favs otherwise |
---|
| 254 | * |
---|
| 255 | * @access public |
---|
| 256 | * |
---|
| 257 | * @return array array of favorites ids (only ids, not enriched) |
---|
| 258 | */ |
---|
| 259 | public function getFavoriteIDs ($global=false) { |
---|
| 260 | return $global?$this->global_prefs:$this->local_prefs; |
---|
| 261 | } |
---|
| 262 | |
---|
| 263 | /** |
---|
| 264 | * setFavoriteIDs - stores user-defined or global favorites ids list |
---|
| 265 | * shall not be called outside preferences.php... |
---|
| 266 | * |
---|
| 267 | * @param array $ids list of fav ids |
---|
| 268 | * @param boolean $global if true, retrieve global favs, user favs otherwise |
---|
| 269 | * |
---|
| 270 | * @access public |
---|
| 271 | */ |
---|
| 272 | public function setFavoriteIDs($ids,$global=false) { |
---|
[3201] | 273 | $this->ws->put('favorites',$ids,'array',null,true,$global); |
---|
[2229] | 274 | } |
---|
[2566] | 275 | |
---|
[2229] | 276 | /** |
---|
| 277 | * getAvailableFavoritesIDs - returns all available fav ids |
---|
| 278 | * |
---|
| 279 | * @access public |
---|
| 280 | * |
---|
| 281 | * @return array array of favorites ids (only ids, not enriched) |
---|
| 282 | */ |
---|
| 283 | public function getAvailableFavoritesIDs () { |
---|
| 284 | return array_keys($this->fav_defs->getArrayCopy()); |
---|
| 285 | } |
---|
| 286 | |
---|
| 287 | /** |
---|
| 288 | * appendMenuTitle - adds favorites section title to sidebar menu |
---|
| 289 | * shall not be called outside admin/prepend.php... |
---|
| 290 | * |
---|
| 291 | * @param dcMenu $menu admin menu instance |
---|
| 292 | * |
---|
| 293 | * @access public |
---|
| 294 | */ |
---|
| 295 | public function appendMenuTitle($menu) { |
---|
| 296 | $menu['Favorites'] = new dcMenu('favorites-menu','My favorites'); |
---|
| 297 | $menu['Favorites']->title = __('My favorites'); |
---|
| 298 | } |
---|
| 299 | |
---|
| 300 | /** |
---|
| 301 | * appendMenu - adds favorites items title to sidebar menu |
---|
| 302 | * shall not be called outside admin/prepend.php... |
---|
| 303 | * |
---|
| 304 | * @param dcMenu $menu admin menu instance |
---|
| 305 | * |
---|
| 306 | * @access public |
---|
| 307 | */ |
---|
| 308 | public function appendMenu($menu) { |
---|
[3161] | 309 | foreach ($this->user_prefs as $k => $v) { |
---|
[2229] | 310 | $menu['Favorites']->addItem( |
---|
| 311 | $v['title'], |
---|
| 312 | $v['url'], |
---|
| 313 | $v['small-icon'], |
---|
| 314 | $v['active'], |
---|
| 315 | true, |
---|
| 316 | $v['id'], |
---|
[3075] | 317 | $v['class'], |
---|
| 318 | true |
---|
[2229] | 319 | ); |
---|
| 320 | } |
---|
| 321 | } |
---|
[2566] | 322 | |
---|
[2229] | 323 | /** |
---|
| 324 | * appendDashboardIcons - adds favorites icons to index page |
---|
| 325 | * shall not be called outside admin/index.php... |
---|
| 326 | * |
---|
| 327 | * @param array $icons dashboard icon list to enrich |
---|
| 328 | * |
---|
| 329 | * @access public |
---|
| 330 | */ |
---|
| 331 | public function appendDashboardIcons($icons) { |
---|
[3161] | 332 | foreach ($this->user_prefs as $k => $v) { |
---|
[2230] | 333 | if (isset($v['dashboard_cb']) && is_callable($v['dashboard_cb'])) { |
---|
| 334 | $v = new ArrayObject($v); |
---|
| 335 | call_user_func($v['dashboard_cb'],$this->core,$v); |
---|
[2229] | 336 | } |
---|
[2230] | 337 | $icons[$k]=new ArrayObject(array($v['title'],$v['url'],$v['large-icon'])); |
---|
[2229] | 338 | $this->core->callBehavior('adminDashboardFavsIcon',$this->core,$k,$icons[$k]); |
---|
[2566] | 339 | } |
---|
[2229] | 340 | } |
---|
[2566] | 341 | |
---|
[2229] | 342 | /** |
---|
| 343 | * register - registers a new favorite definition |
---|
| 344 | * |
---|
| 345 | * @param string $id favorite id |
---|
| 346 | * @param array $data favorite information. Array keys are : |
---|
| 347 | * 'title' => favorite title (localized) |
---|
| 348 | * 'url' => favorite URL, |
---|
| 349 | * 'small-icon' => favorite small icon (for menu) |
---|
| 350 | * 'large-icon' => favorite large icon (for dashboard) |
---|
| 351 | * 'permissions' => (optional) comma-separated list of permissions for thie fav, if not set : no restriction |
---|
[2230] | 352 | * 'dashboard_cb' => (optional) callback to modify title if dynamic, if not set : title is taken as is |
---|
[2229] | 353 | * 'active_cb' => (optional) callback to tell whether current page matches favorite or not, for complex pages |
---|
| 354 | * |
---|
| 355 | * @access public |
---|
| 356 | */ |
---|
| 357 | public function register($id,$data) { |
---|
| 358 | $this->fav_defs[$id] = $data; |
---|
| 359 | return $this; |
---|
| 360 | } |
---|
[2566] | 361 | |
---|
[2229] | 362 | /** |
---|
| 363 | * registerMultiple - registers a list of favorites definition |
---|
| 364 | * |
---|
[2566] | 365 | * @param array an array defining all favorites key is the id, value is the data. |
---|
[2229] | 366 | * see register method for data format |
---|
| 367 | * @access public |
---|
[2566] | 368 | */ |
---|
[2229] | 369 | public function registerMultiple($data) { |
---|
[3161] | 370 | foreach ($data as $k => $v) { |
---|
[2229] | 371 | $this->register($k,$v); |
---|
| 372 | } |
---|
| 373 | return $this; |
---|
| 374 | } |
---|
[2566] | 375 | |
---|
[2229] | 376 | /** |
---|
| 377 | * exists - tells whether a fav definition exists or not |
---|
| 378 | * |
---|
| 379 | * @param string $id : the fav id to test |
---|
| 380 | * |
---|
| 381 | * @access public |
---|
| 382 | * |
---|
| 383 | * @return true if the fav definition exists, false otherwise |
---|
[2566] | 384 | */ |
---|
[2229] | 385 | public function exists($id) { |
---|
| 386 | return isset($this->fav_defs[$id]); |
---|
| 387 | } |
---|
[2566] | 388 | |
---|
[2229] | 389 | } |
---|
| 390 | |
---|
| 391 | |
---|
| 392 | /** |
---|
| 393 | * defaultFavorites -- default favorites definition |
---|
| 394 | * |
---|
| 395 | */ |
---|
| 396 | class defaultFavorites |
---|
| 397 | { |
---|
| 398 | public static function initDefaultFavorites($favs) { |
---|
[2720] | 399 | $core =& $GLOBALS['core']; |
---|
[2229] | 400 | $favs->registerMultiple(array( |
---|
[2302] | 401 | 'prefs' => array( |
---|
| 402 | 'title' => __('My preferences'), |
---|
[2720] | 403 | 'url' => $core->adminurl->get("admin.user.preferences"), |
---|
[2302] | 404 | 'small-icon' => 'images/menu/user-pref.png', |
---|
| 405 | 'large-icon' => 'images/menu/user-pref-b.png'), |
---|
| 406 | 'new_post' => array( |
---|
| 407 | 'title' => __('New entry'), |
---|
[2720] | 408 | 'url' => $core->adminurl->get("admin.post"), |
---|
[2302] | 409 | 'small-icon' => 'images/menu/edit.png', |
---|
| 410 | 'large-icon' => 'images/menu/edit-b.png', |
---|
| 411 | 'permissions' =>'usage,contentadmin'), |
---|
[2229] | 412 | 'posts' => array( |
---|
[3394] | 413 | 'title' => __('Posts'), |
---|
[2720] | 414 | 'url' => $core->adminurl->get("admin.posts"), |
---|
[2229] | 415 | 'small-icon' => 'images/menu/entries.png', |
---|
| 416 | 'large-icon' => 'images/menu/entries-b.png', |
---|
| 417 | 'permissions' => 'usage,contentadmin', |
---|
[2230] | 418 | 'dashboard_cb' => array('defaultFavorites','postsDashboard')), |
---|
[2229] | 419 | 'comments' => array( |
---|
| 420 | 'title' => __('Comments'), |
---|
[2720] | 421 | 'url' => $core->adminurl->get("admin.comments"), |
---|
[2229] | 422 | 'small-icon' => 'images/menu/comments.png', |
---|
| 423 | 'large-icon' => 'images/menu/comments-b.png', |
---|
| 424 | 'permissions' => 'usage,contentadmin', |
---|
[2230] | 425 | 'dashboard_cb' => array('defaultFavorites','commentsDashboard')), |
---|
[2302] | 426 | 'search' => array( |
---|
| 427 | 'title' => __('Search'), |
---|
[2720] | 428 | 'url' => $core->adminurl->get("admin.search"), |
---|
[2302] | 429 | 'small-icon' => 'images/menu/search.png', |
---|
| 430 | 'large-icon' => 'images/menu/search-b.png', |
---|
| 431 | 'permissions' => 'usage,contentadmin'), |
---|
[2229] | 432 | 'categories' => array( |
---|
| 433 | 'title' => __('Categories'), |
---|
[2720] | 434 | 'url' => $core->adminurl->get("admin.categories"), |
---|
[2229] | 435 | 'small-icon' => 'images/menu/categories.png', |
---|
| 436 | 'large-icon' => 'images/menu/categories-b.png', |
---|
| 437 | 'permissions' =>'categories'), |
---|
| 438 | 'media' => array( |
---|
| 439 | 'title' => __('Media manager'), |
---|
[2720] | 440 | 'url' => $core->adminurl->get("admin.media"), |
---|
[2229] | 441 | 'small-icon' => 'images/menu/media.png', |
---|
| 442 | 'large-icon' => 'images/menu/media-b.png', |
---|
[3298] | 443 | 'permissions' => 'media,media_admin'), |
---|
[2302] | 444 | 'blog_pref' => array( |
---|
| 445 | 'title' => __('Blog settings'), |
---|
[2720] | 446 | 'url' => $core->adminurl->get("admin.blog.pref"), |
---|
[2302] | 447 | 'small-icon' => 'images/menu/blog-pref.png', |
---|
| 448 | 'large-icon' => 'images/menu/blog-pref-b.png', |
---|
| 449 | 'permissions' => 'admin'), |
---|
[2229] | 450 | 'blog_theme' => array( |
---|
| 451 | 'title' => __('Blog appearance'), |
---|
[2720] | 452 | 'url' => $core->adminurl->get("admin.blog.theme"), |
---|
[2229] | 453 | 'small-icon' => 'images/menu/themes.png', |
---|
| 454 | 'large-icon' => 'images/menu/blog-theme-b.png', |
---|
| 455 | 'permissions' => 'admin'), |
---|
[2302] | 456 | 'blogs' => array( |
---|
| 457 | 'title' => __('Blogs'), |
---|
[2720] | 458 | 'url' => $core->adminurl->get("admin.blogs"), |
---|
[2302] | 459 | 'small-icon' => 'images/menu/blogs.png', |
---|
| 460 | 'large-icon' => 'images/menu/blogs-b.png', |
---|
| 461 | 'permissions' =>'usage,contentadmin'), |
---|
| 462 | 'users' => array( |
---|
| 463 | 'title' => __('Users'), |
---|
[2720] | 464 | 'url' => $core->adminurl->get("admin.users"), |
---|
[2302] | 465 | 'small-icon' => 'images/menu/users.png', |
---|
| 466 | 'large-icon' => 'images/menu/users-b.png'), |
---|
| 467 | 'plugins' => array( |
---|
| 468 | 'title' => __('Plugins management'), |
---|
[2720] | 469 | 'url' => $core->adminurl->get("admin.plugins"), |
---|
[2302] | 470 | 'small-icon' => 'images/menu/plugins.png', |
---|
| 471 | 'large-icon' => 'images/menu/plugins-b.png'), |
---|
| 472 | 'langs' => array( |
---|
| 473 | 'title' => __('Languages'), |
---|
[2720] | 474 | 'url' => $core->adminurl->get("admin.langs"), |
---|
[2302] | 475 | 'small-icon' => 'images/menu/langs.png', |
---|
| 476 | 'large-icon' => 'images/menu/langs-b.png'), |
---|
[2229] | 477 | 'help' => array( |
---|
| 478 | 'title' => __('Global help'), |
---|
[2720] | 479 | 'url' => $core->adminurl->get("admin.help"), |
---|
[2229] | 480 | 'small-icon' => 'images/menu/help.png', |
---|
| 481 | 'large-icon' => 'images/menu/help-b.png') |
---|
| 482 | )); |
---|
| 483 | } |
---|
[2247] | 484 | |
---|
| 485 | public static function postsDashboard($core,$v) |
---|
| 486 | { |
---|
[2229] | 487 | $post_count = $core->blog->getPosts(array(),true)->f(0); |
---|
[3394] | 488 | $str_entries = __('%d post', '%d posts',$post_count); |
---|
[2230] | 489 | $v['title'] = sprintf($str_entries,$post_count); |
---|
[2229] | 490 | } |
---|
[2247] | 491 | |
---|
| 492 | public static function commentsDashboard($core,$v) |
---|
| 493 | { |
---|
[2229] | 494 | $comment_count = $core->blog->getComments(array(),true)->f(0); |
---|
[2376] | 495 | $str_comments = __('%d comment', '%d comments',$comment_count); |
---|
[2230] | 496 | $v['title']= sprintf($str_comments,$comment_count); |
---|
[2229] | 497 | } |
---|
[2566] | 498 | } |
---|