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 | # -- Check for module configuration -- |
---|
69 | $conf_file = false; |
---|
70 | if (!empty($_REQUEST['conf']) && !empty($_REQUEST['module'])) { |
---|
71 | if (!$core->themes->moduleExists($_REQUEST['module'])) { |
---|
72 | $core->error->add(__('Unknow module ID')); |
---|
73 | } |
---|
74 | else { |
---|
75 | $module = $core->themes->getModules($_REQUEST['module']); |
---|
76 | $module = adminModulesList::parseModuleInfo($_REQUEST['module'], $module); |
---|
77 | |
---|
78 | if (!file_exists(path::real($module['root'].'/_config.php'))) { |
---|
79 | $core->error->add(__('This module has no configuration file.')); |
---|
80 | } |
---|
81 | else { |
---|
82 | $conf_file = path::real($module['root'].'/_config.php'); |
---|
83 | } |
---|
84 | } |
---|
85 | } |
---|
86 | |
---|
87 | # -- Display module configuration page -- |
---|
88 | if ($conf_file) { |
---|
89 | dcPage::open(__('Blog appearance'), |
---|
90 | |
---|
91 | # --BEHAVIOR-- themesToolsHeaders |
---|
92 | $core->callBehavior('themesToolsHeaders', $core, $module['id']), |
---|
93 | |
---|
94 | dcPage::breadcrumb( |
---|
95 | array( |
---|
96 | html::escapeHTML($core->blog->name) => '', |
---|
97 | __('Blog appearance') => 'blog_theme.php', |
---|
98 | '<span class="page-title">'.__('Theme configuration').'</span>' => '' |
---|
99 | )) |
---|
100 | ); |
---|
101 | |
---|
102 | if (!empty($_GET['done'])){ |
---|
103 | dcPage::success(__('Theme successfully configured.')); |
---|
104 | } |
---|
105 | |
---|
106 | try { |
---|
107 | if (!$module['standalone_config']) { |
---|
108 | echo |
---|
109 | '<form id="module_config" action="'.$list->getPageURL('conf=1').'" method="post" enctype="multipart/form-data">'. |
---|
110 | '<h3>'.sprintf(__('Configure theme "%s"'), html::escapeHTML($module['name'])).'</h3>'. |
---|
111 | '<p><a class="back" href="'.$list->getPageURL().'#themes">'.__('Back').'</a></p>'; |
---|
112 | } |
---|
113 | define('DC_CONTEXT_THEME', true); |
---|
114 | |
---|
115 | include $conf_file; |
---|
116 | |
---|
117 | if (!$module['standalone_config']) { |
---|
118 | echo |
---|
119 | '<p class="clear"><input type="submit" name="save" value="'.__('Save').'" />'. |
---|
120 | form::hidden('module', $module['id']). |
---|
121 | $core->formNonce().'</p>'. |
---|
122 | '</form>'; |
---|
123 | } |
---|
124 | } |
---|
125 | catch (Exception $e) { |
---|
126 | echo '<div class="error"><p>'.$e->getMessage().'</p></div>'; |
---|
127 | } |
---|
128 | |
---|
129 | dcPage::close(); |
---|
130 | |
---|
131 | # Stop reading code here |
---|
132 | return; |
---|
133 | } |
---|
134 | |
---|
135 | # -- Execute actions -- |
---|
136 | if (!empty($_POST) && empty($_REQUEST['conf']) && $core->auth->isSuperAdmin() && $list->isPathWritable()) { |
---|
137 | try { |
---|
138 | $list->executeAction('themes', $core->themes, $repository); |
---|
139 | } |
---|
140 | catch (Exception $e) { |
---|
141 | $core->error->add($e->getMessage()); |
---|
142 | } |
---|
143 | } |
---|
144 | |
---|
145 | # -- Page header -- |
---|
146 | dcPage::open(__('Themes management'), |
---|
147 | // (!$conf_file ? dcPage::jsLoad('js/_blog_theme.js') : ''). |
---|
148 | dcPage::jsPageTabs(). |
---|
149 | dcPage::jsColorPicker(), |
---|
150 | |
---|
151 | # --BEHAVIOR-- themesToolsHeaders |
---|
152 | $core->callBehavior('themesToolsHeaders', $core, false), |
---|
153 | |
---|
154 | dcPage::breadcrumb( |
---|
155 | array( |
---|
156 | html::escapeHTML($core->blog->name) => '', |
---|
157 | '<span class="page-title">'.__('Blog appearance').'</span>' => '' |
---|
158 | )) |
---|
159 | ); |
---|
160 | |
---|
161 | # -- Succes messages -- |
---|
162 | if (!empty($_GET['msg'])) { |
---|
163 | $list->displayMessage($_GET['msg']); |
---|
164 | } |
---|
165 | |
---|
166 | # -- Display modules lists -- |
---|
167 | if ($core->auth->isSuperAdmin() && $list->isPathWritable()) { |
---|
168 | |
---|
169 | # Updated modules from repo |
---|
170 | $modules = $repository->get(true); |
---|
171 | if (!empty($modules)) { |
---|
172 | echo |
---|
173 | '<div class="multi-part" id="update" title="'.html::escapeHTML(__('Update themes')).'">'. |
---|
174 | '<h3>'.html::escapeHTML(__('Update themes')).'</h3>'. |
---|
175 | '<p>'.sprintf( |
---|
176 | __('There is one theme to update available from %2$s.', 'There are %s themes to update available from %s.', count($modules)), |
---|
177 | count($modules), |
---|
178 | '<a href="http://dotaddict.org/dc2/themes">Dotaddict</a>' |
---|
179 | ).'</p>'; |
---|
180 | |
---|
181 | $list |
---|
182 | ->newList('theme-update') |
---|
183 | ->setModules($modules) |
---|
184 | ->setPageTab('update') |
---|
185 | ->displayModulesList( |
---|
186 | /*cols */ array('sshot', 'name', 'desc', 'author', 'version', 'current_version', 'parent'), |
---|
187 | /* actions */ array('update') |
---|
188 | ); |
---|
189 | |
---|
190 | echo |
---|
191 | '</div>'; |
---|
192 | } |
---|
193 | } |
---|
194 | |
---|
195 | # List all active plugins |
---|
196 | echo |
---|
197 | '<div class="multi-part" id="themes" title="'.__('Installed themes').'">'; |
---|
198 | |
---|
199 | $modules = $core->themes->getModules(); |
---|
200 | if (!empty($modules)) { |
---|
201 | |
---|
202 | echo |
---|
203 | '<h3>'.__('Activated themes').'</h3>'. |
---|
204 | '<p>'.__('Manage installed themes from this list.').'</p>'; |
---|
205 | |
---|
206 | $list |
---|
207 | ->newList('theme-activate') |
---|
208 | ->setModules($modules) |
---|
209 | ->setPageTab('themes') |
---|
210 | ->displayModulesList( |
---|
211 | /* cols */ array('sshot', 'name', 'config', 'desc', 'author', 'version', 'parent'), |
---|
212 | /* actions */ array('deactivate', 'delete') |
---|
213 | ); |
---|
214 | } |
---|
215 | |
---|
216 | echo |
---|
217 | '</div>'; |
---|
218 | |
---|
219 | if ($core->auth->isSuperAdmin() && $list->isPathWritable()) { |
---|
220 | |
---|
221 | # New modules from repo |
---|
222 | $search = $list->getSearchQuery(); |
---|
223 | $modules = $search ? $repository->search($search) : $repository->get(); |
---|
224 | |
---|
225 | echo |
---|
226 | '<div class="multi-part" id="new" title="'.__('Add themes from Dotaddict').'">'. |
---|
227 | '<h3>'.__('Add themes from Dotaddict repository').'</h3>'; |
---|
228 | |
---|
229 | $list |
---|
230 | ->newList('theme-new') |
---|
231 | ->setModules($modules) |
---|
232 | ->setPageTab('new') |
---|
233 | ->displaySearchForm() |
---|
234 | ->displayNavMenu() |
---|
235 | ->displayModulesList( |
---|
236 | /* cols */ array('expander', 'sshot', 'name', 'config', 'desc', 'author', 'version', 'parent'), |
---|
237 | /* actions */ array('install'), |
---|
238 | /* nav limit */ true |
---|
239 | ); |
---|
240 | |
---|
241 | echo |
---|
242 | '<p class="info vertical-separator">'.sprintf( |
---|
243 | __("Visit %s repository, the resources center for Dotclear."), |
---|
244 | '<a href="http://dotaddict.org/dc2/themes">Dotaddict</a>' |
---|
245 | ). |
---|
246 | '</p>'. |
---|
247 | |
---|
248 | '</div>'; |
---|
249 | |
---|
250 | # Add a new plugin |
---|
251 | echo |
---|
252 | '<div class="multi-part" id="addtheme" title="'.__('Install or upgrade manually').'">'; |
---|
253 | |
---|
254 | echo '<p>'.__('You can install themes by uploading or downloading zip files.').'</p>'; |
---|
255 | |
---|
256 | $list->displayManualForm(); |
---|
257 | |
---|
258 | echo |
---|
259 | '</div>'; |
---|
260 | } |
---|
261 | |
---|
262 | dcPage::close(); |
---|
263 | ?> |
---|