1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
3 | # |
---|
4 | # This file is part of Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2003-2011 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 | if (!defined('DC_CONTEXT_ADMIN')) { return; } |
---|
13 | |
---|
14 | l10n::set(dirname(__FILE__).'/locales/'.$_lang.'/admin'); |
---|
15 | |
---|
16 | $sticker_images = array( |
---|
17 | __('Contact') => 'sticker-contact.png', |
---|
18 | __('Feed') => 'sticker-feed.png', |
---|
19 | __('About') => 'sticker-about.png' |
---|
20 | ); |
---|
21 | |
---|
22 | $fonts = array( |
---|
23 | __('default') => '', |
---|
24 | __('Ductile primary') => 'Ductile body', |
---|
25 | __('Ductile secondary') => 'Ductile alternate', |
---|
26 | __('Times New Roman') => 'Times New Roman', |
---|
27 | __('Georgia') => 'Georgia', |
---|
28 | __('Garamond') => 'Garamond', |
---|
29 | __('Helvetica/Arial') => 'Helvetica/Arial', |
---|
30 | __('Verdana') => 'Verdana', |
---|
31 | __('Trebuchet MS') => 'Trebuchet MS', |
---|
32 | __('Impact') => 'Impact', |
---|
33 | __('Monospace') => 'Monospace' |
---|
34 | ); |
---|
35 | |
---|
36 | function adjustFontSize($s) |
---|
37 | { |
---|
38 | if (preg_match('/^([0-9.]+)\s*(%|pt|px|em|ex)?$/',$s,$m)) { |
---|
39 | if (empty($m[2])) { |
---|
40 | $m[2] = 'em'; |
---|
41 | } |
---|
42 | return $m[1].$m[2]; |
---|
43 | } |
---|
44 | |
---|
45 | return null; |
---|
46 | } |
---|
47 | |
---|
48 | function adjustColor($c) |
---|
49 | { |
---|
50 | if ($c === '') { |
---|
51 | return ''; |
---|
52 | } |
---|
53 | |
---|
54 | $c = strtoupper($c); |
---|
55 | |
---|
56 | if (preg_match('/^[A-F0-9]{3,6}$/',$c)) { |
---|
57 | $c = '#'.$c; |
---|
58 | } |
---|
59 | |
---|
60 | if (preg_match('/^#[A-F0-9]{6}$/',$c)) { |
---|
61 | return $c; |
---|
62 | } |
---|
63 | |
---|
64 | if (preg_match('/^#[A-F0-9]{3,}$/',$c)) { |
---|
65 | return '#'.substr($c,1,1).substr($c,1,1).substr($c,2,1).substr($c,2,1).substr($c,3,1).substr($c,3,1); |
---|
66 | } |
---|
67 | |
---|
68 | return ''; |
---|
69 | } |
---|
70 | |
---|
71 | $ductile_base = array( |
---|
72 | // HTML |
---|
73 | 'subtitle_hidden' => null, |
---|
74 | // CSS |
---|
75 | 'body_font' => null, |
---|
76 | 'alternate_font' => null, |
---|
77 | 'blog_title_w' => null, |
---|
78 | 'blog_title_s' => null, |
---|
79 | 'blog_title_c' => null, |
---|
80 | 'post_title_w' => null, |
---|
81 | 'post_title_s' => null, |
---|
82 | 'post_title_c' => null, |
---|
83 | 'post_link_w' => null, |
---|
84 | 'post_link_v_c' => null, |
---|
85 | 'post_link_f_c' => null, |
---|
86 | 'blog_title_w_m' => null, |
---|
87 | 'blog_title_s_m' => null, |
---|
88 | 'blog_title_c_m' => null, |
---|
89 | 'post_title_w_m' => null, |
---|
90 | 'post_title_s_m' => null, |
---|
91 | 'post_title_c_m' => null |
---|
92 | ); |
---|
93 | |
---|
94 | $ductile_user = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_style'); |
---|
95 | $ductile_user = @unserialize($ductile_user); |
---|
96 | if (!is_array($ductile_user)) { |
---|
97 | $ductile_user = array(); |
---|
98 | } |
---|
99 | |
---|
100 | $ductile_user = array_merge($ductile_base,$ductile_user); |
---|
101 | |
---|
102 | $ductile_stickers_base = array( |
---|
103 | array('label' => null,'url' => null,'image' => null), |
---|
104 | array('label' => null,'url' => null,'image' => null), |
---|
105 | array('label' => null,'url' => null,'image' => null) |
---|
106 | ); |
---|
107 | |
---|
108 | $ductile_stickers = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_stickers'); |
---|
109 | $ductile_stickers = @unserialize($ductile_stickers); |
---|
110 | if (!is_array($ductile_stickers)) { |
---|
111 | $ductile_stickers = $ductile_stickers_base; |
---|
112 | } |
---|
113 | |
---|
114 | $conf_tab = isset($_POST['conf_tab']) ? $_POST['conf_tab'] : 'html'; |
---|
115 | |
---|
116 | if (!empty($_POST)) |
---|
117 | { |
---|
118 | try |
---|
119 | { |
---|
120 | # HTML |
---|
121 | if ($conf_tab == 'html') { |
---|
122 | $ductile_user['subtitle_hidden'] = (integer) !empty($_POST['subtitle_hidden']); |
---|
123 | |
---|
124 | $count = 0; |
---|
125 | if (!empty($_POST['sticker1_label']) && !empty($_POST['sticker1_url'])) { |
---|
126 | $ductile_stickers[$count]['label'] = $_POST['sticker1_label']; |
---|
127 | $ductile_stickers[$count]['url'] = $_POST['sticker1_url']; |
---|
128 | $ductile_stickers[$count]['image'] = $_POST['sticker1_image']; |
---|
129 | $count++; |
---|
130 | } |
---|
131 | if (!empty($_POST['sticker2_label']) && !empty($_POST['sticker2_url'])) { |
---|
132 | $ductile_stickers[$count]['label'] = $_POST['sticker2_label']; |
---|
133 | $ductile_stickers[$count]['url'] = $_POST['sticker2_url']; |
---|
134 | $ductile_stickers[$count]['image'] = $_POST['sticker2_image']; |
---|
135 | $count++; |
---|
136 | } |
---|
137 | if (!empty($_POST['sticker3_label']) && !empty($_POST['sticker3_url'])) { |
---|
138 | $ductile_stickers[$count]['label'] = $_POST['sticker3_label']; |
---|
139 | $ductile_stickers[$count]['url'] = $_POST['sticker3_url']; |
---|
140 | $ductile_stickers[$count]['image'] = $_POST['sticker3_image']; |
---|
141 | $count++; |
---|
142 | } |
---|
143 | for ($i = $count; $i < 3; $i++) { |
---|
144 | $ductile_stickers[$i]['label'] = null; |
---|
145 | $ductile_stickers[$i]['url'] = null; |
---|
146 | $ductile_stickers[$i]['image'] = null; |
---|
147 | } |
---|
148 | } |
---|
149 | |
---|
150 | # CSS |
---|
151 | if ($conf_tab == 'css') { |
---|
152 | $ductile_user['body_font'] = $_POST['body_font']; |
---|
153 | $ductile_user['alternate_font'] = $_POST['alternate_font']; |
---|
154 | |
---|
155 | $ductile_user['blog_title_w'] = (integer) !empty($_POST['blog_title_w']); |
---|
156 | $ductile_user['blog_title_s'] = adjustFontSize($_POST['blog_title_s']); |
---|
157 | $ductile_user['blog_title_c'] = adjustColor($_POST['blog_title_c']); |
---|
158 | |
---|
159 | $ductile_user['post_title_w'] = (integer) !empty($_POST['post_title_w']); |
---|
160 | $ductile_user['post_title_s'] = adjustFontSize($_POST['post_title_s']); |
---|
161 | $ductile_user['post_title_c'] = adjustColor($_POST['post_title_c']); |
---|
162 | |
---|
163 | $ductile_user['post_link_w'] = (integer) !empty($_POST['post_link_w']); |
---|
164 | $ductile_user['post_link_v_c'] = adjustColor($_POST['post_link_v_c']); |
---|
165 | $ductile_user['post_link_f_c'] = adjustColor($_POST['post_link_f_c']); |
---|
166 | |
---|
167 | $ductile_user['blog_title_w_m'] = (integer) !empty($_POST['blog_title_w_m']); |
---|
168 | $ductile_user['blog_title_s_m'] = adjustFontSize($_POST['blog_title_s_m']); |
---|
169 | $ductile_user['blog_title_c_m'] = adjustColor($_POST['blog_title_c_m']); |
---|
170 | |
---|
171 | $ductile_user['post_title_w_m'] = (integer) !empty($_POST['post_title_w_m']); |
---|
172 | $ductile_user['post_title_s_m'] = adjustFontSize($_POST['post_title_s_m']); |
---|
173 | $ductile_user['post_title_c_m'] = adjustColor($_POST['post_title_c_m']); |
---|
174 | } |
---|
175 | |
---|
176 | $core->blog->settings->addNamespace('themes'); |
---|
177 | $core->blog->settings->themes->put($core->blog->settings->system->theme.'_style',serialize($ductile_user)); |
---|
178 | $core->blog->settings->themes->put($core->blog->settings->system->theme.'_stickers',serialize($ductile_stickers)); |
---|
179 | $core->blog->triggerBlog(); |
---|
180 | |
---|
181 | echo |
---|
182 | '<div class="message"><p>'. |
---|
183 | __('Theme configuration upgraded.'). |
---|
184 | '</p></div>'; |
---|
185 | } |
---|
186 | catch (Exception $e) |
---|
187 | { |
---|
188 | $core->error->add($e->getMessage()); |
---|
189 | } |
---|
190 | } |
---|
191 | |
---|
192 | # HTML Tab |
---|
193 | |
---|
194 | echo '<div class="multi-part" id="themes-list'.($conf_tab == 'html' ? '' : '-html').'" title="'.__('Content').'">'; |
---|
195 | |
---|
196 | echo '<form id="theme_config" action="blog_theme.php?conf=1" method="post" enctype="multipart/form-data">'; |
---|
197 | |
---|
198 | echo '<fieldset><legend>'.__('Header').'</legend>'. |
---|
199 | '<p class="field"><label for="subtitle_hidden">'.__('Hide blog description:').' '. |
---|
200 | form::checkbox('subtitle_hidden',1,$ductile_user['subtitle_hidden']).'</label>'.'</p>'. |
---|
201 | '</fieldset>'; |
---|
202 | |
---|
203 | echo '<fieldset><legend>'.__('Stickers').'</legend>'; |
---|
204 | |
---|
205 | echo '<table id="stickerslist">'.'<caption>'.__('Stickers (footer)').'</caption>'. |
---|
206 | '<thead>'. |
---|
207 | '<tr>'. |
---|
208 | '<th scope="col">'.__('Position').'</th>'. |
---|
209 | '<th scope="col">'.__('Label').'</th>'. |
---|
210 | '<th scope="col">'.__('URL').'</th>'. |
---|
211 | '<th scope="col">'.__('Icon').'</th>'. |
---|
212 | '</tr>'. |
---|
213 | '</thead>'. |
---|
214 | '<tbody>'. |
---|
215 | '<tr>'. |
---|
216 | '<td scope="raw">1</td>'. |
---|
217 | '<td>'.form::field('sticker1_label',20,255,$ductile_stickers[0]['label']).'</td>'. |
---|
218 | '<td>'.form::field('sticker1_url',40,255,$ductile_stickers[0]['url']).'</td>'. |
---|
219 | '<td>'.form::combo('sticker1_image',$sticker_images,$ductile_stickers[0]['image']).'</td>'. |
---|
220 | '</tr>'. |
---|
221 | '<tr>'. |
---|
222 | '<td scope="raw">2</td>'. |
---|
223 | '<td>'.form::field('sticker2_label',20,255,$ductile_stickers[1]['label']).'</td>'. |
---|
224 | '<td>'.form::field('sticker2_url',40,255,$ductile_stickers[1]['url']).'</td>'. |
---|
225 | '<td>'.form::combo('sticker2_image',$sticker_images,$ductile_stickers[1]['image']).'</td>'. |
---|
226 | '</tr>'. |
---|
227 | '<tr>'. |
---|
228 | '<td scope="raw">3</td>'. |
---|
229 | '<td>'.form::field('sticker3_label',20,255,$ductile_stickers[2]['label']).'</td>'. |
---|
230 | '<td>'.form::field('sticker3_url',40,255,$ductile_stickers[2]['url']).'</td>'. |
---|
231 | '<td>'.form::combo('sticker3_image',$sticker_images,$ductile_stickers[2]['image']).'</td>'. |
---|
232 | '</tr>'. |
---|
233 | '</tbody>'. |
---|
234 | '</table>'; |
---|
235 | |
---|
236 | echo '</fieldset>'; |
---|
237 | |
---|
238 | echo '<input type="hidden" name="conf_tab" value="html">'; |
---|
239 | echo '<p class="clear"><input type="submit" value="'.__('Save').'" />'.$core->formNonce().'</p>'; |
---|
240 | echo '</form>'; |
---|
241 | |
---|
242 | echo '</div>'; // Close tab |
---|
243 | |
---|
244 | # CSS tab |
---|
245 | |
---|
246 | echo '<div class="multi-part" id="themes-list'.($conf_tab == 'css' ? '' : '-css').'" title="'.__('Presentation').'">'; |
---|
247 | |
---|
248 | echo '<form id="theme_config" action="blog_theme.php?conf=1" method="post" enctype="multipart/form-data">'; |
---|
249 | |
---|
250 | echo '<h3>'.__('General settings').'</h3>'; |
---|
251 | |
---|
252 | echo '<fieldset><legend>'.__('Fonts').'</legend>'. |
---|
253 | '<p class="field"><label for="body_font">'.__('Main:').' '. |
---|
254 | form::combo('body_font',$fonts,$ductile_user['body_font']).'</label></p>'. |
---|
255 | |
---|
256 | '<p class="field"><label for="alternate_font">'.__('Secondary:').' '. |
---|
257 | form::combo('alternate_font',$fonts,$ductile_user['alternate_font']).'</label></p>'. |
---|
258 | '</fieldset>'; |
---|
259 | |
---|
260 | echo '<div class="two-cols">'; |
---|
261 | echo '<div class="col">'; |
---|
262 | |
---|
263 | echo '<fieldset><legend>'.__('Blog title').'</legend>'. |
---|
264 | '<p class="field"><label for="blog_title_w">'.__('In bold:').' '. |
---|
265 | form::checkbox('blog_title_w',1,$ductile_user['blog_title_w']).'</label>'.'</p>'. |
---|
266 | |
---|
267 | '<p class="field"><label for="blog_title_s">'.__('Font size (in em by default):').'</label> '. |
---|
268 | form::field('blog_title_s',7,7,$ductile_user['blog_title_s']).'</p>'. |
---|
269 | |
---|
270 | '<p class="field picker"><label for="blog_title_c">'.__('Color:').'</label> '. |
---|
271 | form::field('blog_title_c',7,7,$ductile_user['blog_title_c'],'colorpicker').'</p>'. |
---|
272 | '</fieldset>'; |
---|
273 | |
---|
274 | echo '</div>'; |
---|
275 | echo '<div class="col">'; |
---|
276 | |
---|
277 | echo '<fieldset><legend>'.__('Post title').'</legend>'. |
---|
278 | '<p class="field"><label for="post_title_w">'.__('In bold:').' '. |
---|
279 | form::checkbox('post_title_w',1,$ductile_user['post_title_w']).'</label>'.'</p>'. |
---|
280 | |
---|
281 | '<p class="field"><label for="post_title_s">'.__('Font size (in em by default):').'</label> '. |
---|
282 | form::field('post_title_s',7,7,$ductile_user['post_title_s']).'</p>'. |
---|
283 | |
---|
284 | '<p class="field picker"><label for="post_title_c">'.__('Color:').'</label> '. |
---|
285 | form::field('post_title_c',7,7,$ductile_user['post_title_c'],'colorpicker').'</p>'. |
---|
286 | '</fieldset>'; |
---|
287 | |
---|
288 | echo '</div>'; |
---|
289 | echo '</div>'; |
---|
290 | |
---|
291 | echo '<fieldset><legend>'.__('Inside posts links').'</legend>'. |
---|
292 | '<p class="field"><label for="post_link_w">'.__('In bold:').' '. |
---|
293 | form::checkbox('post_link_w',1,$ductile_user['post_link_w']).'</label>'.'</p>'. |
---|
294 | |
---|
295 | '<p class="field picker"><label for="post_link_v_c">'.__('Normal and visited links color:').'</label> '. |
---|
296 | form::field('post_link_v_c',7,7,$ductile_user['post_link_v_c'],'colorpicker').'</p>'. |
---|
297 | |
---|
298 | '<p class="field picker"><label for="body_link_f_c">'.__('Active, hover and focus links color:').'</label> '. |
---|
299 | form::field('post_link_f_c',7,7,$ductile_user['post_link_f_c'],'colorpicker').'</p>'. |
---|
300 | '</fieldset>'; |
---|
301 | |
---|
302 | echo '<h3>'.__('Mobile specific settings').'</h3>'; |
---|
303 | |
---|
304 | echo '<div class="two-cols">'; |
---|
305 | echo '<div class="col">'; |
---|
306 | |
---|
307 | echo '<fieldset><legend>'.__('Blog title').'</legend>'. |
---|
308 | '<p class="field"><label for="blog_title_w_m">'.__('In bold:').' '. |
---|
309 | form::checkbox('blog_title_w_m',1,$ductile_user['blog_title_w_m']).'</label>'.'</p>'. |
---|
310 | |
---|
311 | '<p class="field"><label for="blog_title_s_m">'.__('Font size (in em by default):').'</label> '. |
---|
312 | form::field('blog_title_s_m',7,7,$ductile_user['blog_title_s_m']).'</p>'. |
---|
313 | |
---|
314 | '<p class="field picker"><label for="blog_title_c_m">'.__('Color:').'</label> '. |
---|
315 | form::field('blog_title_c_m',7,7,$ductile_user['blog_title_c_m'],'colorpicker').'</p>'. |
---|
316 | '</fieldset>'; |
---|
317 | |
---|
318 | echo '</div>'; |
---|
319 | echo '<div class="col">'; |
---|
320 | |
---|
321 | echo '<fieldset><legend>'.__('Post title').'</legend>'. |
---|
322 | '<p class="field"><label for="post_title_w_m">'.__('In bold:').' '. |
---|
323 | form::checkbox('post_title_w_m',1,$ductile_user['post_title_w_m']).'</label>'.'</p>'. |
---|
324 | |
---|
325 | '<p class="field"><label for="post_title_s_m">'.__('Font size (in em by default):').'</label> '. |
---|
326 | form::field('post_title_s_m',7,7,$ductile_user['post_title_s_m']).'</p>'. |
---|
327 | |
---|
328 | '<p class="field picker"><label for="post_title_c_m">'.__('Color:').'</label> '. |
---|
329 | form::field('post_title_c_m',7,7,$ductile_user['post_title_c_m'],'colorpicker').'</p>'. |
---|
330 | '</fieldset>'; |
---|
331 | |
---|
332 | echo '</div>'; |
---|
333 | echo '</div>'; |
---|
334 | |
---|
335 | echo '<input type="hidden" name="conf_tab" value="css">'; |
---|
336 | echo '<p class="clear"><input type="submit" value="'.__('Save').'" />'.$core->formNonce().'</p>'; |
---|
337 | echo '</form>'; |
---|
338 | |
---|
339 | echo '</div>'; // Close tab |
---|
340 | |
---|
341 | ?> |
---|