Dotclear

source: admin/plugins.php @ 2216:91f485a16187

Revision 2216:91f485a16187, 6.7 KB checked in by Denis Jean-Chirstian <contact@…>, 12 years ago (diff)

Rename dcRepository to dcStore because of dotAddict used this name

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

Sites map