Dotclear

source: admin/blog_theme.php @ 2220:85fc55efed79

Revision 2220:85fc55efed79, 5.9 KB checked in by Denis Jean-Chirstian <contact@…>, 12 years ago (diff)

Oops (c) dcTeam

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->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     # Display previously gathered content
89     $list->getConfigurationContent();
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->isPathWritable()) {
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 %2$s.', 'There are %s themes to update available from %s.', count($modules)),
132               count($modules),
133               '<a href="http://dotaddict.org/dc2/themes">Dotaddict</a>'
134          ).'</p>';
135
136          $list
137               ->newList('theme-update')
138               ->setModules($modules)
139               ->setPageTab('update')
140               ->displayModulesList(
141                    /*cols */      array('sshot', 'name', 'desc', 'author', 'version', 'current_version', 'parent'),
142                    /* actions */  array('update')
143               );
144
145          echo
146          '</div>';
147     }
148}
149
150# List all active plugins
151echo
152'<div class="multi-part" id="themes" title="'.__('Installed themes').'">';
153
154$modules = $list->modules->getModules();
155if (!empty($modules)) {
156
157     echo
158     '<h3>'.__('Activated themes').'</h3>'.
159     '<p>'.__('Manage installed themes from this list.').'</p>';
160
161     $list
162          ->newList('theme-activate')
163          ->setModules($modules)
164          ->setPageTab('themes')
165          ->displayModulesList(
166               /* cols */          array('sshot', 'distrib', 'name', 'config', 'desc', 'author', 'version', 'parent'),
167               /* actions */  array('select', 'deactivate', 'delete')
168          );
169}
170
171$modules = $list->modules->getDisabledModules();
172if (!empty($modules)) {
173
174     echo
175     '<h3>'.__('Deactivated themes').'</h3>'.
176     '<p>'.__('Deactivated themes are installed but not usable. You can activate them from here.').'</p>';
177
178     $list
179          ->newList('theme-deactivate')
180          ->setModules($modules)
181          ->setPageTab('themes')
182          ->displayModulesList(
183               /* cols */          array('name', 'distrib'),
184               /* actions */  array('activate', 'delete')
185          );
186}
187
188echo 
189'</div>';
190
191if ($core->auth->isSuperAdmin() && $list->isPathWritable()) {
192
193     # New modules from repo
194     $search = $list->getSearchQuery();
195     $modules = $search ? $list->store->search($search) : $list->store->get();
196
197     if (!empty($search) || !empty($modules)) {
198          echo
199          '<div class="multi-part" id="new" title="'.__('Add themes from Dotaddict').'">'.
200          '<h3>'.__('Add themes from Dotaddict repository').'</h3>';
201
202          $list
203               ->newList('theme-new')
204               ->setModules($modules)
205               ->setPageTab('new')
206               ->displaySearchForm()
207               ->displayNavMenu()
208               ->displayModulesList(
209                    /* cols */          array('expander', 'sshot', 'name', 'config', 'desc', 'author', 'version', 'parent', 'details', 'support'),
210                    /* actions */  array('install'),
211                    /* nav limit */     true
212               );
213
214          echo
215          '<p class="info vertical-separator">'.sprintf(
216               __("Visit %s repository, the resources center for Dotclear."),
217               '<a href="http://dotaddict.org/dc2/themes">Dotaddict</a>'
218               ).
219          '</p>'.
220
221          '</div>';
222     }
223
224     # Add a new plugin
225     echo
226     '<div class="multi-part" id="addtheme" title="'.__('Install or upgrade manually').'">'.
227     '<p>'.__('You can install themes by uploading or downloading zip files.').'</p>';
228
229     $list->displayManualForm();
230
231     echo
232     '</div>';
233}
234
235dcPage::close();
Note: See TracBrowser for help on using the repository browser.

Sites map