Dotclear

source: admin/plugins.php @ 3874:ab8368569446

Revision 3874:ab8368569446, 7.4 KB checked in by franck <carnet.franck.paul@…>, 7 years ago (diff)

short notation for array (array() → [])

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

Sites map