Dotclear

source: themes/ductile/_config.php @ 390:a8c2855e64e5

Revision 390:a8c2855e64e5, 8.6 KB checked in by Franck <carnet.franck.paul@…>, 14 years ago (diff)

Configuration : mise en place des onglets, step 2 avec du hack de la mort qui tue et du coup deux formulaires fantômes qui posent éventuellement problème point de vue accessibilité ? Si un expert accessibilité passe dans le coin, qu'il n'hésite pas, hein ? C'est pour la bonne cause :-)

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.'/main');
15
16$fonts = array(
17     __('default') => '',
18     __('Ductile primary') => 'Ductile body',
19     __('Ductile secondary') => 'Ductile alternate',
20     __('Times New Roman') => 'Times New Roman',
21     __('Georgia') => 'Georgia',
22     __('Garamond') => 'Garamond',
23     __('Helvetica/Arial') => 'Helvetica/Arial',
24     __('Verdana') => 'Verdana',
25     __('Trebuchet MS') => 'Trebuchet MS',
26     __('Impact') => 'Impact',
27     __('Monospace') => 'Monospace'
28);
29
30function adjustFontSize($s)
31{
32     if (preg_match('/^([0-9.]+)\s*(%|pt|px|em|ex)?$/',$s,$m)) {
33          if (empty($m[2])) {
34               $m[2] = 'em';
35          }
36          return $m[1].$m[2];
37     }
38
39     return null;
40}
41
42function adjustColor($c)
43{
44     if ($c === '') {
45          return '';
46     }
47
48     $c = strtoupper($c);
49
50     if (preg_match('/^[A-F0-9]{3,6}$/',$c)) {
51          $c = '#'.$c;
52     }
53
54     if (preg_match('/^#[A-F0-9]{6}$/',$c)) {
55          return $c;
56     }
57
58     if (preg_match('/^#[A-F0-9]{3,}$/',$c)) {
59          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);
60     }
61
62     return '';
63}
64
65$ductile_base = array(
66     // HTML
67     'subtitle_hidden' => null,
68     // CSS
69     'body_font' => null,
70     'alternate_font' => null,
71     'blog_title_w' => null,
72     'blog_title_s' => null,
73     'blog_title_c' => null,
74     'post_title_w' => null,
75     'post_title_s' => null,
76     'post_title_c' => null,
77     'post_link_w' => null,
78     'post_link_v_c' => null,
79     'post_link_f_c' => null,
80     'blog_title_w_m' => null,
81     'blog_title_s_m' => null,
82     'blog_title_c_m' => null,
83     'post_title_w_m' => null,
84     'post_title_s_m' => null,
85     'post_title_c_m' => null
86);
87
88$ductile_user = $core->blog->settings->themes->ductile_style;
89$ductile_user = @unserialize($ductile_user);
90if (!is_array($ductile_user)) {
91     $ductile_user = array();
92}
93
94$ductile_user = array_merge($ductile_base,$ductile_user);
95
96$conf_tab = isset($_POST['conf_tab']) ? $_POST['conf_tab'] : 'html';
97
98if (!empty($_POST))
99{
100     try
101     {
102          # HTML
103          if ($conf_tab == 'html') {
104               $ductile_user['subtitle_hidden'] = (integer) !empty($_POST['subtitle_hidden']);
105          }
106         
107          # CSS
108          if ($conf_tab == 'css') {
109               $ductile_user['body_font'] = $_POST['body_font'];
110               $ductile_user['alternate_font'] = $_POST['alternate_font'];
111
112               $ductile_user['blog_title_w'] = (integer) !empty($_POST['blog_title_w']);
113               $ductile_user['blog_title_s'] = adjustFontSize($_POST['blog_title_s']);
114               $ductile_user['blog_title_c'] = adjustColor($_POST['blog_title_c']);
115         
116               $ductile_user['post_title_w'] = (integer) !empty($_POST['post_title_w']);
117               $ductile_user['post_title_s'] = adjustFontSize($_POST['post_title_s']);
118               $ductile_user['post_title_c'] = adjustColor($_POST['post_title_c']);
119         
120               $ductile_user['post_link_w'] = (integer) !empty($_POST['post_link_w']);
121               $ductile_user['post_link_v_c'] = adjustColor($_POST['post_link_v_c']);
122               $ductile_user['post_link_f_c'] = adjustColor($_POST['post_link_f_c']);
123         
124               $ductile_user['blog_title_w_m'] = (integer) !empty($_POST['blog_title_w_m']);
125               $ductile_user['blog_title_s_m'] = adjustFontSize($_POST['blog_title_s_m']);
126               $ductile_user['blog_title_c_m'] = adjustColor($_POST['blog_title_c_m']);
127         
128               $ductile_user['post_title_w_m'] = (integer) !empty($_POST['post_title_w_m']);
129               $ductile_user['post_title_s_m'] = adjustFontSize($_POST['post_title_s_m']);
130               $ductile_user['post_title_c_m'] = adjustColor($_POST['post_title_c_m']);
131          }
132         
133          $core->blog->settings->addNamespace('themes');
134          $core->blog->settings->themes->put('ductile_style',serialize($ductile_user));
135          $core->blog->triggerBlog();
136
137          echo
138          '<div class="message"><p>'.
139          __('Theme configuration upgraded.').
140          '</p></div>';
141     }
142     catch (Exception $e)
143     {
144          $core->error->add($e->getMessage());
145     }
146}
147
148echo '</form>';
149
150# HTML Tab
151
152echo '<div class="multi-part" id="themes-list'.($conf_tab == 'html' ? '' : '-html').'" title="'.__('Content').'">';
153
154echo '<form id="theme_config" action="blog_theme.php?conf=1" method="post" enctype="multipart/form-data">';
155
156echo '<fieldset><legend>'.__('Header').'</legend>'.
157'<p class="field"><label for="subtitle_hidden">'.__('Hide blog description:').' '.
158form::checkbox('subtitle_hidden',1,$ductile_user['subtitle_hidden']).'</label>'.'</p>'.
159'</fieldset>';
160
161echo '<input type="hidden" name="conf_tab" value="html">';
162echo '<p class="clear"><input type="submit" value="'.__('Save').'" />'.$core->formNonce().'</p>';
163echo '</form>';
164
165echo '</div>'; // Close tab
166
167# CSS tab
168
169echo '<div class="multi-part" id="themes-list'.($conf_tab == 'css' ? '' : '-css').'" title="'.__('Presentation').'">';
170
171echo '<form id="theme_config" action="blog_theme.php?conf=1" method="post" enctype="multipart/form-data">';
172
173echo '<h3>'.__('General settings').'</h3>';
174
175echo '<fieldset><legend>'.__('Fonts').'</legend>'.
176'<p class="field"><label for="body_font">'.__('Main:').' '.
177form::combo('body_font',$fonts,$ductile_user['body_font']).'</label></p>'.
178
179'<p class="field"><label for="alternate_font">'.__('Secondary:').' '.
180form::combo('alternate_font',$fonts,$ductile_user['alternate_font']).'</label></p>'.
181'</fieldset>';
182
183echo '<div class="two-cols">';
184echo '<div class="col">';
185
186echo '<fieldset><legend>'.__('Blog title').'</legend>'.
187'<p class="field"><label for="blog_title_w">'.__('In bold:').' '.
188form::checkbox('blog_title_w',1,$ductile_user['blog_title_w']).'</label>'.'</p>'.
189
190'<p class="field"><label for="blog_title_s">'.__('Font size:').'</label> '.
191form::field('blog_title_s',7,7,$ductile_user['blog_title_s']).' '.__('(in em by default)').'</p>'.
192
193'<p class="field picker"><label for="blog_title_c">'.__('Color:').'</label> '.
194form::field('blog_title_c',7,7,$ductile_user['blog_title_c'],'colorpicker').'</p>'.
195'</fieldset>';
196
197echo '</div>';
198echo '<div class="col">';
199
200echo '<fieldset><legend>'.__('Post title').'</legend>'.
201'<p class="field"><label for="post_title_w">'.__('In bold:').' '.
202form::checkbox('post_title_w',1,$ductile_user['post_title_w']).'</label>'.'</p>'.
203
204'<p class="field"><label for="post_title_s">'.__('Font size:').'</label> '.
205form::field('post_title_s',7,7,$ductile_user['post_title_s']).' '.__('(in em by default)').'</p>'.
206
207'<p class="field picker"><label for="post_title_c">'.__('Color:').'</label> '.
208form::field('post_title_c',7,7,$ductile_user['post_title_c'],'colorpicker').'</p>'.
209'</fieldset>';
210
211echo '</div>';
212echo '</div>';
213
214echo '<fieldset><legend>'.__('Inside posts links').'</legend>'.
215'<p class="field"><label for="post_link_w">'.__('In bold:').' '.
216form::checkbox('post_link_w',1,$ductile_user['post_link_w']).'</label>'.'</p>'.
217
218'<p class="field picker"><label for="post_link_v_c">'.__('Normal and visited links color:').'</label> '.
219form::field('post_link_v_c',7,7,$ductile_user['post_link_v_c'],'colorpicker').'</p>'.
220
221'<p class="field picker"><label for="body_link_f_c">'.__('Active, hover and focus links color:').'</label> '.
222form::field('post_link_f_c',7,7,$ductile_user['post_link_f_c'],'colorpicker').'</p>'.
223'</fieldset>';
224
225echo '<h3>'.__('Mobile specific settings').'</h3>';
226
227echo '<div class="two-cols">';
228echo '<div class="col">';
229
230echo '<fieldset><legend>'.__('Blog title').'</legend>'.
231'<p class="field"><label for="blog_title_w_m">'.__('In bold:').' '.
232form::checkbox('blog_title_w_m',1,$ductile_user['blog_title_w_m']).'</label>'.'</p>'.
233
234'<p class="field"><label for="blog_title_s_m">'.__('Font size:').'</label> '.
235form::field('blog_title_s_m',7,7,$ductile_user['blog_title_s_m']).' '.__('(in em by default)').'</p>'.
236
237'<p class="field picker"><label for="blog_title_c_m">'.__('Color:').'</label> '.
238form::field('blog_title_c_m',7,7,$ductile_user['blog_title_c_m'],'colorpicker').'</p>'.
239'</fieldset>';
240
241echo '</div>';
242echo '<div class="col">';
243
244echo '<fieldset><legend>'.__('Post title').'</legend>'.
245'<p class="field"><label for="post_title_w_m">'.__('In bold:').' '.
246form::checkbox('post_title_w_m',1,$ductile_user['post_title_w_m']).'</label>'.'</p>'.
247
248'<p class="field"><label for="post_title_s_m">'.__('Font size:').'</label> '.
249form::field('post_title_s_m',7,7,$ductile_user['post_title_s_m']).' '.__('(in em by default)').'</p>'.
250
251'<p class="field picker"><label for="post_title_c_m">'.__('Color:').'</label> '.
252form::field('post_title_c_m',7,7,$ductile_user['post_title_c_m'],'colorpicker').'</p>'.
253'</fieldset>';
254
255echo '</div>';
256echo '</div>';
257
258echo '<input type="hidden" name="conf_tab" value="css">';
259echo '<p class="clear"><input type="submit" value="'.__('Save').'" />'.$core->formNonce().'</p>';
260echo '</form>';
261
262echo '</div>'; // Close tab
263
264echo '<form style="display:none">';
265
266?>
Note: See TracBrowser for help on using the repository browser.

Sites map