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