Dotclear

source: admin/blog_theme.php @ 2215:0775c8672865

Revision 2215:0775c8672865, 6.1 KB checked in by Denis Jean-Chirstian <contact@…>, 12 years ago (diff)

Calls to dcModules and dcRepository from plugins and themes page are now through adminModulesList, cleaner and healthy

Line 
1<?php
2# -- BEGIN LICENSE BLOCK ---------------------------------------
3#
4# This file is part of Dotclear 2.
5#
6# Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear
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
15dcPage::check('admin');
16
17# -- "First time" settings setup --
18if ($core->blog->settings->system->repository_theme_url === null) {
19     $core->blog->settings->system->put(
20          'repository_theme_url', 'http://update.dotaddict.org/dc2/themes.xml', 'string', 'Themes XML feed location', true, true
21     );
22}
23
24# -- Loading themes --
25$core->themes = new dcThemes($core);
26$core->themes->loadModules($core->blog->themes_path, null);
27
28# -- Page helper --
29$list = new adminThemesList(
30     $core->themes, 
31     $core->blog->themes_path,
32     $core->blog->settings->system->repository_theme_url
33);
34$list::$distributed_modules = array(
35     'blueSilence',
36     'blowupConfig',
37     'customCSS',
38     'default',
39     'ductile'
40);
41
42# -- Theme screenshot --
43if (!empty($_GET['shot']) && $list->modules->moduleExists($_GET['shot'])) {
44
45     $f= path::real(empty($_GET['src']) ?
46          $core->blog->themes_path.'/'.$_GET['shot'].'/screenshot.jpg' :
47          $core->blog->themes_path.'/'.$_GET['shot'].'/'.path::clean($_GET['src'])
48     );
49
50     if (!file_exists($f)) {
51          $f = dirname(__FILE__).'/images/noscreenshot.png';
52     }
53
54     http::cache(array_merge(array($f), get_included_files()));
55
56     header('Content-Type: '.files::getMimeType($f));
57     header('Content-Length: '.filesize($f));
58     readfile($f);
59
60     exit;
61}
62
63# -- Display module configuration page --
64if ($list->setConfigurationFile($core->blog->settings->system->theme)) {
65
66     # Get content before page headers
67     include $list->getConfigurationFile();
68
69     # Gather content
70     $list->setConfigurationContent();
71
72     # Display page
73     dcPage::open(__('Blog appearance'),
74          dcPage::jsPageTabs().
75          dcPage::jsColorPicker().
76
77          # --BEHAVIOR-- themesToolsHeaders
78          $core->callBehavior('themesToolsHeaders', $core, true),
79
80          dcPage::breadcrumb(
81               array(
82                    html::escapeHTML($core->blog->name) => '',
83                    __('Blog appearance') => 'blog_theme.php',
84                    '<span class="page-title">'.__('Theme configuration').'</span>' => ''
85               ))
86     );
87
88     if (!empty($_GET['done'])){
89          dcPage::success(__('Theme successfully configured.'));
90     }
91
92     # Display previously gathered content
93     $list->getConfigurationContent();
94
95     dcPage::close();
96
97     # Stop reading code here
98     return;
99}
100
101# -- Execute actions --
102try {
103     $list->doActions('themes');
104}
105catch (Exception $e) {
106     $core->error->add($e->getMessage());
107}
108
109# -- Page header --
110dcPage::open(__('Themes management'),
111     dcPage::jsLoad('js/_blog_theme.js').
112     dcPage::jsPageTabs().
113     dcPage::jsColorPicker(),
114
115     # --BEHAVIOR-- themesToolsHeaders
116     $core->callBehavior('themesToolsHeaders', $core, false),
117
118     dcPage::breadcrumb(
119          array(
120               html::escapeHTML($core->blog->name) => '',
121               '<span class="page-title">'.__('Blog appearance').'</span>' => ''
122          ))
123);
124
125# -- Succes messages --
126if (!empty($_GET['msg'])) {
127     $list->displayMessage($_GET['msg']);
128}
129
130# -- Display modules lists --
131if ($core->auth->isSuperAdmin() && $list->isPathWritable()) {
132
133     # Updated modules from repo
134     $modules = $list->repository->get(true);
135     if (!empty($modules)) {
136          echo 
137          '<div class="multi-part" id="update" title="'.html::escapeHTML(__('Update themes')).'">'.
138          '<h3>'.html::escapeHTML(__('Update themes')).'</h3>'.
139          '<p>'.sprintf(
140               __('There is one theme to update available from %2$s.', 'There are %s themes to update available from %s.', count($modules)),
141               count($modules),
142               '<a href="http://dotaddict.org/dc2/themes">Dotaddict</a>'
143          ).'</p>';
144
145          $list
146               ->newList('theme-update')
147               ->setModules($modules)
148               ->setPageTab('update')
149               ->displayModulesList(
150                    /*cols */      array('sshot', 'name', 'desc', 'author', 'version', 'current_version', 'parent'),
151                    /* actions */  array('update')
152               );
153
154          echo
155          '</div>';
156     }
157}
158
159# List all active plugins
160echo
161'<div class="multi-part" id="themes" title="'.__('Installed themes').'">';
162
163$modules = $list->modules->getModules();
164if (!empty($modules)) {
165
166     echo
167     '<h3>'.__('Activated themes').'</h3>'.
168     '<p>'.__('Manage installed themes from this list.').'</p>';
169
170     $list
171          ->newList('theme-activate')
172          ->setModules($modules)
173          ->setPageTab('themes')
174          ->displayModulesList(
175               /* cols */          array('sshot', 'distrib', 'name', 'config', 'desc', 'author', 'version', 'parent'),
176               /* actions */  array('select', 'deactivate', 'delete')
177          );
178}
179
180$modules = $list->modules->getDisabledModules();
181if (!empty($modules)) {
182
183     echo
184     '<h3>'.__('Deactivated themes').'</h3>'.
185     '<p>'.__('Deactivated themes are installed but not usable. You can activate them from here.').'</p>';
186
187     $list
188          ->newList('theme-deactivate')
189          ->setModules($modules)
190          ->setPageTab('themes')
191          ->displayModulesList(
192               /* cols */          array('name', 'distrib'),
193               /* actions */  array('activate', 'delete')
194          );
195}
196
197echo 
198'</div>';
199
200if ($core->auth->isSuperAdmin() && $list->isPathWritable()) {
201
202     # New modules from repo
203     $search = $list->getSearchQuery();
204     $modules = $search ? $list->repository->search($search) : $list->repository->get();
205
206     if (!empty($search) || !empty($modules)) {
207          echo
208          '<div class="multi-part" id="new" title="'.__('Add themes from Dotaddict').'">'.
209          '<h3>'.__('Add themes from Dotaddict repository').'</h3>';
210
211          $list
212               ->newList('theme-new')
213               ->setModules($modules)
214               ->setPageTab('new')
215               ->displaySearchForm()
216               ->displayNavMenu()
217               ->displayModulesList(
218                    /* cols */          array('expander', 'sshot', 'name', 'config', 'desc', 'author', 'version', 'parent', 'details', 'support'),
219                    /* actions */  array('install'),
220                    /* nav limit */     true
221               );
222
223          echo
224          '<p class="info vertical-separator">'.sprintf(
225               __("Visit %s repository, the resources center for Dotclear."),
226               '<a href="http://dotaddict.org/dc2/themes">Dotaddict</a>'
227               ).
228          '</p>'.
229
230          '</div>';
231     }
232
233     # Add a new plugin
234     echo
235     '<div class="multi-part" id="addtheme" title="'.__('Install or upgrade manually').'">'.
236     '<p>'.__('You can install themes by uploading or downloading zip files.').'</p>';
237
238     $list->displayManualForm();
239
240     echo
241     '</div>';
242}
243
244dcPage::close();
Note: See TracBrowser for help on using the repository browser.

Sites map