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