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