Dotclear

source: admin/plugins.php @ 2216:91f485a16187

Revision 2216:91f485a16187, 6.7 KB checked in by Denis Jean-Chirstian <contact@…>, 12 years ago (diff)

Rename dcRepository to dcStore because of dotAddict used this name

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 --
[2215]58if ($list->setConfigurationFile()) {
[2163]59
[2182]60     # Get content before page headers
61     include $list->getConfigurationFile();
[0]62
[2182]63     # Gather content
64     $list->setConfigurationContent();
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) => '',
75                    '<a href="'.$list->getPageURL().'">'.__('Plugins management').'</a>' => '',
76                    '<span class="page-title">'.__('Plugin configuration').'</span>' => ''
77               ))
78     );
79
[2182]80     # Message
[2163]81     if (!empty($_GET['done'])){
82          dcPage::success(__('Plugin successfully configured.'));
83     }
84
[2182]85     # Display previously gathered content
86     $list->getConfigurationContent();
[2163]87
88     dcPage::close();
89
90     # Stop reading code here
91     return;
92}
93
[2150]94# -- Execute actions --
[2215]95try {
96     $list->doActions('plugins');
97}
98catch (Exception $e) {
99     $core->error->add($e->getMessage());
[2007]100}
101
[2150]102# -- Plugin install --
103$plugins_install = null;
104if (!$core->error->flag()) {
105     $plugins_install = $core->plugins->installModules();
106}
[2007]107
[2150]108# -- Page header --
[0]109dcPage::open(__('Plugins management'),
110     dcPage::jsLoad('js/_plugins.js').
[2150]111     dcPage::jsPageTabs().
[2156]112
113     # --BEHAVIOR-- pluginsToolsHeaders
[2163]114     $core->callBehavior('pluginsToolsHeaders', $core, false),
[2156]115
[1358]116     dcPage::breadcrumb(
117          array(
118               __('System') => '',
[2166]119               __('Plugins management') => ''
[1358]120          ))
[0]121);
122
[2150]123# -- Succes messages --
124if (!empty($_GET['msg'])) {
[2171]125     $list->displayMessage($_GET['msg']);
[0]126}
127
[2150]128# -- Plugins install messages --
129if (!empty($plugins_install['success'])) {
130     echo 
131     '<div class="static-msg">'.__('Following plugins have been installed:').'<ul>';
[2215]132
[0]133     foreach ($plugins_install['success'] as $k => $v) {
[2150]134          echo 
135          '<li>'.$k.'</li>';
[0]136     }
[2150]137     echo 
[2215]138
[2150]139     '</ul></div>';
[0]140}
[2150]141if (!empty($plugins_install['failure'])) {
142     echo 
143     '<div class="error">'.__('Following plugins have not been installed:').'<ul>';
[2215]144
[0]145     foreach ($plugins_install['failure'] as $k => $v) {
[2150]146          echo 
147          '<li>'.$k.' ('.$v.')</li>';
[0]148     }
[2215]149
[2150]150     echo 
151     '</ul></div>';
152}
153
154# -- Display modules lists --
155if ($core->auth->isSuperAdmin() && $list->isPathWritable()) {
156
157     # Updated modules from repo
[2216]158     $modules = $list->store->get(true);
[2150]159     if (!empty($modules)) {
160          echo 
161          '<div class="multi-part" id="update" title="'.html::escapeHTML(__('Update plugins')).'">'.
162          '<h3>'.html::escapeHTML(__('Update plugins')).'</h3>'.
163          '<p>'.sprintf(
164               __('There is one plugin to update available from %2$s.', 'There are %s plugins to update available from %s.', count($modules)),
165               count($modules),
[2158]166               '<a href="http://dotaddict.org/dc2/plugins">Dotaddict</a>'
[2150]167          ).'</p>';
168
169          $list
[2156]170               ->newList('plugin-update')
[2150]171               ->setModules($modules)
172               ->setPageTab('update')
173               ->displayModulesList(
[2156]174                    /*cols */      array('icon', 'name', 'version', 'current_version', 'desc'),
[2150]175                    /* actions */  array('update')
176               );
177
178          echo
179          '</div>';
180     }
[0]181}
182
183# List all active plugins
[2150]184echo
185'<div class="multi-part" id="plugins" title="'.__('Installed plugins').'">';
[0]186
[2215]187$modules = $list->modules->getModules();
[2150]188if (!empty($modules)) {
[0]189     echo
190     '<h3>'.__('Activated plugins').'</h3>'.
[2158]191     '<p>'.__('Manage installed plugins from this list.').'</p>';
[926]192
[2150]193     $list
[2156]194          ->newList('plugin-activate')
[2150]195          ->setModules($modules)
196          ->setPageTab('plugins')
197          ->displayModulesList(
[2156]198               /* cols */          array('expander', 'icon', 'name', 'config', 'version', 'desc', 'distrib'),
[2150]199               /* actions */  array('deactivate', 'delete')
200          );
[0]201}
202
[2150]203# Deactivated modules
[2215]204$modules = $list->modules->getDisabledModules();
[2150]205if (!empty($modules)) {
[0]206     echo
207     '<h3>'.__('Deactivated plugins').'</h3>'.
[2150]208     '<p>'.__('Deactivated plugins are installed but not usable. You can activate them from here.').'</p>';
209
210     $list
[2156]211          ->newList('plugin-deactivate')
[2150]212          ->setModules($modules)
213          ->setPageTab('plugins')
214          ->displayModulesList(
215               /* cols */          array('icon', 'name', 'distrib'),
216               /* actions */  array('activate', 'delete')
217          );
[0]218}
219
[2150]220echo 
221'</div>';
[0]222
[2150]223if ($core->auth->isSuperAdmin() && $list->isPathWritable()) {
[0]224
[2150]225     # New modules from repo
226     $search = $list->getSearchQuery();
[2216]227     $modules = $search ? $list->store->search($search) : $list->store->get();
[2150]228
[2215]229     if (!empty($search) || !empty($modules)) {
230          echo
231          '<div class="multi-part" id="new" title="'.__('Add plugins from Dotaddict').'">'.
232          '<h3>'.__('Add plugins from Dotaddict repository').'</h3>';
[2150]233
[2215]234          $list
235               ->newList('plugin-new')
236               ->setModules($modules)
237               ->setPageTab('new')
238               ->displaySearchForm()
239               ->displayNavMenu()
240               ->displayModulesList(
241                    /* cols */          array('expander', 'name', 'version', 'desc'),
242                    /* actions */  array('install'),
243                    /* nav limit */     true
244               );
[2150]245
[2215]246          echo
247          '<p class="info vertical-separator">'.sprintf(
248               __("Visit %s repository, the resources center for Dotclear."),
249               '<a href="http://dotaddict.org/dc2/plugins">Dotaddict</a>'
250               ).
251          '</p>'.
[2158]252
[2215]253          '</div>';
254     }
[2150]255
256     # Add a new plugin
257     echo
[2215]258     '<div class="multi-part" id="addplugin" title="'.__('Install or upgrade manually').'">'.
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 --
271if ($core->auth->isSuperAdmin() && !$list->isPathWritable()) {
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