[0] | 1 | <?php |
---|
[3731] | 2 | /** |
---|
| 3 | * @brief pages, a plugin for Dotclear 2 |
---|
| 4 | * |
---|
| 5 | * @package Dotclear |
---|
| 6 | * @subpackage Plugins |
---|
| 7 | * |
---|
| 8 | * @copyright Olivier Meunier & Association Dotclear |
---|
| 9 | * @copyright GPL-2.0-only |
---|
| 10 | */ |
---|
| 11 | |
---|
[3709] | 12 | if (!defined('DC_CONTEXT_ADMIN')) {return;} |
---|
[0] | 13 | |
---|
[3874] | 14 | $core->addBehavior('adminColumnsLists', ['pagesColumnsLists', 'adminColumnsLists']); |
---|
| 15 | $core->addBehavior('adminDashboardFavorites', ['pagesDashboard', 'pagesDashboardFavs']); |
---|
[3709] | 16 | $core->addBehavior('adminUsersActionsHeaders', 'pages_users_actions_headers'); |
---|
[1503] | 17 | |
---|
[3265] | 18 | class pagesColumnsLists |
---|
| 19 | { |
---|
[3709] | 20 | public static function adminColumnsLists($core, $cols) |
---|
| 21 | { |
---|
| 22 | // Set optional columns in pages lists |
---|
[3874] | 23 | $cols['pages'] = [__('Pages'), [ |
---|
| 24 | 'date' => [true, __('Date')], |
---|
| 25 | 'author' => [true, __('Author')], |
---|
| 26 | 'comments' => [true, __('Comments')], |
---|
| 27 | 'trackbacks' => [true, __('Trackbacks')] |
---|
| 28 | ]]; |
---|
[3709] | 29 | } |
---|
[3265] | 30 | } |
---|
| 31 | |
---|
[2230] | 32 | class pagesDashboard |
---|
[0] | 33 | { |
---|
[3709] | 34 | public static function pagesDashboardFavs($core, $favs) |
---|
| 35 | { |
---|
[3874] | 36 | $favs->register('pages', [ |
---|
[3709] | 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', |
---|
[3874] | 42 | 'dashboard_cb' => ['pagesDashboard', 'pagesDashboardCB'], |
---|
| 43 | 'active_cb' => ['pagesDashboard', 'pagesActiveCB'] |
---|
| 44 | ]); |
---|
| 45 | $favs->register('newpage', [ |
---|
[3709] | 46 | 'title' => __('New page'), |
---|
[3874] | 47 | 'url' => $core->adminurl->get('admin.plugin.pages', ['act' => 'page']), |
---|
[3709] | 48 | 'small-icon' => dcPage::getPF('pages/icon-np.png'), |
---|
| 49 | 'large-icon' => dcPage::getPF('pages/icon-np-big.png'), |
---|
| 50 | 'permissions' => 'contentadmin,pages', |
---|
[3874] | 51 | 'active_cb' => ['pagesDashboard', 'newPageActiveCB'] |
---|
| 52 | ]); |
---|
[3709] | 53 | } |
---|
[2246] | 54 | |
---|
[3709] | 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 | } |
---|
[2246] | 65 | |
---|
[3709] | 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 | } |
---|
[2246] | 72 | |
---|
[3709] | 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 | } |
---|
[130] | 79 | } |
---|
[2230] | 80 | |
---|
[1503] | 81 | function pages_users_actions_headers() |
---|
| 82 | { |
---|
[3709] | 83 | return dcPage::jsLoad('index.php?pf=pages/js/_users_actions.js'); |
---|
[1503] | 84 | } |
---|
[0] | 85 | |
---|
[2825] | 86 | $_menu['Blog']->addItem(__('Pages'), |
---|
[3709] | 87 | $core->adminurl->get('admin.plugin.pages'), |
---|
| 88 | dcPage::getPF('pages/icon.png'), |
---|
| 89 | preg_match('/plugin.php(.*)$/', $_SERVER['REQUEST_URI']) && !empty($_REQUEST['p']) && $_REQUEST['p'] == 'pages', |
---|
| 90 | $core->auth->check('contentadmin,pages', $core->blog->id)); |
---|
[0] | 91 | |
---|
[3709] | 92 | $core->auth->setPermissionType('pages', __('manage pages')); |
---|
[0] | 93 | |
---|
[3709] | 94 | require dirname(__FILE__) . '/_widgets.php'; |
---|