Dotclear

source: admin/blog_theme.php @ 2241:4168cffbc76e

Revision 2241:4168cffbc76e, 6.2 KB checked in by Denis Jean-Chirstian <contact@…>, 12 years ago (diff)

Open action per module to plugin, enjoy

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->store_theme_url === null) {
19     $core->blog->settings->system->put(
20          'store_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->store_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->setConfiguration($core->blog->settings->system->theme)) {
65
66     # Get content before page headers
67     include $list->includeConfiguration();
68
69     # Gather content
70     $list->getConfiguration();
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') => $list->getURL('',false),
84                    '<span class="page-title">'.__('Theme configuration').'</span>' => ''
85               ))
86     );
87
88     # Display previously gathered content
89     $list->displayConfiguration();
90
91     dcPage::close();
92
93     # Stop reading code here
94     return;
95}
96
97# -- Execute actions --
98try {
99     $list->doActions('themes');
100}
101catch (Exception $e) {
102     $core->error->add($e->getMessage());
103}
104
105# -- Page header --
106dcPage::open(__('Themes management'),
107     dcPage::jsLoad('js/_blog_theme.js').
108     dcPage::jsPageTabs().
109     dcPage::jsColorPicker().
110
111     # --BEHAVIOR-- themesToolsHeaders
112     $core->callBehavior('themesToolsHeaders', $core, false),
113
114     dcPage::breadcrumb(
115          array(
116               html::escapeHTML($core->blog->name) => '',
117               '<span class="page-title">'.__('Blog appearance').'</span>' => ''
118          ))
119);
120
121# -- Display modules lists --
122if ($core->auth->isSuperAdmin() && $list->isWritablePath()) {
123
124     # Updated modules from repo
125     $modules = $list->store->get(true);
126     if (!empty($modules)) {
127          echo 
128          '<div class="multi-part" id="update" title="'.html::escapeHTML(__('Update themes')).'">'.
129          '<h3>'.html::escapeHTML(__('Update themes')).'</h3>'.
130          '<p>'.sprintf(
131               __('There is one theme to update available from repository.', 'There are %s themes to update available from repository.', count($modules)),
132               count($modules)
133          ).'</p>';
134
135          $list
136               ->setList('theme-update')
137               ->setTab('themes')
138               ->setModules($modules)
139               ->displayModules(
140                    /*cols */      array('sshot', 'name', 'desc', 'author', 'version', 'current_version', 'parent'),
141                    /* actions */  array('update', 'delete')
142               );
143
144          echo
145          '<p class="info vertical-separator">'.sprintf(
146               __("Visit %s repository, the resources center for Dotclear."),
147               '<a href="http://dotaddict.org/dc2/themes">Dotaddict</a>'
148               ).
149          '</p>'.
150
151          '</div>';
152     }
153}
154
155# Activated modules
156$modules = $list->modules->getModules();
157if (!empty($modules)) {
158
159     echo
160     '<div class="multi-part" id="themes" title="'.__('Installed themes').'">'.
161     '<h3>'.__('Installed themes').'</h3>'.
162     '<p>'.__('You can configure and manage installed themes from this list.').'</p>';
163
164     $list
165          ->setList('theme-activate')
166          ->setTab('themes')
167          ->setModules($modules)
168          ->displayModules(
169               /* cols */          array('sshot', 'distrib', 'name', 'config', 'desc', 'author', 'version', 'parent'),
170               /* actions */  array('select', 'behavior', 'deactivate', 'delete')
171          );
172
173     echo 
174     '</div>';
175}
176
177# Deactivated modules
178$modules = $list->modules->getDisabledModules();
179if (!empty($modules)) {
180
181     echo
182     '<div class="multi-part" id="deactivate" title="'.__('Deactivated themes').'">'.
183     '<h3>'.__('Deactivated themes').'</h3>'.
184     '<p>'.__('Deactivated themes are installed but not usable. You can activate them from here.').'</p>';
185
186     $list
187          ->setList('theme-deactivate')
188          ->setTab('themes')
189          ->setModules($modules)
190          ->displayModules(
191               /* cols */          array('name', 'distrib'),
192               /* actions */  array('activate', 'delete')
193          );
194
195     echo 
196     '</div>';
197}
198
199if ($core->auth->isSuperAdmin() && $list->isWritablePath()) {
200
201     # New modules from repo
202     $search = $list->getSearch();
203     $modules = $search ? $list->store->search($search) : $list->store->get();
204
205     if (!empty($search) || !empty($modules)) {
206          echo
207          '<div class="multi-part" id="new" title="'.__('Add themes').'">'.
208          '<h3>'.__('Add themes from repository').'</h3>'.
209          '<p>'.__('Search and install themes directly from repository.').'</p>';
210
211          $list
212               ->setList('theme-new')
213               ->setTab('new')
214               ->setModules($modules)
215               ->displaySearch()
216               ->displayIndex()
217               ->displayModules(
218                    /* cols */          array('expander', 'sshot', 'name', 'score', '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     '<h3>'.__('Add themes from a package').'</h3>'.
237     '<p>'.__('You can install themes by uploading or downloading zip files.').'</p>';
238
239     $list->displayManualForm();
240
241     echo
242     '</div>';
243}
244
245dcPage::close();
Note: See TracBrowser for help on using the repository browser.

Sites map