| 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('adminDashboardFavorites',array('pagesDashboard','pagesDashboardFavs')); |
|---|
| 15 | $core->addBehavior('adminUsersActionsHeaders','pages_users_actions_headers'); |
|---|
| 16 | |
|---|
| 17 | class pagesDashboard |
|---|
| 18 | { |
|---|
| 19 | public static function pagesDashboardFavs($core,$favs) |
|---|
| 20 | { |
|---|
| 21 | $favs->register('pages', array( |
|---|
| 22 | 'title' => __('Pages'), |
|---|
| 23 | 'url' => 'plugin.php?p=pages', |
|---|
| 24 | 'small-icon' => 'index.php?pf=pages/icon.png', |
|---|
| 25 | 'large-icon' => 'index.php?pf=pages/icon-big.png', |
|---|
| 26 | 'permissions' => 'contentadmin,pages', |
|---|
| 27 | 'dashboard_cb' => array('pagesDashboard','pagesDashboardCB'), |
|---|
| 28 | 'active_cb' => array('pagesDashboard','pagesActiveCB') |
|---|
| 29 | )); |
|---|
| 30 | $favs->register('newpage', array( |
|---|
| 31 | 'title' => __('New page'), |
|---|
| 32 | 'url' => 'plugin.php?p=pages&act=page', |
|---|
| 33 | 'small-icon' => 'index.php?pf=pages/icon-np.png', |
|---|
| 34 | 'large-icon' => 'index.php?pf=pages/icon-np-big.png', |
|---|
| 35 | 'permissions' => 'contentadmin,pages', |
|---|
| 36 | 'active_cb' => array('pagesDashboard','newPageActiveCB') |
|---|
| 37 | )); |
|---|
| 38 | } |
|---|
| 39 | |
|---|
| 40 | public static function pagesDashboardCB($core,$v) |
|---|
| 41 | { |
|---|
| 42 | $params = new ArrayObject(); |
|---|
| 43 | $params['post_type'] = 'page'; |
|---|
| 44 | $page_count = $core->blog->getPosts($params,true)->f(0); |
|---|
| 45 | if ($page_count > 0) { |
|---|
| 46 | $str_pages = ($page_count > 1) ? __('%d pages') : __('%d page'); |
|---|
| 47 | $v['title'] = sprintf($str_pages,$page_count); |
|---|
| 48 | } |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | public static function pagesActiveCB($request,$params) |
|---|
| 52 | { |
|---|
| 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 | { |
|---|
| 60 | return ($request == "plugin.php") && |
|---|
| 61 | isset($params['p']) && $params['p'] == 'pages' |
|---|
| 62 | && isset($params['act']) && $params['act']=='page'; |
|---|
| 63 | } |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | |
|---|
| 67 | function 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 | |
|---|
| 78 | require dirname(__FILE__).'/_widgets.php'; |
|---|