Dotclear

source: admin/plugins.php @ 2237:911f18a5b287

Revision 2237:911f18a5b287, 6.8 KB checked in by Anne Kozlika <kozlika@…>, 12 years ago (diff)

Essentiellement des changements d'images

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

Sites map