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

Line 
1<?php
2/**
3 * @package Dotclear
4 * @subpackage Backend
5 *
6 * @copyright Olivier Meunier & Association Dotclear
7 * @copyright GPL-2.0-only
8 */
9
10require dirname(__FILE__) . '/../inc/admin/prepend.php';
11
12dcPage::check('admin');
13
14# -- Loading themes --
15$core->themes = new dcThemes($core);
16$core->themes->loadModules($core->blog->themes_path, null);
17
18# -- Page helper --
19$list = new adminThemesList(
20    $core->themes,
21    $core->blog->themes_path,
22    $core->blog->settings->system->store_theme_url
23);
24adminThemesList::$distributed_modules = explode(',', DC_DISTRIB_THEMES);
25
26# -- Theme screenshot --
27if (!empty($_GET['shot']) && $list->modules->moduleExists($_GET['shot'])) {
28
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    );
33
34    if (!file_exists($f)) {
35        $f = dirname(__FILE__) . '/images/noscreenshot.png';
36    }
37
38    http::cache(array_merge(array($f), get_included_files()));
39
40    header('Content-Type: ' . files::getMimeType($f));
41    header('Content-Length: ' . filesize($f));
42    readfile($f);
43
44    exit;
45}
46
47# -- Display module configuration page --
48if ($list->setConfiguration($core->blog->settings->system->theme)) {
49
50    # Get content before page headers
51    include $list->includeConfiguration();
52
53    # Gather content
54    $list->getConfiguration();
55
56    # Display page
57    dcPage::open(__('Blog appearance'),
58        dcPage::jsPageTabs() .
59        dcPage::jsColorPicker() .
60
61        # --BEHAVIOR-- themesToolsHeaders
62        $core->callBehavior('themesToolsHeaders', $core, true),
63
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    );
71
72    # Display previously gathered content
73    $list->displayConfiguration();
74
75    dcPage::helpBlock('core_blog_theme_conf');
76    dcPage::close();
77
78    # Stop reading code here
79    return;
80}
81
82# -- Execute actions --
83try {
84    $list->doActions();
85} catch (Exception $e) {
86    $core->error->add($e->getMessage());
87}
88
89# -- Page header --
90dcPage::open(__('Themes management'),
91    dcPage::jsLoad('js/_blog_theme.js') .
92    dcPage::jsPageTabs() .
93    dcPage::jsColorPicker() .
94
95    # --BEHAVIOR-- themesToolsHeaders
96    $core->callBehavior('themesToolsHeaders', $core, false),
97
98    dcPage::breadcrumb(
99        array(
100            html::escapeHTML($core->blog->name)                             => '',
101            '<span class="page-title">' . __('Blog appearance') . '</span>' => ''
102        ))
103);
104
105# -- Display modules lists --
106if ($core->auth->isSuperAdmin()) {
107
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>';
118
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            );
127
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>' .
134
135            '</div>';
136    }
137}
138
139# Activated modules
140$modules = $list->modules->getModules();
141if (!empty($modules)) {
142
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>';
147
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        );
156
157    echo
158        '</div>';
159}
160
161# Deactivated modules
162$modules = $list->modules->getDisabledModules();
163if (!empty($modules)) {
164
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>';
169
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        );
178
179    echo
180        '</div>';
181}
182
183if ($core->auth->isSuperAdmin() && $list->isWritablePath()) {
184
185    # New modules from repo
186    $search  = $list->getSearch();
187    $modules = $search ? $list->store->search($search) : $list->store->get();
188
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>';
194
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            );
206
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>' .
213
214            '</div>';
215    }
216
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>';
222
223    $list->displayManualForm();
224
225    echo
226        '</div>';
227}
228
229# --BEHAVIOR-- themesToolsTabs
230$core->callBehavior('themesToolsTabs', $core);
231
232# -- Notice for super admin --
233if ($core->auth->isSuperAdmin() && !$list->isWritablePath()) {
234    echo
235    '<p class="warning">' . __('Some functions are disabled, please give write access to your themes directory to enable them.') . '</p>';
236}
237
238dcPage::helpBlock('core_blog_theme');
239dcPage::close();
Note: See TracBrowser for help on using the repository browser.

Sites map