[345] | 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 ----------------------------------------- |
---|
| 12 | if (!defined('DC_CONTEXT_ADMIN')) { return; } |
---|
| 13 | |
---|
[357] | 14 | l10n::set(dirname(__FILE__).'/locales/'.$_lang.'/main'); |
---|
| 15 | |
---|
[376] | 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 | |
---|
[387] | 30 | function 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 | |
---|
[357] | 42 | function 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( |
---|
[376] | 66 | 'body_font' => null, |
---|
[387] | 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 |
---|
[357] | 83 | ); |
---|
| 84 | |
---|
| 85 | $ductile_user = $core->blog->settings->themes->ductile_style; |
---|
| 86 | $ductile_user = @unserialize($ductile_user); |
---|
| 87 | if (!is_array($ductile_user)) { |
---|
| 88 | $ductile_user = array(); |
---|
| 89 | } |
---|
| 90 | |
---|
| 91 | $ductile_user = array_merge($ductile_base,$ductile_user); |
---|
| 92 | |
---|
| 93 | if (!empty($_POST)) |
---|
| 94 | { |
---|
| 95 | try |
---|
| 96 | { |
---|
[376] | 97 | $ductile_user['body_font'] = $_POST['body_font']; |
---|
| 98 | $ductile_user['alternate_font'] = $_POST['alternate_font']; |
---|
[387] | 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']); |
---|
[376] | 119 | |
---|
[357] | 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 | |
---|
[387] | 135 | echo '<h3>'.__('General settings').'</h3>'; |
---|
| 136 | |
---|
[376] | 137 | echo '<fieldset><legend>'.__('Fonts').'</legend>'. |
---|
| 138 | '<p class="field"><label for="body_font">'.__('Main font:').' '. |
---|
| 139 | form::combo('body_font',$fonts,$ductile_user['body_font']).'</label></p>'. |
---|
| 140 | |
---|
[378] | 141 | '<p class="field"><label for="alternate_font">'.__('Secondary font:').' '. |
---|
[376] | 142 | form::combo('alternate_font',$fonts,$ductile_user['alternate_font']).'</label></p>'. |
---|
| 143 | '</fieldset>'; |
---|
| 144 | |
---|
[387] | 145 | echo '<div class="two-cols">'; |
---|
| 146 | echo '<div class="col">'; |
---|
| 147 | |
---|
| 148 | echo '<fieldset><legend>'.__('Blog title').'</legend>'. |
---|
| 149 | '<p class="field"><label for="blog_title_w">'.__('Blog title in bold:').' '. |
---|
| 150 | form::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> '. |
---|
| 153 | form::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> '. |
---|
| 156 | form::field('blog_title_c',7,7,$ductile_user['blog_title_c'],'colorpicker').'</p>'. |
---|
| 157 | '</fieldset>'; |
---|
| 158 | |
---|
| 159 | echo '</div>'; |
---|
| 160 | echo '<div class="col">'; |
---|
| 161 | |
---|
| 162 | echo '<fieldset><legend>'.__('Post title').'</legend>'. |
---|
| 163 | '<p class="field"><label for="post_title_w">'.__('Post title in bold:').' '. |
---|
| 164 | form::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> '. |
---|
| 167 | form::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> '. |
---|
| 170 | form::field('post_title_c',7,7,$ductile_user['post_title_c'],'colorpicker').'</p>'. |
---|
| 171 | '</fieldset>'; |
---|
| 172 | |
---|
| 173 | echo '</div>'; |
---|
| 174 | echo '</div>'; |
---|
| 175 | |
---|
[378] | 176 | echo '<fieldset><legend>'.__('Inside posts links').'</legend>'. |
---|
[387] | 177 | '<p class="field"><label for="post_link_w">'.__('Links in bold:').' '. |
---|
| 178 | form::checkbox('post_link_w',1,$ductile_user['post_link_w']).'</label>'.'</p>'. |
---|
[357] | 179 | |
---|
[387] | 180 | '<p class="field"><label for="post_link_v_c">'.__('Normal and visited links color:').'</label> '. |
---|
| 181 | form::field('post_link_v_c',7,7,$ductile_user['post_link_v_c'],'colorpicker').'</p>'. |
---|
[357] | 182 | |
---|
[378] | 183 | '<p class="field"><label for="body_link_f_c">'.__('Active, hover and focus links color:').'</label> '. |
---|
[387] | 184 | form::field('post_link_f_c',7,7,$ductile_user['post_link_f_c'],'colorpicker').'</p>'. |
---|
[357] | 185 | '</fieldset>'; |
---|
| 186 | |
---|
[387] | 187 | echo '<h3>'.__('Mobile specific settings').'</h3>'; |
---|
| 188 | |
---|
| 189 | echo '<div class="two-cols">'; |
---|
| 190 | echo '<div class="col">'; |
---|
| 191 | |
---|
| 192 | echo '<fieldset><legend>'.__('Blog title').'</legend>'. |
---|
| 193 | '<p class="field"><label for="blog_title_w_m">'.__('Blog title in bold:').' '. |
---|
| 194 | form::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> '. |
---|
| 197 | form::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> '. |
---|
| 200 | form::field('blog_title_c_m',7,7,$ductile_user['blog_title_c_m'],'colorpicker').'</p>'. |
---|
| 201 | '</fieldset>'; |
---|
| 202 | |
---|
| 203 | echo '</div>'; |
---|
| 204 | echo '<div class="col">'; |
---|
| 205 | |
---|
| 206 | echo '<fieldset><legend>'.__('Post title').'</legend>'. |
---|
| 207 | '<p class="field"><label for="post_title_w_m">'.__('Post title in bold:').' '. |
---|
| 208 | form::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> '. |
---|
| 211 | form::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> '. |
---|
| 214 | form::field('post_title_c_m',7,7,$ductile_user['post_title_c_m'],'colorpicker').'</p>'. |
---|
| 215 | '</fieldset>'; |
---|
| 216 | |
---|
| 217 | echo '</div>'; |
---|
| 218 | echo '</div>'; |
---|
| 219 | |
---|
[345] | 220 | ?> |
---|