Dotclear

source: themes/ductile/_config.php @ 583:c7f81168aa22

Revision 583:c7f81168aa22, 14.7 KB checked in by Franck <carnet.franck.paul@…>, 14 years ago (diff)

Configuration du nb de billets par page pour les contextes home (toute page), catégorie, tag, recherche.

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$ductile_counts_base = array(
146     'default' => null,
147     'category' => null,
148     'tag' => null,
149     'search' => null
150);
151
152$ductile_counts = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_entries_counts');
153$ductile_counts = @unserialize($ductile_counts);
154if (!is_array($ductile_counts)) {
155     $ductile_counts = $ductile_counts_base;
156}
157
158
159$conf_tab = isset($_POST['conf_tab']) ? $_POST['conf_tab'] : 'html';
160
161if (!empty($_POST))
162{
163     try
164     {
165          # HTML
166          if ($conf_tab == 'html') {
167               $ductile_user['subtitle_hidden'] = (integer) !empty($_POST['subtitle_hidden']);
168               
169               $count = 0;
170               if (!empty($_POST['sticker1_label']) && !empty($_POST['sticker1_url'])) {
171                    $ductile_stickers[$count]['label'] = $_POST['sticker1_label'];
172                    $ductile_stickers[$count]['url'] = $_POST['sticker1_url'];
173                    $ductile_stickers[$count]['image'] = $_POST['sticker1_image'];
174                    $count++;
175               }
176               if (!empty($_POST['sticker2_label']) && !empty($_POST['sticker2_url'])) {
177                    $ductile_stickers[$count]['label'] = $_POST['sticker2_label'];
178                    $ductile_stickers[$count]['url'] = $_POST['sticker2_url'];
179                    $ductile_stickers[$count]['image'] = $_POST['sticker2_image'];
180                    $count++;
181               }
182               if (!empty($_POST['sticker3_label']) && !empty($_POST['sticker3_url'])) {
183                    $ductile_stickers[$count]['label'] = $_POST['sticker3_label'];
184                    $ductile_stickers[$count]['url'] = $_POST['sticker3_url'];
185                    $ductile_stickers[$count]['image'] = $_POST['sticker3_image'];
186                    $count++;
187               }
188               for ($i = $count; $i < 3; $i++) {
189                    $ductile_stickers[$i]['label'] = null;
190                    $ductile_stickers[$i]['url'] = null;
191                    $ductile_stickers[$i]['image'] = null;
192               }
193
194               for ($i = 0; $i < count($_POST['list_type']); $i++) {
195                    $ductile_lists[$_POST['list_ctx'][$i]] = $_POST['list_type'][$i];
196               }
197               
198               for ($i = 0; $i < count($_POST['count_nb']); $i++) {
199                    $ductile_counts[$_POST['count_ctx'][$i]] = $_POST['count_nb'][$i];
200               }
201               
202          }
203         
204          # CSS
205          if ($conf_tab == 'css') {
206               $ductile_user['body_font'] = $_POST['body_font'];
207               $ductile_user['alternate_font'] = $_POST['alternate_font'];
208
209               $ductile_user['blog_title_w'] = (integer) !empty($_POST['blog_title_w']);
210               $ductile_user['blog_title_s'] = adjustFontSize($_POST['blog_title_s']);
211               $ductile_user['blog_title_c'] = adjustColor($_POST['blog_title_c']);
212         
213               $ductile_user['post_title_w'] = (integer) !empty($_POST['post_title_w']);
214               $ductile_user['post_title_s'] = adjustFontSize($_POST['post_title_s']);
215               $ductile_user['post_title_c'] = adjustColor($_POST['post_title_c']);
216         
217               $ductile_user['post_link_w'] = (integer) !empty($_POST['post_link_w']);
218               $ductile_user['post_link_v_c'] = adjustColor($_POST['post_link_v_c']);
219               $ductile_user['post_link_f_c'] = adjustColor($_POST['post_link_f_c']);
220         
221               $ductile_user['post_simple_title_c'] = adjustColor($_POST['post_simple_title_c']);
222         
223               $ductile_user['blog_title_w_m'] = (integer) !empty($_POST['blog_title_w_m']);
224               $ductile_user['blog_title_s_m'] = adjustFontSize($_POST['blog_title_s_m']);
225               $ductile_user['blog_title_c_m'] = adjustColor($_POST['blog_title_c_m']);
226         
227               $ductile_user['post_title_w_m'] = (integer) !empty($_POST['post_title_w_m']);
228               $ductile_user['post_title_s_m'] = adjustFontSize($_POST['post_title_s_m']);
229               $ductile_user['post_title_c_m'] = adjustColor($_POST['post_title_c_m']);
230          }
231         
232          $core->blog->settings->addNamespace('themes');
233          $core->blog->settings->themes->put($core->blog->settings->system->theme.'_style',serialize($ductile_user));
234          $core->blog->settings->themes->put($core->blog->settings->system->theme.'_stickers',serialize($ductile_stickers));
235          $core->blog->settings->themes->put($core->blog->settings->system->theme.'_entries_lists',serialize($ductile_lists));
236          $core->blog->settings->themes->put($core->blog->settings->system->theme.'_entries_counts',serialize($ductile_counts));
237
238          // Blog refresh
239          $core->blog->triggerBlog();
240
241          // Template cache reset
242          $core->emptyTemplatesCache();
243         
244          echo
245          '<div class="message"><p>'.
246          __('Theme configuration upgraded.').
247          '</p></div>';
248     }
249     catch (Exception $e)
250     {
251          $core->error->add($e->getMessage());
252     }
253}
254
255// To be deleted when adminThemeConfigManaged behaviour will be implemented in admin/blog_themes.php :
256echo '</form>';
257
258# HTML Tab
259
260echo '<div class="multi-part" id="themes-list'.($conf_tab == 'html' ? '' : '-html').'" title="'.__('Content').'">';
261
262echo '<form id="theme_config" action="blog_theme.php?conf=1" method="post" enctype="multipart/form-data">';
263
264echo '<fieldset><legend>'.__('Header').'</legend>'.
265'<p class="field"><label for="subtitle_hidden">'.__('Hide blog description:').' '.
266form::checkbox('subtitle_hidden',1,$ductile_user['subtitle_hidden']).'</label>'.'</p>'.
267'</fieldset>';
268
269echo '<fieldset><legend>'.__('Stickers').'</legend>';
270
271echo '<table id="stickerslist">'.'<caption>'.__('Stickers (footer)').'</caption>'.
272'<thead>'.
273'<tr>'.
274'<th scope="col">'.__('Position').'</th>'.
275'<th scope="col">'.__('Label').'</th>'.
276'<th scope="col">'.__('URL').'</th>'.
277'<th scope="col">'.__('Icon').'</th>'.
278'</tr>'.
279'</thead>'.
280'<tbody>'.
281'<tr>'.
282'<td scope="raw">1</td>'.
283'<td>'.form::field('sticker1_label',20,255,$ductile_stickers[0]['label']).'</td>'.
284'<td>'.form::field('sticker1_url',40,255,$ductile_stickers[0]['url']).'</td>'.
285'<td>'.form::combo('sticker1_image',$sticker_images,$ductile_stickers[0]['image']).'</td>'.
286'</tr>'.
287'<tr>'.
288'<td scope="raw">2</td>'.
289'<td>'.form::field('sticker2_label',20,255,$ductile_stickers[1]['label']).'</td>'.
290'<td>'.form::field('sticker2_url',40,255,$ductile_stickers[1]['url']).'</td>'.
291'<td>'.form::combo('sticker2_image',$sticker_images,$ductile_stickers[1]['image']).'</td>'.
292'</tr>'.
293'<tr>'.
294'<td scope="raw">3</td>'.
295'<td>'.form::field('sticker3_label',20,255,$ductile_stickers[2]['label']).'</td>'.
296'<td>'.form::field('sticker3_url',40,255,$ductile_stickers[2]['url']).'</td>'.
297'<td>'.form::combo('sticker3_image',$sticker_images,$ductile_stickers[2]['image']).'</td>'.
298'</tr>'.
299'</tbody>'.
300'</table>';
301
302echo '</fieldset>';
303
304echo '<fieldset><legend>'.__('Entries list types and limits').'</legend>';
305
306echo '<table id="entrieslist">'.'<caption>'.__('Entries lists').'</caption>'.
307'<thead>'.
308'<tr>'.
309'<th scope="col">'.__('Context').'</th>'.
310'<th scope="col">'.__('Entries list type').'</th>'.
311'<th scope="col">'.__('Number of entries').'</th>'.
312'</tr>'.
313'</thead>'.
314'<tbody>';
315foreach ($ductile_lists as $k => $v) {
316     echo 
317          '<tr>'.
318          '<td scope="raw">'.$contexts[$k].'</td>'.
319          '<td>'.form::hidden(array('list_ctx[]'),$k).form::combo(array('list_type[]'),$list_types,$v).'</td>';
320     if (array_key_exists($k,$ductile_counts)) {
321          echo '<td>'.form::hidden(array('count_ctx[]'),$k).form::field(array('count_nb[]'),2,3,$ductile_counts[$k]).'</td>';
322     } else {
323          echo '<td></td>';
324     }
325     echo
326          '</tr>';
327}
328echo
329'</tbody>'.
330'</table>';
331
332echo '</fieldset>';
333
334echo '<input type="hidden" name="conf_tab" value="html">';
335echo '<p class="clear"><input type="submit" value="'.__('Save').'" />'.$core->formNonce().'</p>';
336echo '</form>';
337
338echo '</div>'; // Close tab
339
340# CSS tab
341
342echo '<div class="multi-part" id="themes-list'.($conf_tab == 'css' ? '' : '-css').'" title="'.__('Presentation').'">';
343
344echo '<form id="theme_config" action="blog_theme.php?conf=1" method="post" enctype="multipart/form-data">';
345
346echo '<h3>'.__('General settings').'</h3>';
347
348echo '<fieldset><legend>'.__('Fonts').'</legend>'.
349'<p class="field"><label for="body_font">'.__('Main:').' '.
350form::combo('body_font',$fonts,$ductile_user['body_font']).'</label></p>'.
351
352'<p class="field"><label for="alternate_font">'.__('Secondary:').' '.
353form::combo('alternate_font',$fonts,$ductile_user['alternate_font']).'</label></p>'.
354'</fieldset>';
355
356echo '<div class="two-cols">';
357echo '<div class="col">';
358
359echo '<fieldset><legend>'.__('Blog title').'</legend>'.
360'<p class="field"><label for="blog_title_w">'.__('In bold:').' '.
361form::checkbox('blog_title_w',1,$ductile_user['blog_title_w']).'</label>'.'</p>'.
362
363'<p class="field"><label for="blog_title_s">'.__('Font size (in em by default):').'</label> '.
364form::field('blog_title_s',7,7,$ductile_user['blog_title_s']).'</p>'.
365
366'<p class="field picker"><label for="blog_title_c">'.__('Color:').'</label> '.
367form::field('blog_title_c',7,7,$ductile_user['blog_title_c'],'colorpicker').'</p>'.
368'</fieldset>';
369
370echo '</div>';
371echo '<div class="col">';
372
373echo '<fieldset><legend>'.__('Post title').'</legend>'.
374'<p class="field"><label for="post_title_w">'.__('In bold:').' '.
375form::checkbox('post_title_w',1,$ductile_user['post_title_w']).'</label>'.'</p>'.
376
377'<p class="field"><label for="post_title_s">'.__('Font size (in em by default):').'</label> '.
378form::field('post_title_s',7,7,$ductile_user['post_title_s']).'</p>'.
379
380'<p class="field picker"><label for="post_title_c">'.__('Color:').'</label> '.
381form::field('post_title_c',7,7,$ductile_user['post_title_c'],'colorpicker').'</p>'.
382'</fieldset>';
383
384echo '</div>';
385echo '</div>';
386
387echo '<fieldset><legend>'.__('Titles without link').'</legend>'.
388
389'<p class="field picker"><label for="post_simple_title_c">'.__('Color:').'</label> '.
390form::field('post_simple_title_c',7,7,$ductile_user['post_simple_title_c'],'colorpicker').'</p>'.
391'</fieldset>';
392
393echo '<fieldset><legend>'.__('Inside posts links').'</legend>'.
394'<p class="field"><label for="post_link_w">'.__('In bold:').' '.
395form::checkbox('post_link_w',1,$ductile_user['post_link_w']).'</label>'.'</p>'.
396
397'<p class="field picker"><label for="post_link_v_c">'.__('Normal and visited links color:').'</label> '.
398form::field('post_link_v_c',7,7,$ductile_user['post_link_v_c'],'colorpicker').'</p>'.
399
400'<p class="field picker"><label for="body_link_f_c">'.__('Active, hover and focus links color:').'</label> '.
401form::field('post_link_f_c',7,7,$ductile_user['post_link_f_c'],'colorpicker').'</p>'.
402'</fieldset>';
403
404echo '<h3>'.__('Mobile specific settings').'</h3>';
405
406echo '<div class="two-cols">';
407echo '<div class="col">';
408
409echo '<fieldset><legend>'.__('Blog title').'</legend>'.
410'<p class="field"><label for="blog_title_w_m">'.__('In bold:').' '.
411form::checkbox('blog_title_w_m',1,$ductile_user['blog_title_w_m']).'</label>'.'</p>'.
412
413'<p class="field"><label for="blog_title_s_m">'.__('Font size (in em by default):').'</label> '.
414form::field('blog_title_s_m',7,7,$ductile_user['blog_title_s_m']).'</p>'.
415
416'<p class="field picker"><label for="blog_title_c_m">'.__('Color:').'</label> '.
417form::field('blog_title_c_m',7,7,$ductile_user['blog_title_c_m'],'colorpicker').'</p>'.
418'</fieldset>';
419
420echo '</div>';
421echo '<div class="col">';
422
423echo '<fieldset><legend>'.__('Post title').'</legend>'.
424'<p class="field"><label for="post_title_w_m">'.__('In bold:').' '.
425form::checkbox('post_title_w_m',1,$ductile_user['post_title_w_m']).'</label>'.'</p>'.
426
427'<p class="field"><label for="post_title_s_m">'.__('Font size (in em by default):').'</label> '.
428form::field('post_title_s_m',7,7,$ductile_user['post_title_s_m']).'</p>'.
429
430'<p class="field picker"><label for="post_title_c_m">'.__('Color:').'</label> '.
431form::field('post_title_c_m',7,7,$ductile_user['post_title_c_m'],'colorpicker').'</p>'.
432'</fieldset>';
433
434echo '</div>';
435echo '</div>';
436
437echo '<input type="hidden" name="conf_tab" value="css">';
438echo '<p class="clear"><input type="submit" value="'.__('Save').'" />'.$core->formNonce().'</p>';
439echo '</form>';
440
441echo '</div>'; // Close tab
442
443// To be deleted when adminThemeConfigManaged behaviour will be implemented in admin/blog_themes.php :
444echo '<form style="display:none">';
445
446?>
Note: See TracBrowser for help on using the repository browser.

Sites map