Dotclear

source: admin/blog_theme.php @ 2487:53510da55dc5

Revision 2487:53510da55dc5, 6.1 KB checked in by Denis Jean-Chirstian <contact@…>, 12 years ago (diff)

Add actions batch (and checkboxes) to modules list.

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

Sites map