Dotclear

source: admin/blog_theme.php @ 3731:3770620079d4

Revision 3731:3770620079d4, 7.1 KB checked in by franck <carnet.franck.paul@…>, 7 years ago (diff)

Simplify licence block at the beginning of each file

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

Sites map