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