This repository was archived by the owner on Sep 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path_admin.php
More file actions
259 lines (226 loc) · 6.26 KB
/
_admin.php
File metadata and controls
259 lines (226 loc) · 6.26 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of zoneclearFeedServer, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2015 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
# Namespace for settings
$core->blog->settings->addNamespace('zoneclearFeedServer');
# Check if latest version is installed
if ($core->getVersion('zoneclearFeedServer') !=
$core->plugins->moduleInfo('zoneclearFeedServer', 'version')) {
return null;
}
# Widgets
require_once dirname(__FILE__).'/_widgets.php';
# Admin menu
$_menu['Blog']->addItem(
__('Feeds server'),
'plugin.php?p=zoneclearFeedServer',
'index.php?pf=zoneclearFeedServer/icon.png',
preg_match(
'/plugin.php\?p=zoneclearFeedServer(&.*)?$/',
$_SERVER['REQUEST_URI']
),
$core->auth->check('admin', $core->blog->id)
);
# Delete related info about feed post in meta table
$core->addBehavior(
'adminBeforePostDelete',
array('zcfsAdminBehaviors', 'adminBeforePostDelete')
);
if ($core->auth->check('admin', $core->blog->id)) {
# Dashboard icon
$core->addBehavior(
'adminDashboardFavorites',
array('zcfsAdminBehaviors', 'adminDashboardFavorites')
);
# Add info about feed on post page sidebar
$core->addBehavior(
'adminPostHeaders',
array('zcfsAdminBehaviors', 'adminPostHeaders')
);
$core->addBehavior(
'adminPostFormItems',
array('zcfsAdminBehaviors', 'adminPostFormItems')
);
}
# Take care about tweakurls (thanks Mathieu M.)
if (version_compare($core->plugins->moduleInfo('tweakurls', 'version'), '0.8', '>=')) {
$core->addbehavior(
'zcfsAfterPostCreate',
array('zoneclearFeedServer', 'tweakurlsAfterPostCreate')
);
}
/**
* @ingroup DC_PLUGIN_ZONECLEARFEEDSERVER
* @brief Mix your blog with a feeds planet - admin methods.
* @since 2.6
*/
class zcfsAdminBehaviors
{
/**
* Favorites.
*
* @param dcCore $core dcCore instance
* @param arrayObject $favs Array of favorites
*/
public static function adminDashboardFavorites(dcCore $core, $favs)
{
$favs->register('zcfs', array(
'title' => __('Feeds server'),
'url' => 'plugin.php?p=zoneclearFeedServer',
'small-icon' => 'index.php?pf=zoneclearFeedServer/icon.png',
'large-icon' => 'index.php?pf=zoneclearFeedServer/icon-big.png',
'permissions' => 'usage,contentadmin',
'active_cb' => array(
'zcfsAdminBehaviors',
'adminDashboardFavoritesActive'
),
'dashboard_cb' => array(
'zcfsAdminBehaviors',
'adminDashboardFavoritesCallback'
)
));
}
/**
* Favorites selection.
*
* @param string $request Requested page
* @param array $params Requested parameters
*/
public static function adminDashboardFavoritesActive($request, $params)
{
return $request == 'plugin.php'
&& isset($params['p'])
&& $params['p'] == 'zoneclearFeedServer';
}
/**
* Favorites hack.
*
* @param dcCore $core dcCore instance
* @param arrayObject $fav Fav attributes
*/
public static function adminDashboardFavoritesCallback(dcCore $core, $fav)
{
$zcfs = new zoneclearFeedServer($core);
$count = $zcfs->getFeeds(array(
'feed_status' => '0'
), true)->f(0);
if (!$count) {
return null;
}
$fav['title'] .= '<br />'.sprintf(
__('%s feed disabled', '%s feeds disabled', $count),
$count
);
$fav['url'] = 'plugin.php?p=zoneclearFeedServer&part=feeds'.
'&sortby=feed_status&order=asc';
$fav['large-icon'] = 'index.php?pf=zoneclearFeedServer'.
'/icon-big-update.png';
}
/**
* Add javascript for toggle to post edition page header.
*
* @return string Page header
*/
public static function adminPostHeaders()
{
return dcPage::jsLoad(
'index.php?pf=zoneclearFeedServer/js/post.js'
);
}
/**
* Add form to post sidebar.
*
* @param ArrayObject $main_items Main items
* @param ArrayObject $sidebar_items Sidebar items
* @param record $post Post record or null
*/
public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, $post)
{
if ($post === null || $post->post_type != 'post') {
return null;
}
global $core;
$url = $core->meta->getMetadata(array(
'post_id' => $post->post_id,
'meta_type' => 'zoneclearfeed_url',
'limit' => 1
));
$url = $url->isEmpty() ? '' : $url->meta_id;
if (!$url) {
return null;
}
$author = $core->meta->getMetadata(array(
'post_id' => $post->post_id,
'meta_type' => 'zoneclearfeed_author',
'limit' => 1
));
$author = $author->isEmpty() ? '' : $author->meta_id;
$site = $core->meta->getMetadata(array(
'post_id' => $post->post_id,
'meta_type' => 'zoneclearfeed_site',
'limit' => 1
));
$site = $site->isEmpty() ? '' : $site->meta_id;
$sitename = $core->meta->getMetadata(array(
'post_id' => $post->post_id,
'meta_type' => 'zoneclearfeed_sitename',
'limit' => 1
));
$sitename = $sitename->isEmpty() ? '' : $sitename->meta_id;
$edit = '';
if ($core->auth->check('admin', $core->blog->id)) {
$fid = $core->meta->getMetadata(array(
'post_id' => $post->post_id,
'meta_type' => 'zoneclearfeed_id',
'limit' => 1
));
if (!$fid->isEmpty()) {
$edit =
'<p><a href="plugin.php?p=zoneclearFeedServer'.
'&part=feed&feed_id='.$fid->meta_id.
'">'.__('Edit this feed').'</a></p>';
}
}
$sidebar_items['options-box']['items']['zcfs'] =
'<div id="zcfs">'.
'<h5>'.__('Feed source').'</h5>'.
'<p>'.
'<a href="'.$url.'" title="'.$author.' - '.$url.'">'.__('feed URL').'</a> - '.
'<a href="'.$site.'" title="'.$sitename.' - '.$site.'">'.__('site URL').'</a>'.
'</p>'.
$edit.
'</div>';
}
/**
* Delete related info about feed post in meta table.
*
* @param integer $post_id Post id
*/
public static function adminBeforePostDelete($post_id)
{
global $core;
$core->con->execute(
'DELETE FROM '.$core->prefix.'meta '.
'WHERE post_id = '.((integer) $post_id).' '.
'AND meta_type '.$core->con->in(array(
'zoneclearfeed_url',
'zoneclearfeed_author',
'zoneclearfeed_site',
'zoneclearfeed_sitename',
'zoneclearfeed_id'
)).' '
);
}
}