[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
[1179] | 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
[0] | 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('adminDashboardIcons','pages_dashboard'); |
---|
[2230] | 15 | $core->addBehavior('adminDashboardFavorites',array('pagesDashboard','pagesDashboardFavs')); |
---|
[130] | 16 | $core->addBehavior('adminDashboardFavsIcon','pages_dashboard_favs_icon'); |
---|
[1503] | 17 | $core->addBehavior('adminUsersActionsHeaders','pages_users_actions_headers'); |
---|
| 18 | |
---|
[2230] | 19 | class pagesDashboard |
---|
[0] | 20 | { |
---|
[2230] | 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&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) { |
---|
[130] | 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'); |
---|
[2230] | 48 | $v['title'] = sprintf($str_pages,$page_count); |
---|
[130] | 49 | } |
---|
| 50 | } |
---|
[2230] | 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 | |
---|
[130] | 64 | } |
---|
[2230] | 65 | |
---|
| 66 | |
---|
[1503] | 67 | function pages_users_actions_headers() |
---|
| 68 | { |
---|
| 69 | return dcPage::jsLoad('index.php?pf=pages/_users_actions.js'); |
---|
| 70 | } |
---|
[0] | 71 | |
---|
| 72 | $_menu['Blog']->addItem(__('Pages'),'plugin.php?p=pages','index.php?pf=pages/icon.png', |
---|
[2141] | 73 | preg_match('/plugin.php(.*)$/',$_SERVER['REQUEST_URI']) && !empty($_REQUEST['p']) && $_REQUEST['p']=='pages', |
---|
[0] | 74 | $core->auth->check('contentadmin,pages',$core->blog->id)); |
---|
| 75 | |
---|
| 76 | $core->auth->setPermissionType('pages',__('manage pages')); |
---|
| 77 | |
---|
| 78 | require dirname(__FILE__).'/_widgets.php'; |
---|
| 79 | ?> |
---|