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