Dotclear

source: admin/plugins.php @ 2219:1226a4c7ab59

Revision 2219:1226a4c7ab59, 6.5 KB checked in by Denis Jean-Chirstian <contact@…>, 12 years ago (diff)

Use new success notice system

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

Sites map