Dotclear

source: admin/blog_theme.php @ 3018:02463a39c69a

Revision 3018:02463a39c69a, 6.3 KB checked in by franck <carnet.franck.paul@…>, 10 years ago (diff)

Display update message for themes and plugins, even if respective folder is read-only, fixes #1969

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

Sites map