Dotclear

source: admin/blog_theme.php @ 3730:5c45a5df9a59

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

Code formatting (PSR-2)

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
[3730]13require dirname(__FILE__) . '/../inc/admin/prepend.php';
[0]14
15dcPage::check('admin');
16
[2171]17# -- Loading themes --
[0]18$core->themes = new dcThemes($core);
[2171]19$core->themes->loadModules($core->blog->themes_path, null);
[0]20
[2215]21# -- Page helper --
22$list = new adminThemesList(
[3730]23    $core->themes,
24    $core->blog->themes_path,
25    $core->blog->settings->system->store_theme_url
[2171]26);
[2286]27adminThemesList::$distributed_modules = explode(',', DC_DISTRIB_THEMES);
[2171]28
29# -- Theme screenshot --
[2215]30if (!empty($_GET['shot']) && $list->modules->moduleExists($_GET['shot'])) {
31
[3730]32    $f = path::real(empty($_GET['src']) ?
33        $core->blog->themes_path . '/' . $_GET['shot'] . '/screenshot.jpg' :
34        $core->blog->themes_path . '/' . $_GET['shot'] . '/' . path::clean($_GET['src'])
35    );
[2215]36
[3730]37    if (!file_exists($f)) {
38        $f = dirname(__FILE__) . '/images/noscreenshot.png';
39    }
[2215]40
[3730]41    http::cache(array_merge(array($f), get_included_files()));
[2215]42
[3730]43    header('Content-Type: ' . files::getMimeType($f));
44    header('Content-Length: ' . filesize($f));
45    readfile($f);
[2215]46
[3730]47    exit;
[0]48}
49
[2182]50# -- Display module configuration page --
[2227]51if ($list->setConfiguration($core->blog->settings->system->theme)) {
[0]52
[3730]53    # Get content before page headers
54    include $list->includeConfiguration();
[2166]55
[3730]56    # Gather content
57    $list->getConfiguration();
[2182]58
[3730]59    # Display page
60    dcPage::open(__('Blog appearance'),
61        dcPage::jsPageTabs() .
62        dcPage::jsColorPicker() .
[2171]63
[3730]64        # --BEHAVIOR-- themesToolsHeaders
65        $core->callBehavior('themesToolsHeaders', $core, true),
[2171]66
[3730]67        dcPage::breadcrumb(
68            array(
69                html::escapeHTML($core->blog->name)                                 => '',
70                __('Blog appearance')                                               => $list->getURL('', false),
71                '<span class="page-title">' . __('Theme configuration') . '</span>' => ''
72            ))
73    );
[2189]74
[3730]75    # Display previously gathered content
76    $list->displayConfiguration();
[2171]77
[3730]78    dcPage::helpBlock('core_blog_theme_conf');
79    dcPage::close();
[2171]80
[3730]81    # Stop reading code here
82    return;
[0]83}
84
[2171]85# -- Execute actions --
[2215]86try {
[3730]87    $list->doActions();
88} catch (Exception $e) {
89    $core->error->add($e->getMessage());
[0]90}
91
[2171]92# -- Page header --
93dcPage::open(__('Themes management'),
[3730]94    dcPage::jsLoad('js/_blog_theme.js') .
95    dcPage::jsPageTabs() .
96    dcPage::jsColorPicker() .
[2171]97
[3730]98    # --BEHAVIOR-- themesToolsHeaders
99    $core->callBehavior('themesToolsHeaders', $core, false),
[2171]100
[3730]101    dcPage::breadcrumb(
102        array(
103            html::escapeHTML($core->blog->name)                             => '',
104            '<span class="page-title">' . __('Blog appearance') . '</span>' => ''
105        ))
[2171]106);
107
108# -- Display modules lists --
[3018]109if ($core->auth->isSuperAdmin()) {
[2171]110
[3730]111    # Updated modules from repo
112    $modules = $list->store->get(true);
113    if (!empty($modules)) {
114        echo
115        '<div class="multi-part" id="update" title="' . html::escapeHTML(__('Update themes')) . '">' .
116        '<h3>' . html::escapeHTML(__('Update themes')) . '</h3>' .
117        '<p>' . sprintf(
118            __('There is one theme to update available from repository.', 'There are %s themes to update available from repository.', count($modules)),
119            count($modules)
120        ) . '</p>';
[2171]121
[3730]122        $list
123            ->setList('theme-update')
124            ->setTab('themes')
125            ->setModules($modules)
126            ->displayModules(
127                /*cols */array('checkbox', 'name', 'sshot', 'desc', 'author', 'version', 'current_version', 'parent'),
128                /* actions */array('update', 'delete')
129            );
[2171]130
[3730]131        echo
132        '<p class="info vertical-separator">' . sprintf(
133            __("Visit %s repository, the resources center for Dotclear."),
134            '<a href="http://themes.dotaddict.org/galerie-dc2/">Dotaddict</a>'
135        ) .
136            '</p>' .
[2227]137
[3730]138            '</div>';
139    }
[0]140}
141
[2227]142# Activated modules
[2215]143$modules = $list->modules->getModules();
[2171]144if (!empty($modules)) {
145
[3730]146    echo
147    '<div class="multi-part" id="themes" title="' . __('Installed themes') . '">' .
148    '<h3>' . __('Installed themes') . '</h3>' .
149    '<p class="more-info">' . __('You can configure and manage installed themes from this list.') . '</p>';
[2171]150
[3730]151    $list
152        ->setList('theme-activate')
153        ->setTab('themes')
154        ->setModules($modules)
155        ->displayModules(
156            /* cols */array('sshot', 'distrib', 'name', 'config', 'desc', 'author', 'version', 'parent'),
157            /* actions */array('select', 'behavior', 'deactivate', 'delete')
158        );
[2227]159
[3730]160    echo
161        '</div>';
[0]162}
163
[2227]164# Deactivated modules
[2215]165$modules = $list->modules->getDisabledModules();
[2192]166if (!empty($modules)) {
167
[3730]168    echo
169    '<div class="multi-part" id="deactivate" title="' . __('Deactivated themes') . '">' .
170    '<h3>' . __('Deactivated themes') . '</h3>' .
171    '<p class="more-info">' . __('Deactivated themes are installed but not usable. You can activate them from here.') . '</p>';
[2192]172
[3730]173    $list
174        ->setList('theme-deactivate')
175        ->setTab('themes')
176        ->setModules($modules)
177        ->displayModules(
178            /* cols */array('name', 'distrib'),
179            /* actions */array('activate', 'delete')
180        );
[2227]181
[3730]182    echo
183        '</div>';
[0]184}
185
[2227]186if ($core->auth->isSuperAdmin() && $list->isWritablePath()) {
[0]187
[3730]188    # New modules from repo
189    $search  = $list->getSearch();
190    $modules = $search ? $list->store->search($search) : $list->store->get();
[1332]191
[3730]192    if (!empty($search) || !empty($modules)) {
193        echo
194        '<div class="multi-part" id="new" title="' . __('Add themes') . '">' .
195        '<h3>' . __('Add themes from repository') . '</h3>';
196//        '<p>'.__('Search and install themes directly from repository.').'</p>';
[2171]197
[3730]198        $list
199            ->setList('theme-new')
200            ->setTab('new')
201            ->setModules($modules)
202            ->displaySearch()
203            ->displayIndex()
204            ->displayModules(
205                /* cols */array('expander', 'sshot', 'name', 'score', 'config', 'desc', 'author', 'version', 'parent', 'details', 'support'),
206                /* actions */array('install'),
207                /* nav limit */true
208            );
[2171]209
[3730]210        echo
211        '<p class="info vertical-separator">' . sprintf(
212            __("Visit %s repository, the resources center for Dotclear."),
213            '<a href="http://themes.dotaddict.org/galerie-dc2/">Dotaddict</a>'
214        ) .
215            '</p>' .
[2171]216
[3730]217            '</div>';
218    }
[2171]219
[3730]220    # Add a new plugin
221    echo
222    '<div class="multi-part" id="addtheme" title="' . __('Install or upgrade manually') . '">' .
223    '<h3>' . __('Add themes from a package') . '</h3>' .
224    '<p class="more-info">' . __('You can install themes by uploading or downloading zip files.') . '</p>';
[2171]225
[3730]226    $list->displayManualForm();
[684]227
[3730]228    echo
229        '</div>';
[0]230}
231
[2282]232# --BEHAVIOR-- themesToolsTabs
233$core->callBehavior('themesToolsTabs', $core);
[3018]234
235# -- Notice for super admin --
236if ($core->auth->isSuperAdmin() && !$list->isWritablePath()) {
[3730]237    echo
238    '<p class="warning">' . __('Some functions are disabled, please give write access to your themes directory to enable them.') . '</p>';
[3018]239}
240
[2314]241dcPage::helpBlock('core_blog_theme');
[0]242dcPage::close();
Note: See TracBrowser for help on using the repository browser.

Sites map