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