Dotclear

source: admin/plugins.php @ 2279:e6084be51600

Revision 2279:e6084be51600, 6.8 KB checked in by Denis Jean-Chirstian <contact@…>, 12 years ago (diff)

Because I'm nice, hu!

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

Sites map