Dotclear

source: admin/plugins.php @ 2314:a8e88895bff2

Revision 2314:a8e88895bff2, 6.6 KB checked in by franck <carnet.franck.paul@…>, 12 years ago (diff)

First step of contextual helps, see #1760

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

Sites map