Dotclear

source: themes/ductile/_config.php @ 389:217c64dcfc81

Revision 389:217c64dcfc81, 7.8 KB checked in by Franck <carnet.franck.paul@…>, 14 years ago (diff)

Configuration (HTML) : mise en place des onglets (contenu html / contenant css) imparfaite* et ajout du masquage de la description du blog

  • Les colorpickers sont à l'ouest (à cause des onglets), l'onglet actif est toujours le premier
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
96if (!empty($_POST))
97{
98     try
99     {
100          # HTML
101         
102          $ductile_user['subtitle_hidden'] = (integer) !empty($_POST['subtitle_hidden']);
103         
104          # CSS
105         
106          $ductile_user['body_font'] = $_POST['body_font'];
107          $ductile_user['alternate_font'] = $_POST['alternate_font'];
108
109          $ductile_user['blog_title_w'] = (integer) !empty($_POST['blog_title_w']);
110          $ductile_user['blog_title_s'] = adjustFontSize($_POST['blog_title_s']);
111          $ductile_user['blog_title_c'] = adjustColor($_POST['blog_title_c']);
112         
113          $ductile_user['post_title_w'] = (integer) !empty($_POST['post_title_w']);
114          $ductile_user['post_title_s'] = adjustFontSize($_POST['post_title_s']);
115          $ductile_user['post_title_c'] = adjustColor($_POST['post_title_c']);
116         
117          $ductile_user['post_link_w'] = (integer) !empty($_POST['post_link_w']);
118          $ductile_user['post_link_v_c'] = adjustColor($_POST['post_link_v_c']);
119          $ductile_user['post_link_f_c'] = adjustColor($_POST['post_link_f_c']);
120         
121          $ductile_user['blog_title_w_m'] = (integer) !empty($_POST['blog_title_w_m']);
122          $ductile_user['blog_title_s_m'] = adjustFontSize($_POST['blog_title_s_m']);
123          $ductile_user['blog_title_c_m'] = adjustColor($_POST['blog_title_c_m']);
124         
125          $ductile_user['post_title_w_m'] = (integer) !empty($_POST['post_title_w_m']);
126          $ductile_user['post_title_s_m'] = adjustFontSize($_POST['post_title_s_m']);
127          $ductile_user['post_title_c_m'] = adjustColor($_POST['post_title_c_m']);
128         
129          $core->blog->settings->addNamespace('themes');
130          $core->blog->settings->themes->put('ductile_style',serialize($ductile_user));
131          $core->blog->triggerBlog();
132
133          echo
134          '<div class="message"><p>'.
135          __('Theme configuration upgraded.').
136          '</p></div>';
137     }
138     catch (Exception $e)
139     {
140          $core->error->add($e->getMessage());
141     }
142}
143
144# HTML Tab
145
146echo '<div class="multi-part" id="themes-list" title="'.__('Content').'">';
147
148echo '<fieldset><legend>'.__('Header').'</legend>'.
149'<p class="field"><label for="subtitle_hidden">'.__('Hide blog description:').' '.
150form::checkbox('subtitle_hidden',1,$ductile_user['subtitle_hidden']).'</label>'.'</p>'.
151'</fieldset>';
152
153echo '</div>'; // Close tab
154
155# CSS tab
156
157echo '<div class="multi-part" id="ductile-css" title="'.__('Presentation').'">';
158
159echo '<h3>'.__('General settings').'</h3>';
160
161echo '<fieldset><legend>'.__('Fonts').'</legend>'.
162'<p class="field"><label for="body_font">'.__('Main:').' '.
163form::combo('body_font',$fonts,$ductile_user['body_font']).'</label></p>'.
164
165'<p class="field"><label for="alternate_font">'.__('Secondary:').' '.
166form::combo('alternate_font',$fonts,$ductile_user['alternate_font']).'</label></p>'.
167'</fieldset>';
168
169echo '<div class="two-cols">';
170echo '<div class="col">';
171
172echo '<fieldset><legend>'.__('Blog title').'</legend>'.
173'<p class="field"><label for="blog_title_w">'.__('In bold:').' '.
174form::checkbox('blog_title_w',1,$ductile_user['blog_title_w']).'</label>'.'</p>'.
175
176'<p class="field"><label for="blog_title_s">'.__('Font size:').'</label> '.
177form::field('blog_title_s',7,7,$ductile_user['blog_title_s']).' '.__('(in em by default)').'</p>'.
178
179'<p class="field picker"><label for="blog_title_c">'.__('Color:').'</label> '.
180form::field('blog_title_c',7,7,$ductile_user['blog_title_c'],'colorpicker').'</p>'.
181'</fieldset>';
182
183echo '</div>';
184echo '<div class="col">';
185
186echo '<fieldset><legend>'.__('Post title').'</legend>'.
187'<p class="field"><label for="post_title_w">'.__('In bold:').' '.
188form::checkbox('post_title_w',1,$ductile_user['post_title_w']).'</label>'.'</p>'.
189
190'<p class="field"><label for="post_title_s">'.__('Font size:').'</label> '.
191form::field('post_title_s',7,7,$ductile_user['post_title_s']).' '.__('(in em by default)').'</p>'.
192
193'<p class="field picker"><label for="post_title_c">'.__('Color:').'</label> '.
194form::field('post_title_c',7,7,$ductile_user['post_title_c'],'colorpicker').'</p>'.
195'</fieldset>';
196
197echo '</div>';
198echo '</div>';
199
200echo '<fieldset><legend>'.__('Inside posts links').'</legend>'.
201'<p class="field"><label for="post_link_w">'.__('In bold:').' '.
202form::checkbox('post_link_w',1,$ductile_user['post_link_w']).'</label>'.'</p>'.
203
204'<p class="field picker"><label for="post_link_v_c">'.__('Normal and visited links color:').'</label> '.
205form::field('post_link_v_c',7,7,$ductile_user['post_link_v_c'],'colorpicker').'</p>'.
206
207'<p class="field picker"><label for="body_link_f_c">'.__('Active, hover and focus links color:').'</label> '.
208form::field('post_link_f_c',7,7,$ductile_user['post_link_f_c'],'colorpicker').'</p>'.
209'</fieldset>';
210
211echo '<h3>'.__('Mobile specific settings').'</h3>';
212
213echo '<div class="two-cols">';
214echo '<div class="col">';
215
216echo '<fieldset><legend>'.__('Blog title').'</legend>'.
217'<p class="field"><label for="blog_title_w_m">'.__('In bold:').' '.
218form::checkbox('blog_title_w_m',1,$ductile_user['blog_title_w_m']).'</label>'.'</p>'.
219
220'<p class="field"><label for="blog_title_s_m">'.__('Font size:').'</label> '.
221form::field('blog_title_s_m',7,7,$ductile_user['blog_title_s_m']).' '.__('(in em by default)').'</p>'.
222
223'<p class="field picker"><label for="blog_title_c_m">'.__('Color:').'</label> '.
224form::field('blog_title_c_m',7,7,$ductile_user['blog_title_c_m'],'colorpicker').'</p>'.
225'</fieldset>';
226
227echo '</div>';
228echo '<div class="col">';
229
230echo '<fieldset><legend>'.__('Post title').'</legend>'.
231'<p class="field"><label for="post_title_w_m">'.__('In bold:').' '.
232form::checkbox('post_title_w_m',1,$ductile_user['post_title_w_m']).'</label>'.'</p>'.
233
234'<p class="field"><label for="post_title_s_m">'.__('Font size:').'</label> '.
235form::field('post_title_s_m',7,7,$ductile_user['post_title_s_m']).' '.__('(in em by default)').'</p>'.
236
237'<p class="field picker"><label for="post_title_c_m">'.__('Color:').'</label> '.
238form::field('post_title_c_m',7,7,$ductile_user['post_title_c_m'],'colorpicker').'</p>'.
239'</fieldset>';
240
241echo '</div>';
242echo '</div>';
243
244echo '</div>'; // Close tab
245
246?>
Note: See TracBrowser for help on using the repository browser.

Sites map