Dotclear

source: admin/plugins.php @ 2182:eaaf345b04f3

Revision 2182:eaaf345b04f3, 7.0 KB checked in by Denis Jean-Chirstian <contact@…>, 12 years ago (diff)

Enable complex loop (get, post, redirect) in themes and plugins configuration files

Line 
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
13require dirname(__FILE__).'/../inc/admin/prepend.php';
14
15dcPage::check('admin');
16
17# --------------------------------------------------
18# @todo Add settings to Dotclear update features
19if ($core->blog->settings->system->plugins_allow_multi_install === null) {
20     $core->blog->settings->system->put(
21          'plugins_allow_multi_install', false, 'boolean', 'Allow multi-installation for plugins', true, true
22     );
23}
24if ($core->blog->settings->system->repository_plugin_url === null) {
25     $core->blog->settings->system->put(
26          'repository_plugin_url', 'http://update.dotaddict.org/dc2/plugins.xml', 'string', 'Plugins XML feed location', true, true
27     );
28}
29# --------------------------------------------------
30
31# -- Repository helper --
32$repository = new dcRepository(
33     $core->plugins, 
34     $core->blog->settings->system->repository_plugin_url
35);
36$repository->check();
37
38# -- Page helper --
39$list = new adminModulesList(
40     $core, 
41     DC_PLUGINS_ROOT,
42     $core->blog->settings->system->plugins_allow_multi_install
43);
44
45$list::setDistributedModules(array(
46     'aboutConfig',
47     'akismet',
48     'antispam',
49     'attachments',
50     'blogroll',
51     'blowupConfig',
52     'daInstaller',
53     'fairTrackbacks',
54     'importExport',
55     'maintenance',
56     'pages',
57     'pings',
58     'simpleMenu',
59     'tags',
60     'themeEditor',
61     'userPref',
62     'widgets'
63));
64
65# -- Display module configuration page --
66if ($list->setConfigurationFile($core->plugins)) {
67
68     # Get content before page headers
69     include $list->getConfigurationFile();
70
71     # Gather content
72     $list->setConfigurationContent();
73
74     # Display page
75     dcPage::open(__('Plugins management'),
76
77          # --BEHAVIOR-- pluginsToolsHeaders
78          $core->callBehavior('pluginsToolsHeaders', $core, true),
79
80          dcPage::breadcrumb(
81               array(
82                    html::escapeHTML($core->blog->name) => '',
83                    '<a href="'.$list->getPageURL().'">'.__('Plugins management').'</a>' => '',
84                    '<span class="page-title">'.__('Plugin configuration').'</span>' => ''
85               ))
86     );
87
88     # Message
89     if (!empty($_GET['done'])){
90          dcPage::success(__('Plugin successfully configured.'));
91     }
92
93     # Display previously gathered content
94     $list->getConfigurationContent();
95
96     dcPage::close();
97
98     # Stop reading code here
99     return;
100}
101
102# -- Execute actions --
103if (!empty($_POST) && empty($_REQUEST['conf']) && $core->auth->isSuperAdmin() && $list->isPathWritable()) {
104     try {
105          $list->executeAction('plugins', $core->plugins, $repository);
106     }
107     catch (Exception $e) {
108          $core->error->add($e->getMessage());
109     }
110}
111
112# -- Plugin install --
113$plugins_install = null;
114if (!$core->error->flag()) {
115     $plugins_install = $core->plugins->installModules();
116}
117
118# -- Page header --
119dcPage::open(__('Plugins management'),
120     dcPage::jsLoad('js/_plugins.js').
121     dcPage::jsPageTabs().
122
123     # --BEHAVIOR-- pluginsToolsHeaders
124     $core->callBehavior('pluginsToolsHeaders', $core, false),
125
126     dcPage::breadcrumb(
127          array(
128               __('System') => '',
129               __('Plugins management') => ''
130          ))
131);
132
133# -- Succes messages --
134if (!empty($_GET['msg'])) {
135     $list->displayMessage($_GET['msg']);
136}
137
138# -- Plugins install messages --
139if (!empty($plugins_install['success'])) {
140     echo 
141     '<div class="static-msg">'.__('Following plugins have been installed:').'<ul>';
142     foreach ($plugins_install['success'] as $k => $v) {
143          echo 
144          '<li>'.$k.'</li>';
145     }
146     echo 
147     '</ul></div>';
148}
149if (!empty($plugins_install['failure'])) {
150     echo 
151     '<div class="error">'.__('Following plugins have not been installed:').'<ul>';
152     foreach ($plugins_install['failure'] as $k => $v) {
153          echo 
154          '<li>'.$k.' ('.$v.')</li>';
155     }
156     echo 
157     '</ul></div>';
158}
159
160# -- Display modules lists --
161if ($core->auth->isSuperAdmin() && $list->isPathWritable()) {
162
163     # Updated modules from repo
164     $modules = $repository->get(true);
165     if (!empty($modules)) {
166          echo 
167          '<div class="multi-part" id="update" title="'.html::escapeHTML(__('Update plugins')).'">'.
168          '<h3>'.html::escapeHTML(__('Update plugins')).'</h3>'.
169          '<p>'.sprintf(
170               __('There is one plugin to update available from %2$s.', 'There are %s plugins to update available from %s.', count($modules)),
171               count($modules),
172               '<a href="http://dotaddict.org/dc2/plugins">Dotaddict</a>'
173          ).'</p>';
174
175          $list
176               ->newList('plugin-update')
177               ->setModules($modules)
178               ->setPageTab('update')
179               ->displayModulesList(
180                    /*cols */      array('icon', 'name', 'version', 'current_version', 'desc'),
181                    /* actions */  array('update')
182               );
183
184          echo
185          '</div>';
186     }
187}
188
189# List all active plugins
190echo
191'<div class="multi-part" id="plugins" title="'.__('Installed plugins').'">';
192
193$modules = $core->plugins->getModules();
194if (!empty($modules)) {
195
196     echo
197     '<h3>'.__('Activated plugins').'</h3>'.
198     '<p>'.__('Manage installed plugins from this list.').'</p>';
199
200     $list
201          ->newList('plugin-activate')
202          ->setModules($modules)
203          ->setPageTab('plugins')
204          ->displayModulesList(
205               /* cols */          array('expander', 'icon', 'name', 'config', 'version', 'desc', 'distrib'),
206               /* actions */  array('deactivate', 'delete')
207          );
208}
209
210# Deactivated modules
211$modules = $core->plugins->getDisabledModules();
212if (!empty($modules)) {
213
214     echo
215     '<h3>'.__('Deactivated plugins').'</h3>'.
216     '<p>'.__('Deactivated plugins are installed but not usable. You can activate them from here.').'</p>';
217
218     $list
219          ->newList('plugin-deactivate')
220          ->setModules($modules)
221          ->setPageTab('plugins')
222          ->displayModulesList(
223               /* cols */          array('icon', 'name', 'distrib'),
224               /* actions */  array('activate', 'delete')
225          );
226}
227
228echo 
229'</div>';
230
231if ($core->auth->isSuperAdmin() && $list->isPathWritable()) {
232
233     # New modules from repo
234     $search = $list->getSearchQuery();
235     $modules = $search ? $repository->search($search) : $repository->get();
236
237     echo
238     '<div class="multi-part" id="new" title="'.__('Add plugins from Dotaddict').'">'.
239     '<h3>'.__('Add plugins from Dotaddict repository').'</h3>';
240
241     $list
242          ->newList('plugin-new')
243          ->setModules($modules)
244          ->setPageTab('new')
245          ->displaySearchForm()
246          ->displayNavMenu()
247          ->displayModulesList(
248               /* cols */          array('expander', 'name', 'version', 'desc'),
249               /* actions */  array('install'),
250               /* nav limit */     true
251          );
252
253     echo
254     '<p class="info vertical-separator">'.sprintf(
255          __("Visit %s repository, the resources center for Dotclear."),
256          '<a href="http://dotaddict.org/dc2/plugins">Dotaddict</a>'
257          ).
258     '</p>'.
259
260     '</div>';
261
262     # Add a new plugin
263     echo
264     '<div class="multi-part" id="addplugin" title="'.__('Install or upgrade manually').'">';
265
266     echo '<p>'.__('You can install plugins by uploading or downloading zip files.').'</p>';
267     
268     $list->displayManualForm();
269
270     echo
271     '</div>';
272}
273
274# --BEHAVIOR-- pluginsToolsTabs
275$core->callBehavior('pluginsToolsTabs', $core);
276
277# -- Notice for super admin --
278if ($core->auth->isSuperAdmin() && !$list->isPathWritable()) {
279     echo 
280     '<p class="warning">'.__('Some functions are disabled, please give write access to your plugins directory to enable them.').'</p>';
281}
282
283dcPage::close();
284?>
Note: See TracBrowser for help on using the repository browser.

Sites map