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