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_CONTEXT_ADMIN')) { return; } |
---|
13 | |
---|
14 | $core->addBehavior('adminColumnsLists',array('pagesColumnsLists','adminColumnsLists')); |
---|
15 | $core->addBehavior('adminDashboardFavorites',array('pagesDashboard','pagesDashboardFavs')); |
---|
16 | $core->addBehavior('adminUsersActionsHeaders','pages_users_actions_headers'); |
---|
17 | |
---|
18 | class pagesColumnsLists |
---|
19 | { |
---|
20 | public static function adminColumnsLists($core,$cols) |
---|
21 | { |
---|
22 | // Set optional columns in pages lists |
---|
23 | $cols['pages'] = array(__('Pages'), array( |
---|
24 | 'date' => array(true,__('Date')), |
---|
25 | 'author' => array(true,__('Author')), |
---|
26 | 'comments' => array(true,__('Comments')), |
---|
27 | 'trackbacks' => array(true,__('Trackbacks')) |
---|
28 | )); |
---|
29 | } |
---|
30 | } |
---|
31 | |
---|
32 | class pagesDashboard |
---|
33 | { |
---|
34 | public static function pagesDashboardFavs($core,$favs) |
---|
35 | { |
---|
36 | $favs->register('pages', array( |
---|
37 | 'title' => __('Pages'), |
---|
38 | 'url' => $core->adminurl->get('admin.plugin.pages'), |
---|
39 | 'small-icon' => dcPage::getPF('pages/icon.png'), |
---|
40 | 'large-icon' => dcPage::getPF('pages/icon-big.png'), |
---|
41 | 'permissions' => 'contentadmin,pages', |
---|
42 | 'dashboard_cb' => array('pagesDashboard','pagesDashboardCB'), |
---|
43 | 'active_cb' => array('pagesDashboard','pagesActiveCB') |
---|
44 | )); |
---|
45 | $favs->register('newpage', array( |
---|
46 | 'title' => __('New page'), |
---|
47 | 'url' => $core->adminurl->get('admin.plugin.pages',array('act' => 'page')), |
---|
48 | 'small-icon' => dcPage::getPF('pages/icon-np.png'), |
---|
49 | 'large-icon' => dcPage::getPF( 'pages/icon-np-big.png'), |
---|
50 | 'permissions' => 'contentadmin,pages', |
---|
51 | 'active_cb' => array('pagesDashboard','newPageActiveCB') |
---|
52 | )); |
---|
53 | } |
---|
54 | |
---|
55 | public static function pagesDashboardCB($core,$v) |
---|
56 | { |
---|
57 | $params = new ArrayObject(); |
---|
58 | $params['post_type'] = 'page'; |
---|
59 | $page_count = $core->blog->getPosts($params,true)->f(0); |
---|
60 | if ($page_count > 0) { |
---|
61 | $str_pages = ($page_count > 1) ? __('%d pages') : __('%d page'); |
---|
62 | $v['title'] = sprintf($str_pages,$page_count); |
---|
63 | } |
---|
64 | } |
---|
65 | |
---|
66 | public static function pagesActiveCB($request,$params) |
---|
67 | { |
---|
68 | return ($request == "plugin.php") && |
---|
69 | isset($params['p']) && $params['p'] == 'pages' |
---|
70 | && !(isset($params['act']) && $params['act']=='page'); |
---|
71 | } |
---|
72 | |
---|
73 | public static function newPageActiveCB($request,$params) |
---|
74 | { |
---|
75 | return ($request == "plugin.php") && |
---|
76 | isset($params['p']) && $params['p'] == 'pages' |
---|
77 | && isset($params['act']) && $params['act']=='page'; |
---|
78 | } |
---|
79 | } |
---|
80 | |
---|
81 | |
---|
82 | function pages_users_actions_headers() |
---|
83 | { |
---|
84 | return dcPage::jsLoad('index.php?pf=pages/_users_actions.js'); |
---|
85 | } |
---|
86 | |
---|
87 | $_menu['Blog']->addItem(__('Pages'), |
---|
88 | $core->adminurl->get('admin.plugin.pages'), |
---|
89 | dcPage::getPF('pages/icon.png'), |
---|
90 | preg_match('/plugin.php(.*)$/',$_SERVER['REQUEST_URI']) && !empty($_REQUEST['p']) && $_REQUEST['p']=='pages', |
---|
91 | $core->auth->check('contentadmin,pages',$core->blog->id)); |
---|
92 | |
---|
93 | $core->auth->setPermissionType('pages',__('manage pages')); |
---|
94 | |
---|
95 | require dirname(__FILE__).'/_widgets.php'; |
---|