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