[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 | # -------------------------------------------------- |
---|
| 18 | # @todo Add settings to Dotclear update features |
---|
| 19 | if ($core->blog->settings->system->plugins_allow_multi_install === null) { |
---|
| 20 | $core->blog->settings->system->put( |
---|
| 21 | 'plugins_allow_multi_install', false, 'boolean', 'Allow multi-installation for plugins', true, true |
---|
| 22 | ); |
---|
| 23 | } |
---|
| 24 | if ($core->blog->settings->system->repository_plugin_url === null) { |
---|
| 25 | $core->blog->settings->system->put( |
---|
| 26 | 'repository_plugin_url', 'http://update.dotaddict.org/dc2/plugins.xml', 'string', 'Plugins XML feed location', true, true |
---|
| 27 | ); |
---|
| 28 | } |
---|
| 29 | # -------------------------------------------------- |
---|
[0] | 30 | |
---|
[2150] | 31 | # -- Repository helper -- |
---|
| 32 | $repository = new dcRepository( |
---|
| 33 | $core->plugins, |
---|
| 34 | $core->blog->settings->system->repository_plugin_url |
---|
| 35 | ); |
---|
| 36 | $repository->check(); |
---|
[0] | 37 | |
---|
[2150] | 38 | # -- Page helper -- |
---|
| 39 | $list = new adminModulesList( |
---|
| 40 | $core, |
---|
| 41 | DC_PLUGINS_ROOT, |
---|
| 42 | $core->blog->settings->system->plugins_allow_multi_install |
---|
| 43 | ); |
---|
[0] | 44 | |
---|
[2171] | 45 | $list::setDistributedModules(array( |
---|
| 46 | 'aboutConfig', |
---|
| 47 | 'akismet', |
---|
| 48 | 'antispam', |
---|
| 49 | 'attachments', |
---|
| 50 | 'blogroll', |
---|
| 51 | 'blowupConfig', |
---|
| 52 | 'daInstaller', |
---|
| 53 | 'fairTrackbacks', |
---|
| 54 | 'importExport', |
---|
| 55 | 'maintenance', |
---|
| 56 | 'pages', |
---|
| 57 | 'pings', |
---|
| 58 | 'simpleMenu', |
---|
| 59 | 'tags', |
---|
| 60 | 'themeEditor', |
---|
| 61 | 'userPref', |
---|
| 62 | 'widgets' |
---|
| 63 | )); |
---|
[2163] | 64 | |
---|
| 65 | # -- Check for module configuration -- |
---|
| 66 | $conf_file = false; |
---|
| 67 | if (!empty($_REQUEST['conf']) && !empty($_REQUEST['module'])) { |
---|
| 68 | if (!$core->plugins->moduleExists($_REQUEST['module'])) { |
---|
| 69 | $core->error->add(__('Unknow module ID')); |
---|
| 70 | } |
---|
| 71 | else { |
---|
| 72 | $module = $core->plugins->getModules($_REQUEST['module']); |
---|
[2174] | 73 | $module = adminModulesList::parseModuleInfo($_REQUEST['module'], $module); |
---|
[2163] | 74 | |
---|
| 75 | if (!file_exists(path::real($module['root'].'/_config.php'))) { |
---|
| 76 | $core->error->add(__('This module has no configuration file.')); |
---|
| 77 | } |
---|
| 78 | else { |
---|
| 79 | $conf_file = path::real($module['root'].'/_config.php'); |
---|
| 80 | } |
---|
| 81 | } |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | # -- Display module configuration page -- |
---|
| 85 | if ($conf_file) { |
---|
| 86 | dcPage::open(__('Plugins management'), |
---|
| 87 | |
---|
| 88 | # --BEHAVIOR-- pluginsToolsHeaders |
---|
| 89 | $core->callBehavior('pluginsToolsHeaders', $core, $module['id']), |
---|
| 90 | |
---|
| 91 | dcPage::breadcrumb( |
---|
| 92 | array( |
---|
| 93 | html::escapeHTML($core->blog->name) => '', |
---|
| 94 | '<a href="'.$list->getPageURL().'">'.__('Plugins management').'</a>' => '', |
---|
| 95 | '<span class="page-title">'.__('Plugin configuration').'</span>' => '' |
---|
| 96 | )) |
---|
| 97 | ); |
---|
| 98 | |
---|
| 99 | if (!empty($_GET['done'])){ |
---|
| 100 | dcPage::success(__('Plugin successfully configured.')); |
---|
| 101 | } |
---|
| 102 | |
---|
| 103 | try { |
---|
| 104 | if (!$module['standalone_config']) { |
---|
| 105 | echo |
---|
| 106 | '<form id="module_config" action="'.$list->getPageURL('conf=1').'" method="post" enctype="multipart/form-data">'. |
---|
| 107 | '<h3>'.sprintf(__('Configure plugin "%s"'), html::escapeHTML($module['name'])).'</h3>'. |
---|
| 108 | '<p><a class="back" href="'.$list->getPageURL().'#plugins">'.__('Back').'</a></p>'; |
---|
| 109 | } |
---|
[2165] | 110 | define('DC_CONTEXT_PLUGIN', true); |
---|
[2163] | 111 | |
---|
| 112 | include $conf_file; |
---|
| 113 | |
---|
| 114 | if (!$module['standalone_config']) { |
---|
| 115 | echo |
---|
| 116 | '<p class="clear"><input type="submit" name="save" value="'.__('Save').'" />'. |
---|
| 117 | form::hidden('module', $module['id']). |
---|
| 118 | $core->formNonce().'</p>'. |
---|
| 119 | '</form>'; |
---|
| 120 | } |
---|
| 121 | } |
---|
| 122 | catch (Exception $e) { |
---|
| 123 | echo '<div class="error"><p>'.$e->getMessage().'</p></div>'; |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | dcPage::close(); |
---|
| 127 | |
---|
| 128 | # Stop reading code here |
---|
| 129 | return; |
---|
| 130 | } |
---|
| 131 | |
---|
[2150] | 132 | # -- Execute actions -- |
---|
[2171] | 133 | if (!empty($_POST) && empty($_REQUEST['conf']) && $core->auth->isSuperAdmin() && $list->isPathWritable()) { |
---|
| 134 | try { |
---|
| 135 | $list->executeAction('plugins', $core->plugins, $repository); |
---|
[2150] | 136 | } |
---|
[2171] | 137 | catch (Exception $e) { |
---|
| 138 | $core->error->add($e->getMessage()); |
---|
[0] | 139 | } |
---|
| 140 | } |
---|
| 141 | |
---|
[2150] | 142 | # -- Plugin install -- |
---|
| 143 | $plugins_install = null; |
---|
| 144 | if (!$core->error->flag()) { |
---|
| 145 | $plugins_install = $core->plugins->installModules(); |
---|
| 146 | } |
---|
[0] | 147 | |
---|
[2150] | 148 | # -- Page header -- |
---|
[0] | 149 | dcPage::open(__('Plugins management'), |
---|
| 150 | dcPage::jsLoad('js/_plugins.js'). |
---|
[2150] | 151 | dcPage::jsPageTabs(). |
---|
[2156] | 152 | |
---|
| 153 | # --BEHAVIOR-- pluginsToolsHeaders |
---|
[2163] | 154 | $core->callBehavior('pluginsToolsHeaders', $core, false), |
---|
[2156] | 155 | |
---|
[1358] | 156 | dcPage::breadcrumb( |
---|
| 157 | array( |
---|
| 158 | __('System') => '', |
---|
| 159 | '<span class="page-title">'.__('Plugins management').'</span>' => '' |
---|
| 160 | )) |
---|
[0] | 161 | ); |
---|
| 162 | |
---|
[2150] | 163 | # -- Succes messages -- |
---|
| 164 | if (!empty($_GET['msg'])) { |
---|
[2171] | 165 | $list->displayMessage($_GET['msg']); |
---|
[0] | 166 | } |
---|
| 167 | |
---|
[2150] | 168 | # -- Plugins install messages -- |
---|
| 169 | if (!empty($plugins_install['success'])) { |
---|
| 170 | echo |
---|
| 171 | '<div class="static-msg">'.__('Following plugins have been installed:').'<ul>'; |
---|
[0] | 172 | foreach ($plugins_install['success'] as $k => $v) { |
---|
[2150] | 173 | echo |
---|
| 174 | '<li>'.$k.'</li>'; |
---|
[0] | 175 | } |
---|
[2150] | 176 | echo |
---|
| 177 | '</ul></div>'; |
---|
[0] | 178 | } |
---|
[2150] | 179 | if (!empty($plugins_install['failure'])) { |
---|
| 180 | echo |
---|
| 181 | '<div class="error">'.__('Following plugins have not been installed:').'<ul>'; |
---|
[0] | 182 | foreach ($plugins_install['failure'] as $k => $v) { |
---|
[2150] | 183 | echo |
---|
| 184 | '<li>'.$k.' ('.$v.')</li>'; |
---|
[0] | 185 | } |
---|
[2150] | 186 | echo |
---|
| 187 | '</ul></div>'; |
---|
| 188 | } |
---|
| 189 | |
---|
| 190 | # -- Display modules lists -- |
---|
| 191 | if ($core->auth->isSuperAdmin() && $list->isPathWritable()) { |
---|
| 192 | |
---|
| 193 | # Updated modules from repo |
---|
| 194 | $modules = $repository->get(true); |
---|
| 195 | if (!empty($modules)) { |
---|
| 196 | echo |
---|
| 197 | '<div class="multi-part" id="update" title="'.html::escapeHTML(__('Update plugins')).'">'. |
---|
| 198 | '<h3>'.html::escapeHTML(__('Update plugins')).'</h3>'. |
---|
| 199 | '<p>'.sprintf( |
---|
| 200 | __('There is one plugin to update available from %2$s.', 'There are %s plugins to update available from %s.', count($modules)), |
---|
| 201 | count($modules), |
---|
[2158] | 202 | '<a href="http://dotaddict.org/dc2/plugins">Dotaddict</a>' |
---|
[2150] | 203 | ).'</p>'; |
---|
| 204 | |
---|
| 205 | $list |
---|
[2156] | 206 | ->newList('plugin-update') |
---|
[2150] | 207 | ->setModules($modules) |
---|
| 208 | ->setPageTab('update') |
---|
| 209 | ->displayModulesList( |
---|
[2156] | 210 | /*cols */ array('icon', 'name', 'version', 'current_version', 'desc'), |
---|
[2150] | 211 | /* actions */ array('update') |
---|
| 212 | ); |
---|
| 213 | |
---|
| 214 | echo |
---|
| 215 | '</div>'; |
---|
| 216 | } |
---|
[0] | 217 | } |
---|
| 218 | |
---|
| 219 | # List all active plugins |
---|
[2150] | 220 | echo |
---|
| 221 | '<div class="multi-part" id="plugins" title="'.__('Installed plugins').'">'; |
---|
[0] | 222 | |
---|
[2150] | 223 | $modules = $core->plugins->getModules(); |
---|
| 224 | if (!empty($modules)) { |
---|
[0] | 225 | |
---|
| 226 | echo |
---|
| 227 | '<h3>'.__('Activated plugins').'</h3>'. |
---|
[2158] | 228 | '<p>'.__('Manage installed plugins from this list.').'</p>'; |
---|
[926] | 229 | |
---|
[2150] | 230 | $list |
---|
[2156] | 231 | ->newList('plugin-activate') |
---|
[2150] | 232 | ->setModules($modules) |
---|
| 233 | ->setPageTab('plugins') |
---|
| 234 | ->displayModulesList( |
---|
[2156] | 235 | /* cols */ array('expander', 'icon', 'name', 'config', 'version', 'desc', 'distrib'), |
---|
[2150] | 236 | /* actions */ array('deactivate', 'delete') |
---|
| 237 | ); |
---|
[0] | 238 | } |
---|
| 239 | |
---|
[2150] | 240 | # Deactivated modules |
---|
| 241 | $modules = $core->plugins->getDisabledModules(); |
---|
| 242 | if (!empty($modules)) { |
---|
| 243 | |
---|
[0] | 244 | echo |
---|
| 245 | '<h3>'.__('Deactivated plugins').'</h3>'. |
---|
[2150] | 246 | '<p>'.__('Deactivated plugins are installed but not usable. You can activate them from here.').'</p>'; |
---|
| 247 | |
---|
| 248 | $list |
---|
[2156] | 249 | ->newList('plugin-deactivate') |
---|
[2150] | 250 | ->setModules($modules) |
---|
| 251 | ->setPageTab('plugins') |
---|
| 252 | ->displayModulesList( |
---|
| 253 | /* cols */ array('icon', 'name', 'distrib'), |
---|
| 254 | /* actions */ array('activate', 'delete') |
---|
| 255 | ); |
---|
[0] | 256 | } |
---|
| 257 | |
---|
[2150] | 258 | echo |
---|
| 259 | '</div>'; |
---|
[0] | 260 | |
---|
[2150] | 261 | if ($core->auth->isSuperAdmin() && $list->isPathWritable()) { |
---|
[0] | 262 | |
---|
[2150] | 263 | # New modules from repo |
---|
| 264 | $search = $list->getSearchQuery(); |
---|
| 265 | $modules = $search ? $repository->search($search) : $repository->get(); |
---|
| 266 | |
---|
| 267 | echo |
---|
[2157] | 268 | '<div class="multi-part" id="new" title="'.__('Add plugins from Dotaddict').'">'. |
---|
| 269 | '<h3>'.__('Add plugins from Dotaddict repository').'</h3>'; |
---|
[2150] | 270 | |
---|
| 271 | $list |
---|
[2156] | 272 | ->newList('plugin-new') |
---|
[2150] | 273 | ->setModules($modules) |
---|
| 274 | ->setPageTab('new') |
---|
| 275 | ->displaySearchForm() |
---|
| 276 | ->displayNavMenu() |
---|
| 277 | ->displayModulesList( |
---|
[2156] | 278 | /* cols */ array('expander', 'name', 'version', 'desc'), |
---|
[2150] | 279 | /* actions */ array('install'), |
---|
| 280 | /* nav limit */ true |
---|
| 281 | ); |
---|
| 282 | |
---|
| 283 | echo |
---|
[2158] | 284 | '<p class="info vertical-separator">'.sprintf( |
---|
[2157] | 285 | __("Visit %s repository, the resources center for Dotclear."), |
---|
| 286 | '<a href="http://dotaddict.org/dc2/plugins">Dotaddict</a>' |
---|
[2158] | 287 | ). |
---|
| 288 | '</p>'. |
---|
| 289 | |
---|
[2150] | 290 | '</div>'; |
---|
| 291 | |
---|
| 292 | # Add a new plugin |
---|
| 293 | echo |
---|
[2157] | 294 | '<div class="multi-part" id="addplugin" title="'.__('Install or upgrade manually').'">'; |
---|
[2150] | 295 | |
---|
[0] | 296 | echo '<p>'.__('You can install plugins by uploading or downloading zip files.').'</p>'; |
---|
| 297 | |
---|
[2171] | 298 | $list->displayManualForm(); |
---|
[2150] | 299 | |
---|
| 300 | echo |
---|
| 301 | '</div>'; |
---|
[0] | 302 | } |
---|
| 303 | |
---|
| 304 | # --BEHAVIOR-- pluginsToolsTabs |
---|
[2150] | 305 | $core->callBehavior('pluginsToolsTabs', $core); |
---|
| 306 | |
---|
| 307 | # -- Notice for super admin -- |
---|
| 308 | if ($core->auth->isSuperAdmin() && !$list->isPathWritable()) { |
---|
| 309 | echo |
---|
| 310 | '<p class="warning">'.__('Some functions are disabled, please give write access to your plugins directory to enable them.').'</p>'; |
---|
| 311 | } |
---|
[0] | 312 | |
---|
| 313 | dcPage::close(); |
---|
| 314 | ?> |
---|