Dotclear

source: plugins/pages/_admin.php @ 2230:e63e48e1c53b

Revision 2230:e63e48e1c53b, 2.7 KB checked in by Dsls, 12 years ago (diff)
  • 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
Line 
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 -----------------------------------------
12if (!defined('DC_CONTEXT_ADMIN')) { return; }
13
14$core->addBehavior('adminDashboardIcons','pages_dashboard');
15$core->addBehavior('adminDashboardFavorites',array('pagesDashboard','pagesDashboardFavs'));
16$core->addBehavior('adminDashboardFavsIcon','pages_dashboard_favs_icon');
17$core->addBehavior('adminUsersActionsHeaders','pages_users_actions_headers');
18
19class pagesDashboard
20{
21     public static function pagesDashboardFavs($core,$favs)
22     {
23          $favs->register('pages', array(
24               'title' => __('Pages'),
25               'url' => 'plugin.php?p=pages',
26               'small-icon' => 'index.php?pf=pages/icon.png',
27               'large-icon' => 'index.php?pf=pages/icon-big.png',
28               'permissions' => 'contentadmin,pages',
29               'dashboard_cb' => array('pagesDashboard','pagesDashboardCB'),
30               'active_cb' => array('pagesDashboard','pagesActiveCB')
31          ));
32          $favs->register('newpage', array(
33               'title' => __('New page'),
34               'url' => 'plugin.php?p=pages&amp;act=page',
35               'small-icon' => 'index.php?pf=pages/icon-np.png',
36               'large-icon' => 'index.php?pf=pages/icon-np-big.png',
37               'permissions' => 'contentadmin,pages',
38               'active_cb' => array('pagesDashboard','newPageActiveCB')
39          ));
40     }
41     
42     public static function pagesDashboardCB($core,$v) {
43          $params = new ArrayObject();
44          $params['post_type'] = 'page';
45          $page_count = $core->blog->getPosts($params,true)->f(0);
46          if ($page_count > 0) {
47               $str_pages = ($page_count > 1) ? __('%d pages') : __('%d page');
48               $v['title'] = sprintf($str_pages,$page_count);
49          }
50     }
51     
52     public static function pagesActiveCB($request,$params) {
53          return ($request == "plugin.php") &&
54               isset($params['p']) && $params['p'] == 'pages'
55               && !(isset($params['act']) && $params['act']=='page');
56     }
57     
58     public static function newPageActiveCB($request,$params) {
59          return ($request == "plugin.php") &&
60               isset($params['p']) && $params['p'] == 'pages'
61               && isset($params['act']) && $params['act']=='page';
62     }
63     
64}
65
66
67function pages_users_actions_headers()
68{
69     return dcPage::jsLoad('index.php?pf=pages/_users_actions.js');
70}
71
72$_menu['Blog']->addItem(__('Pages'),'plugin.php?p=pages','index.php?pf=pages/icon.png',
73          preg_match('/plugin.php(.*)$/',$_SERVER['REQUEST_URI']) && !empty($_REQUEST['p']) && $_REQUEST['p']=='pages',
74          $core->auth->check('contentadmin,pages',$core->blog->id));
75
76$core->auth->setPermissionType('pages',__('manage pages'));
77
78require dirname(__FILE__).'/_widgets.php';
79?>
Note: See TracBrowser for help on using the repository browser.

Sites map