Dotclear

source: themes/ductile/_config.php @ 564:7b2e8ebcb406

Revision 564:7b2e8ebcb406, 13.7 KB checked in by Franck <carnet.franck.paul@…>, 14 years ago (diff)

Bugfix sur contexte utilisé pour les archives mensuelles

Line 
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 -----------------------------------------
12if (!defined('DC_CONTEXT_ADMIN')) { return; }
13
14l10n::set(dirname(__FILE__).'/locales/'.$_lang.'/admin');
15
16$list_types = array(
17     __('Title') => 'title',
18     __('Short') => 'short',
19     __('Full') => 'full'
20);
21
22$contexts = array(
23     'default' => __('Home (first page)'),
24     'default-page' => __('Home (other pages)'),
25     'category' => __('Entries for a category'),
26     'tag' => __('Entries for a tag'),
27     'search' => __('Search result entries'),
28     'archive' => __('Month archive entries')
29);
30
31$sticker_images = array(
32     __('Contact') => 'sticker-contact.png',
33     __('Feed') => 'sticker-feed.png',
34     __('About') => 'sticker-about.png'
35);
36
37$fonts = array(
38     __('default') => '',
39     __('Ductile primary') => 'Ductile body',
40     __('Ductile secondary') => 'Ductile alternate',
41     __('Times New Roman') => 'Times New Roman',
42     __('Georgia') => 'Georgia',
43     __('Garamond') => 'Garamond',
44     __('Helvetica/Arial') => 'Helvetica/Arial',
45     __('Verdana') => 'Verdana',
46     __('Trebuchet MS') => 'Trebuchet MS',
47     __('Impact') => 'Impact',
48     __('Monospace') => 'Monospace'
49);
50
51function adjustFontSize($s)
52{
53     if (preg_match('/^([0-9.]+)\s*(%|pt|px|em|ex)?$/',$s,$m)) {
54          if (empty($m[2])) {
55               $m[2] = 'em';
56          }
57          return $m[1].$m[2];
58     }
59
60     return null;
61}
62
63function adjustColor($c)
64{
65     if ($c === '') {
66          return '';
67     }
68
69     $c = strtoupper($c);
70
71     if (preg_match('/^[A-F0-9]{3,6}$/',$c)) {
72          $c = '#'.$c;
73     }
74
75     if (preg_match('/^#[A-F0-9]{6}$/',$c)) {
76          return $c;
77     }
78
79     if (preg_match('/^#[A-F0-9]{3,}$/',$c)) {
80          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);
81     }
82
83     return '';
84}
85
86$ductile_base = array(
87     // HTML
88     'subtitle_hidden' => null,
89     // CSS
90     'body_font' => null,
91     'alternate_font' => null,
92     'blog_title_w' => null,
93     'blog_title_s' => null,
94     'blog_title_c' => null,
95     'post_title_w' => null,
96     'post_title_s' => null,
97     'post_title_c' => null,
98     'post_link_w' => null,
99     'post_link_v_c' => null,
100     'post_link_f_c' => null,
101     'blog_title_w_m' => null,
102     'blog_title_s_m' => null,
103     'blog_title_c_m' => null,
104     'post_title_w_m' => null,
105     'post_title_s_m' => null,
106     'post_title_c_m' => null,
107     'post_simple_title_c' => null
108);
109
110$ductile_user = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_style');
111$ductile_user = @unserialize($ductile_user);
112if (!is_array($ductile_user)) {
113     $ductile_user = array();
114}
115
116$ductile_user = array_merge($ductile_base,$ductile_user);
117
118$ductile_stickers_base = array(
119     array('label' => null,'url' => null,'image' => null),
120     array('label' => null,'url' => null,'image' => null),
121     array('label' => null,'url' => null,'image' => null)
122);
123
124$ductile_stickers = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_stickers');
125$ductile_stickers = @unserialize($ductile_stickers);
126if (!is_array($ductile_stickers)) {
127     $ductile_stickers = $ductile_stickers_base;
128}
129
130$ductile_lists_base = array(
131     'default' => null,
132     'default-page' => null,
133     'category' => null,
134     'tag' => null,
135     'search' => null,
136     'archive' => null
137);
138
139$ductile_lists = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_entries_lists');
140$ductile_lists = @unserialize($ductile_lists);
141if (!is_array($ductile_lists)) {
142     $ductile_lists = $ductile_lists_base;
143}
144
145$conf_tab = isset($_POST['conf_tab']) ? $_POST['conf_tab'] : 'html';
146
147if (!empty($_POST))
148{
149     try
150     {
151          # HTML
152          if ($conf_tab == 'html') {
153               $ductile_user['subtitle_hidden'] = (integer) !empty($_POST['subtitle_hidden']);
154               
155               $count = 0;
156               if (!empty($_POST['sticker1_label']) && !empty($_POST['sticker1_url'])) {
157                    $ductile_stickers[$count]['label'] = $_POST['sticker1_label'];
158                    $ductile_stickers[$count]['url'] = $_POST['sticker1_url'];
159                    $ductile_stickers[$count]['image'] = $_POST['sticker1_image'];
160                    $count++;
161               }
162               if (!empty($_POST['sticker2_label']) && !empty($_POST['sticker2_url'])) {
163                    $ductile_stickers[$count]['label'] = $_POST['sticker2_label'];
164                    $ductile_stickers[$count]['url'] = $_POST['sticker2_url'];
165                    $ductile_stickers[$count]['image'] = $_POST['sticker2_image'];
166                    $count++;
167               }
168               if (!empty($_POST['sticker3_label']) && !empty($_POST['sticker3_url'])) {
169                    $ductile_stickers[$count]['label'] = $_POST['sticker3_label'];
170                    $ductile_stickers[$count]['url'] = $_POST['sticker3_url'];
171                    $ductile_stickers[$count]['image'] = $_POST['sticker3_image'];
172                    $count++;
173               }
174               for ($i = $count; $i < 3; $i++) {
175                    $ductile_stickers[$i]['label'] = null;
176                    $ductile_stickers[$i]['url'] = null;
177                    $ductile_stickers[$i]['image'] = null;
178               }
179
180               for ($i = 0; $i < count($_POST['list_type']); $i++) {
181                    $ductile_lists[$_POST['list_ctx'][$i]] = $_POST['list_type'][$i];
182               }
183               
184          }
185         
186          # CSS
187          if ($conf_tab == 'css') {
188               $ductile_user['body_font'] = $_POST['body_font'];
189               $ductile_user['alternate_font'] = $_POST['alternate_font'];
190
191               $ductile_user['blog_title_w'] = (integer) !empty($_POST['blog_title_w']);
192               $ductile_user['blog_title_s'] = adjustFontSize($_POST['blog_title_s']);
193               $ductile_user['blog_title_c'] = adjustColor($_POST['blog_title_c']);
194         
195               $ductile_user['post_title_w'] = (integer) !empty($_POST['post_title_w']);
196               $ductile_user['post_title_s'] = adjustFontSize($_POST['post_title_s']);
197               $ductile_user['post_title_c'] = adjustColor($_POST['post_title_c']);
198         
199               $ductile_user['post_link_w'] = (integer) !empty($_POST['post_link_w']);
200               $ductile_user['post_link_v_c'] = adjustColor($_POST['post_link_v_c']);
201               $ductile_user['post_link_f_c'] = adjustColor($_POST['post_link_f_c']);
202         
203               $ductile_user['post_simple_title_c'] = adjustColor($_POST['post_simple_title_c']);
204         
205               $ductile_user['blog_title_w_m'] = (integer) !empty($_POST['blog_title_w_m']);
206               $ductile_user['blog_title_s_m'] = adjustFontSize($_POST['blog_title_s_m']);
207               $ductile_user['blog_title_c_m'] = adjustColor($_POST['blog_title_c_m']);
208         
209               $ductile_user['post_title_w_m'] = (integer) !empty($_POST['post_title_w_m']);
210               $ductile_user['post_title_s_m'] = adjustFontSize($_POST['post_title_s_m']);
211               $ductile_user['post_title_c_m'] = adjustColor($_POST['post_title_c_m']);
212          }
213         
214          $core->blog->settings->addNamespace('themes');
215          $core->blog->settings->themes->put($core->blog->settings->system->theme.'_style',serialize($ductile_user));
216          $core->blog->settings->themes->put($core->blog->settings->system->theme.'_stickers',serialize($ductile_stickers));
217          $core->blog->settings->themes->put($core->blog->settings->system->theme.'_entries_lists',serialize($ductile_lists));
218          $core->blog->triggerBlog();
219
220          echo
221          '<div class="message"><p>'.
222          __('Theme configuration upgraded.').
223          '</p></div>';
224     }
225     catch (Exception $e)
226     {
227          $core->error->add($e->getMessage());
228     }
229}
230
231// To be deleted when adminThemeConfigManaged behaviour will be implemented in admin/blog_themes.php :
232echo '</form>';
233
234# HTML Tab
235
236echo '<div class="multi-part" id="themes-list'.($conf_tab == 'html' ? '' : '-html').'" title="'.__('Content').'">';
237
238echo '<form id="theme_config" action="blog_theme.php?conf=1" method="post" enctype="multipart/form-data">';
239
240echo '<fieldset><legend>'.__('Header').'</legend>'.
241'<p class="field"><label for="subtitle_hidden">'.__('Hide blog description:').' '.
242form::checkbox('subtitle_hidden',1,$ductile_user['subtitle_hidden']).'</label>'.'</p>'.
243'</fieldset>';
244
245echo '<fieldset><legend>'.__('Stickers').'</legend>';
246
247echo '<table id="stickerslist">'.'<caption>'.__('Stickers (footer)').'</caption>'.
248'<thead>'.
249'<tr>'.
250'<th scope="col">'.__('Position').'</th>'.
251'<th scope="col">'.__('Label').'</th>'.
252'<th scope="col">'.__('URL').'</th>'.
253'<th scope="col">'.__('Icon').'</th>'.
254'</tr>'.
255'</thead>'.
256'<tbody>'.
257'<tr>'.
258'<td scope="raw">1</td>'.
259'<td>'.form::field('sticker1_label',20,255,$ductile_stickers[0]['label']).'</td>'.
260'<td>'.form::field('sticker1_url',40,255,$ductile_stickers[0]['url']).'</td>'.
261'<td>'.form::combo('sticker1_image',$sticker_images,$ductile_stickers[0]['image']).'</td>'.
262'</tr>'.
263'<tr>'.
264'<td scope="raw">2</td>'.
265'<td>'.form::field('sticker2_label',20,255,$ductile_stickers[1]['label']).'</td>'.
266'<td>'.form::field('sticker2_url',40,255,$ductile_stickers[1]['url']).'</td>'.
267'<td>'.form::combo('sticker2_image',$sticker_images,$ductile_stickers[1]['image']).'</td>'.
268'</tr>'.
269'<tr>'.
270'<td scope="raw">3</td>'.
271'<td>'.form::field('sticker3_label',20,255,$ductile_stickers[2]['label']).'</td>'.
272'<td>'.form::field('sticker3_url',40,255,$ductile_stickers[2]['url']).'</td>'.
273'<td>'.form::combo('sticker3_image',$sticker_images,$ductile_stickers[2]['image']).'</td>'.
274'</tr>'.
275'</tbody>'.
276'</table>';
277
278echo '</fieldset>';
279
280echo '<fieldset><legend>'.__('Entries list types').'</legend>';
281
282echo '<table id="entrieslist">'.'<caption>'.__('Entries lists').'</caption>'.
283'<thead>'.
284'<tr>'.
285'<th scope="col">'.__('Context').'</th>'.
286'<th scope="col">'.__('Entries list type').'</th>'.
287'</tr>'.
288'</thead>'.
289'<tbody>';
290foreach ($ductile_lists as $k => $v) {
291     echo 
292          '<tr>'.
293          '<td scope="raw">'.$contexts[$k].'</td>'.
294          '<td>'.form::hidden(array('list_ctx[]'),$k).form::combo(array('list_type[]'),$list_types,$v).'</td>'.
295          '</tr>';
296}
297echo
298'</tbody>'.
299'</table>';
300
301echo '</fieldset>';
302
303echo '<input type="hidden" name="conf_tab" value="html">';
304echo '<p class="clear"><input type="submit" value="'.__('Save').'" />'.$core->formNonce().'</p>';
305echo '</form>';
306
307echo '</div>'; // Close tab
308
309# CSS tab
310
311echo '<div class="multi-part" id="themes-list'.($conf_tab == 'css' ? '' : '-css').'" title="'.__('Presentation').'">';
312
313echo '<form id="theme_config" action="blog_theme.php?conf=1" method="post" enctype="multipart/form-data">';
314
315echo '<h3>'.__('General settings').'</h3>';
316
317echo '<fieldset><legend>'.__('Fonts').'</legend>'.
318'<p class="field"><label for="body_font">'.__('Main:').' '.
319form::combo('body_font',$fonts,$ductile_user['body_font']).'</label></p>'.
320
321'<p class="field"><label for="alternate_font">'.__('Secondary:').' '.
322form::combo('alternate_font',$fonts,$ductile_user['alternate_font']).'</label></p>'.
323'</fieldset>';
324
325echo '<div class="two-cols">';
326echo '<div class="col">';
327
328echo '<fieldset><legend>'.__('Blog title').'</legend>'.
329'<p class="field"><label for="blog_title_w">'.__('In bold:').' '.
330form::checkbox('blog_title_w',1,$ductile_user['blog_title_w']).'</label>'.'</p>'.
331
332'<p class="field"><label for="blog_title_s">'.__('Font size (in em by default):').'</label> '.
333form::field('blog_title_s',7,7,$ductile_user['blog_title_s']).'</p>'.
334
335'<p class="field picker"><label for="blog_title_c">'.__('Color:').'</label> '.
336form::field('blog_title_c',7,7,$ductile_user['blog_title_c'],'colorpicker').'</p>'.
337'</fieldset>';
338
339echo '</div>';
340echo '<div class="col">';
341
342echo '<fieldset><legend>'.__('Post title').'</legend>'.
343'<p class="field"><label for="post_title_w">'.__('In bold:').' '.
344form::checkbox('post_title_w',1,$ductile_user['post_title_w']).'</label>'.'</p>'.
345
346'<p class="field"><label for="post_title_s">'.__('Font size (in em by default):').'</label> '.
347form::field('post_title_s',7,7,$ductile_user['post_title_s']).'</p>'.
348
349'<p class="field picker"><label for="post_title_c">'.__('Color:').'</label> '.
350form::field('post_title_c',7,7,$ductile_user['post_title_c'],'colorpicker').'</p>'.
351'</fieldset>';
352
353echo '</div>';
354echo '</div>';
355
356echo '<fieldset><legend>'.__('Titles without link').'</legend>'.
357
358'<p class="field picker"><label for="post_simple_title_c">'.__('Color:').'</label> '.
359form::field('post_simple_title_c',7,7,$ductile_user['post_simple_title_c'],'colorpicker').'</p>'.
360'</fieldset>';
361
362echo '<fieldset><legend>'.__('Inside posts links').'</legend>'.
363'<p class="field"><label for="post_link_w">'.__('In bold:').' '.
364form::checkbox('post_link_w',1,$ductile_user['post_link_w']).'</label>'.'</p>'.
365
366'<p class="field picker"><label for="post_link_v_c">'.__('Normal and visited links color:').'</label> '.
367form::field('post_link_v_c',7,7,$ductile_user['post_link_v_c'],'colorpicker').'</p>'.
368
369'<p class="field picker"><label for="body_link_f_c">'.__('Active, hover and focus links color:').'</label> '.
370form::field('post_link_f_c',7,7,$ductile_user['post_link_f_c'],'colorpicker').'</p>'.
371'</fieldset>';
372
373echo '<h3>'.__('Mobile specific settings').'</h3>';
374
375echo '<div class="two-cols">';
376echo '<div class="col">';
377
378echo '<fieldset><legend>'.__('Blog title').'</legend>'.
379'<p class="field"><label for="blog_title_w_m">'.__('In bold:').' '.
380form::checkbox('blog_title_w_m',1,$ductile_user['blog_title_w_m']).'</label>'.'</p>'.
381
382'<p class="field"><label for="blog_title_s_m">'.__('Font size (in em by default):').'</label> '.
383form::field('blog_title_s_m',7,7,$ductile_user['blog_title_s_m']).'</p>'.
384
385'<p class="field picker"><label for="blog_title_c_m">'.__('Color:').'</label> '.
386form::field('blog_title_c_m',7,7,$ductile_user['blog_title_c_m'],'colorpicker').'</p>'.
387'</fieldset>';
388
389echo '</div>';
390echo '<div class="col">';
391
392echo '<fieldset><legend>'.__('Post title').'</legend>'.
393'<p class="field"><label for="post_title_w_m">'.__('In bold:').' '.
394form::checkbox('post_title_w_m',1,$ductile_user['post_title_w_m']).'</label>'.'</p>'.
395
396'<p class="field"><label for="post_title_s_m">'.__('Font size (in em by default):').'</label> '.
397form::field('post_title_s_m',7,7,$ductile_user['post_title_s_m']).'</p>'.
398
399'<p class="field picker"><label for="post_title_c_m">'.__('Color:').'</label> '.
400form::field('post_title_c_m',7,7,$ductile_user['post_title_c_m'],'colorpicker').'</p>'.
401'</fieldset>';
402
403echo '</div>';
404echo '</div>';
405
406echo '<input type="hidden" name="conf_tab" value="css">';
407echo '<p class="clear"><input type="submit" value="'.__('Save').'" />'.$core->formNonce().'</p>';
408echo '</form>';
409
410echo '</div>'; // Close tab
411
412// To be deleted when adminThemeConfigManaged behaviour will be implemented in admin/blog_themes.php :
413echo '<form style="display:none">';
414
415?>
Note: See TracBrowser for help on using the repository browser.

Sites map