File: _admin.php

package info (click to toggle)
dotclear 2.6.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie-kfreebsd
  • size: 8,420 kB
  • sloc: php: 54,270; sql: 1,290; sh: 213; xml: 173; makefile: 158
file content (78 lines) | stat: -rw-r--r-- 2,595 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
# -- BEGIN LICENSE BLOCK ---------------------------------------
#
# This file is part of Dotclear 2.
#
# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
# Licensed under the GPL version 2.0 license.
# See LICENSE file or
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK -----------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) { return; }

$core->addBehavior('adminDashboardFavorites',array('pagesDashboard','pagesDashboardFavs'));
$core->addBehavior('adminUsersActionsHeaders','pages_users_actions_headers');

class pagesDashboard
{
	public static function pagesDashboardFavs($core,$favs)
	{
		$favs->register('pages', array(
			'title' => __('Pages'),
			'url' => 'plugin.php?p=pages',
			'small-icon' => 'index.php?pf=pages/icon.png',
			'large-icon' => 'index.php?pf=pages/icon-big.png',
			'permissions' => 'contentadmin,pages',
			'dashboard_cb' => array('pagesDashboard','pagesDashboardCB'),
			'active_cb' => array('pagesDashboard','pagesActiveCB')
		));
		$favs->register('newpage', array(
			'title' => __('New page'),
			'url' => 'plugin.php?p=pages&amp;act=page',
			'small-icon' => 'index.php?pf=pages/icon-np.png',
			'large-icon' => 'index.php?pf=pages/icon-np-big.png',
			'permissions' => 'contentadmin,pages',
			'active_cb' => array('pagesDashboard','newPageActiveCB')
		));
	}

	public static function pagesDashboardCB($core,$v)
	{
		$params = new ArrayObject();
		$params['post_type'] = 'page';
		$page_count = $core->blog->getPosts($params,true)->f(0);
		if ($page_count > 0) {
			$str_pages = ($page_count > 1) ? __('%d pages') : __('%d page');
			$v['title'] = sprintf($str_pages,$page_count);
		}
	}

	public static function pagesActiveCB($request,$params)
	{
		return ($request == "plugin.php") &&
			isset($params['p']) && $params['p'] == 'pages'
			&& !(isset($params['act']) && $params['act']=='page');
	}

	public static function newPageActiveCB($request,$params)
	{
		return ($request == "plugin.php") &&
			isset($params['p']) && $params['p'] == 'pages'
			&& isset($params['act']) && $params['act']=='page';
	}
}


function pages_users_actions_headers()
{
	return dcPage::jsLoad('index.php?pf=pages/_users_actions.js');
}

$_menu['Blog']->addItem(__('Pages'),'plugin.php?p=pages','index.php?pf=pages/icon.png',
		preg_match('/plugin.php(.*)$/',$_SERVER['REQUEST_URI']) && !empty($_REQUEST['p']) && $_REQUEST['p']=='pages',
		$core->auth->check('contentadmin,pages',$core->blog->id));

$core->auth->setPermissionType('pages',__('manage pages'));

require dirname(__FILE__).'/_widgets.php';