Dotclear

source: themes/ductile/_config.php @ 387:023783060913

Revision 387:023783060913, 7.3 KB checked in by Franck <carnet.franck.paul@…>, 14 years ago (diff)

Configuration des titres - step 1 : graisse, taille et couleur

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     'body_font' => null,
67     'alternate_font' => null,
68     'blog_title_w' => null,
69     'blog_title_s' => null,
70     'blog_title_c' => null,
71     'post_title_w' => null,
72     'post_title_s' => null,
73     'post_title_c' => null,
74     'post_link_w' => null,
75     'post_link_v_c' => null,
76     'post_link_f_c' => null,
77     'blog_title_w_m' => null,
78     'blog_title_s_m' => null,
79     'blog_title_c_m' => null,
80     'post_title_w_m' => null,
81     'post_title_s_m' => null,
82     'post_title_c_m' => null
83);
84
85$ductile_user = $core->blog->settings->themes->ductile_style;
86$ductile_user = @unserialize($ductile_user);
87if (!is_array($ductile_user)) {
88     $ductile_user = array();
89}
90
91$ductile_user = array_merge($ductile_base,$ductile_user);
92
93if (!empty($_POST))
94{
95     try
96     {
97          $ductile_user['body_font'] = $_POST['body_font'];
98          $ductile_user['alternate_font'] = $_POST['alternate_font'];
99
100          $ductile_user['blog_title_w'] = (integer) !empty($_POST['blog_title_w']);
101          $ductile_user['blog_title_s'] = adjustFontSize($_POST['blog_title_s']);
102          $ductile_user['blog_title_c'] = adjustColor($_POST['blog_title_c']);
103         
104          $ductile_user['post_title_w'] = (integer) !empty($_POST['post_title_w']);
105          $ductile_user['post_title_s'] = adjustFontSize($_POST['post_title_s']);
106          $ductile_user['post_title_c'] = adjustColor($_POST['post_title_c']);
107         
108          $ductile_user['post_link_w'] = (integer) !empty($_POST['post_link_w']);
109          $ductile_user['post_link_v_c'] = adjustColor($_POST['post_link_v_c']);
110          $ductile_user['post_link_f_c'] = adjustColor($_POST['post_link_f_c']);
111         
112          $ductile_user['blog_title_w_m'] = (integer) !empty($_POST['blog_title_w_m']);
113          $ductile_user['blog_title_s_m'] = adjustFontSize($_POST['blog_title_s_m']);
114          $ductile_user['blog_title_c_m'] = adjustColor($_POST['blog_title_c_m']);
115         
116          $ductile_user['post_title_w_m'] = (integer) !empty($_POST['post_title_w_m']);
117          $ductile_user['post_title_s_m'] = adjustFontSize($_POST['post_title_s_m']);
118          $ductile_user['post_title_c_m'] = adjustColor($_POST['post_title_c_m']);
119         
120          $core->blog->settings->addNamespace('themes');
121          $core->blog->settings->themes->put('ductile_style',serialize($ductile_user));
122          $core->blog->triggerBlog();
123
124          echo
125          '<div class="message"><p>'.
126          __('Style sheet upgraded.').
127          '</p></div>';
128     }
129     catch (Exception $e)
130     {
131          $core->error->add($e->getMessage());
132     }
133}
134
135echo '<h3>'.__('General settings').'</h3>';
136
137echo '<fieldset><legend>'.__('Fonts').'</legend>'.
138'<p class="field"><label for="body_font">'.__('Main font:').' '.
139form::combo('body_font',$fonts,$ductile_user['body_font']).'</label></p>'.
140
141'<p class="field"><label for="alternate_font">'.__('Secondary font:').' '.
142form::combo('alternate_font',$fonts,$ductile_user['alternate_font']).'</label></p>'.
143'</fieldset>';
144
145echo '<div class="two-cols">';
146echo '<div class="col">';
147
148echo '<fieldset><legend>'.__('Blog title').'</legend>'.
149'<p class="field"><label for="blog_title_w">'.__('Blog title in bold:').' '.
150form::checkbox('blog_title_w',1,$ductile_user['blog_title_w']).'</label>'.'</p>'.
151
152'<p class="field"><label for="blog_title_s">'.__('Blog title font size:').'</label> '.
153form::field('blog_title_s',7,7,$ductile_user['blog_title_s']).' '.__('(in em by default)').'</p>'.
154
155'<p class="field"><label for="blog_title_c">'.__('Blog title color:').'</label> '.
156form::field('blog_title_c',7,7,$ductile_user['blog_title_c'],'colorpicker').'</p>'.
157'</fieldset>';
158
159echo '</div>';
160echo '<div class="col">';
161
162echo '<fieldset><legend>'.__('Post title').'</legend>'.
163'<p class="field"><label for="post_title_w">'.__('Post title in bold:').' '.
164form::checkbox('post_title_w',1,$ductile_user['post_title_w']).'</label>'.'</p>'.
165
166'<p class="field"><label for="post_title_s">'.__('Post title font size:').'</label> '.
167form::field('post_title_s',7,7,$ductile_user['post_title_s']).' '.__('(in em by default)').'</p>'.
168
169'<p class="field"><label for="post_title_c">'.__('Post title color:').'</label> '.
170form::field('post_title_c',7,7,$ductile_user['post_title_c'],'colorpicker').'</p>'.
171'</fieldset>';
172
173echo '</div>';
174echo '</div>';
175
176echo '<fieldset><legend>'.__('Inside posts links').'</legend>'.
177'<p class="field"><label for="post_link_w">'.__('Links in bold:').' '.
178form::checkbox('post_link_w',1,$ductile_user['post_link_w']).'</label>'.'</p>'.
179
180'<p class="field"><label for="post_link_v_c">'.__('Normal and visited links color:').'</label> '.
181form::field('post_link_v_c',7,7,$ductile_user['post_link_v_c'],'colorpicker').'</p>'.
182
183'<p class="field"><label for="body_link_f_c">'.__('Active, hover and focus links color:').'</label> '.
184form::field('post_link_f_c',7,7,$ductile_user['post_link_f_c'],'colorpicker').'</p>'.
185'</fieldset>';
186
187echo '<h3>'.__('Mobile specific settings').'</h3>';
188
189echo '<div class="two-cols">';
190echo '<div class="col">';
191
192echo '<fieldset><legend>'.__('Blog title').'</legend>'.
193'<p class="field"><label for="blog_title_w_m">'.__('Blog title in bold:').' '.
194form::checkbox('blog_title_w_m',1,$ductile_user['blog_title_w_m']).'</label>'.'</p>'.
195
196'<p class="field"><label for="blog_title_s_m">'.__('Blog title font size:').'</label> '.
197form::field('blog_title_s_m',7,7,$ductile_user['blog_title_s_m']).' '.__('(in em by default)').'</p>'.
198
199'<p class="field"><label for="blog_title_c_m">'.__('Blog title color:').'</label> '.
200form::field('blog_title_c_m',7,7,$ductile_user['blog_title_c_m'],'colorpicker').'</p>'.
201'</fieldset>';
202
203echo '</div>';
204echo '<div class="col">';
205
206echo '<fieldset><legend>'.__('Post title').'</legend>'.
207'<p class="field"><label for="post_title_w_m">'.__('Post title in bold:').' '.
208form::checkbox('post_title_w_m',1,$ductile_user['post_title_w_m']).'</label>'.'</p>'.
209
210'<p class="field"><label for="post_title_s_m">'.__('Post title font size:').'</label> '.
211form::field('post_title_s_m',7,7,$ductile_user['post_title_s_m']).' '.__('(in em by default)').'</p>'.
212
213'<p class="field"><label for="post_title_c_m">'.__('Post title color:').'</label> '.
214form::field('post_title_c_m',7,7,$ductile_user['post_title_c_m'],'colorpicker').'</p>'.
215'</fieldset>';
216
217echo '</div>';
218echo '</div>';
219
220?>
Note: See TracBrowser for help on using the repository browser.

Sites map