Dotclear

source: plugins/pages/_admin.php @ 130:e5a965650d8b

Revision 130:e5a965650d8b, 1.9 KB checked in by Franck <carnet.franck.paul@…>, 14 years ago (diff)

Implements adminDashboardFavsIcon behavior in order to let plugins set their own fav icon title on dashboard

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2010 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 -----------------------------------------
12if (!defined('DC_CONTEXT_ADMIN')) { return; }
13
14$core->addBehavior('adminDashboardIcons','pages_dashboard');
15$core->addBehavior('adminDashboardFavs','pages_dashboard_favs');
16$core->addBehavior('adminDashboardFavsIcon','pages_dashboard_favs_icon');
17function pages_dashboard($core,$icons)
18{
19     $icons['pages'] = new ArrayObject(array(__('Pages'),'plugin.php?p=pages','index.php?pf=pages/icon-big.png'));
20}
21function pages_dashboard_favs($core,$favs)
22{
23     $favs['pages'] = new ArrayObject(array('pages',__('Pages'),'plugin.php?p=pages',
24          'index.php?pf=pages/icon.png','index.php?pf=pages/icon-big.png',
25          'contentadmin,pages',null,null));
26     $favs['newpage'] = new ArrayObject(array('newpage',__('New page'),'plugin.php?p=pages&amp;act=page',
27          'index.php?pf=pages/icon-np.png','index.php?pf=pages/icon-np-big.png',
28          'contentadmin,pages',null,null));
29}
30function pages_dashboard_favs_icon($core,$name,$icon)
31{
32     // Check if it is one of my own favs
33     if ($name == 'pages') {
34          $params = new ArrayObject();
35          $params['post_type'] = 'page';
36          $page_count = $core->blog->getPosts($params,true)->f(0);
37          if ($page_count > 0) {
38               $str_pages = ($page_count > 1) ? __('%d pages') : __('%d page');
39               $icon[0] = sprintf($str_pages,$page_count);
40          }
41     }
42}
43
44$_menu['Blog']->addItem(__('Pages'),'plugin.php?p=pages','index.php?pf=pages/icon.png',
45          preg_match('/plugin.php\?p=pages(&.*)?$/',$_SERVER['REQUEST_URI']),
46          $core->auth->check('contentadmin,pages',$core->blog->id));
47
48$core->auth->setPermissionType('pages',__('manage pages'));
49
50require dirname(__FILE__).'/_widgets.php';
51?>
Note: See TracBrowser for help on using the repository browser.

Sites map