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