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('adminDashboardIcons','pages_dashboard'); |
---|
15 | $core->addBehavior('adminDashboardFavs','pages_dashboard_favs'); |
---|
16 | $core->addBehavior('adminDashboardFavsIcon','pages_dashboard_favs_icon'); |
---|
17 | $core->addBehavior('adminUsersActionsHeaders','pages_users_actions_headers'); |
---|
18 | $core->addBehavior('adminPostsActionsContent','pages_PostsActionsContent'); |
---|
19 | |
---|
20 | function pages_dashboard($core,$icons) |
---|
21 | { |
---|
22 | $icons['pages'] = new ArrayObject(array(__('Pages'),'plugin.php?p=pages','index.php?pf=pages/icon-big.png')); |
---|
23 | } |
---|
24 | function pages_dashboard_favs($core,$favs) |
---|
25 | { |
---|
26 | $favs['pages'] = new ArrayObject(array('pages','Pages','plugin.php?p=pages', |
---|
27 | 'index.php?pf=pages/icon.png','index.php?pf=pages/icon-big.png', |
---|
28 | 'contentadmin,pages',null,null)); |
---|
29 | $favs['newpage'] = new ArrayObject(array('newpage','New page','plugin.php?p=pages&act=page', |
---|
30 | 'index.php?pf=pages/icon-np.png','index.php?pf=pages/icon-np-big.png', |
---|
31 | 'contentadmin,pages',null,null)); |
---|
32 | } |
---|
33 | function pages_dashboard_favs_icon($core,$name,$icon) |
---|
34 | { |
---|
35 | // Check if it is one of my own favs |
---|
36 | if ($name == 'pages') { |
---|
37 | $params = new ArrayObject(); |
---|
38 | $params['post_type'] = 'page'; |
---|
39 | $page_count = $core->blog->getPosts($params,true)->f(0); |
---|
40 | if ($page_count > 0) { |
---|
41 | $str_pages = ($page_count > 1) ? __('%d pages') : __('%d page'); |
---|
42 | $icon[0] = sprintf($str_pages,$page_count); |
---|
43 | } |
---|
44 | } |
---|
45 | } |
---|
46 | |
---|
47 | function pages_PostsActionsContent($core,$action,$hidden_fields,$form_uri="posts_actions.php") |
---|
48 | { |
---|
49 | |
---|
50 | if ($action == 'reorder' && !empty($_POST['order'])) { |
---|
51 | try { |
---|
52 | |
---|
53 | foreach($_POST['order'] as $post_id => $value) { |
---|
54 | |
---|
55 | if (!$core->auth->check('publish,contentadmin',$core->blog->id)) |
---|
56 | throw new Exception(__('You are not allowed to change this entry status')); |
---|
57 | |
---|
58 | $strReq = "WHERE blog_id = '".$core->con->escape($core->blog->id)."' ". |
---|
59 | "AND post_id ".$core->con->in($post_id); |
---|
60 | |
---|
61 | #If user can only publish, we need to check the post's owner |
---|
62 | if (!$core->auth->check('contentadmin',$core->blog->id)) |
---|
63 | $strReq .= "AND user_id = '".$core->con->escape($core->auth->userID())."' "; |
---|
64 | |
---|
65 | $cur = $core->con->openCursor($core->prefix.'post'); |
---|
66 | |
---|
67 | $cur->post_position = (integer) $value-1; |
---|
68 | $cur->post_upddt = date('Y-m-d H:i:s'); |
---|
69 | |
---|
70 | $cur->update($strReq); |
---|
71 | $core->blog->triggerBlog(); |
---|
72 | |
---|
73 | } |
---|
74 | |
---|
75 | http::redirect($_POST['redir']); |
---|
76 | } catch (Exception $e) { |
---|
77 | $core->error->add($e->getMessage()); |
---|
78 | } |
---|
79 | } |
---|
80 | } |
---|
81 | function pages_users_actions_headers() |
---|
82 | { |
---|
83 | return dcPage::jsLoad('index.php?pf=pages/_users_actions.js'); |
---|
84 | } |
---|
85 | |
---|
86 | $_menu['Blog']->addItem(__('Pages'),'plugin.php?p=pages','index.php?pf=pages/icon.png', |
---|
87 | preg_match('/plugin.php\?p=pages(&.*)?$/',$_SERVER['REQUEST_URI']), |
---|
88 | $core->auth->check('contentadmin,pages',$core->blog->id)); |
---|
89 | |
---|
90 | $core->auth->setPermissionType('pages',__('manage pages')); |
---|
91 | |
---|
92 | require dirname(__FILE__).'/_widgets.php'; |
---|
93 | ?> |
---|