| [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( | 
|---|
| [389] | 66 |      // HTML | 
|---|
 | 67 |      'subtitle_hidden' => null, | 
|---|
 | 68 |      // CSS | 
|---|
| [376] | 69 |      'body_font' => null, | 
|---|
| [387] | 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 | 
|---|
| [357] | 86 | ); | 
|---|
 | 87 |  | 
|---|
 | 88 | $ductile_user = $core->blog->settings->themes->ductile_style; | 
|---|
 | 89 | $ductile_user = @unserialize($ductile_user); | 
|---|
 | 90 | if (!is_array($ductile_user)) { | 
|---|
 | 91 |      $ductile_user = array(); | 
|---|
 | 92 | } | 
|---|
 | 93 |  | 
|---|
 | 94 | $ductile_user = array_merge($ductile_base,$ductile_user); | 
|---|
 | 95 |  | 
|---|
| [390] | 96 | $conf_tab = isset($_POST['conf_tab']) ? $_POST['conf_tab'] : 'html'; | 
|---|
 | 97 |  | 
|---|
| [357] | 98 | if (!empty($_POST)) | 
|---|
 | 99 | { | 
|---|
 | 100 |      try | 
|---|
 | 101 |      { | 
|---|
| [389] | 102 |           # HTML | 
|---|
| [390] | 103 |           if ($conf_tab == 'html') { | 
|---|
 | 104 |                $ductile_user['subtitle_hidden'] = (integer) !empty($_POST['subtitle_hidden']); | 
|---|
 | 105 |           } | 
|---|
| [389] | 106 |            | 
|---|
 | 107 |           # CSS | 
|---|
| [390] | 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']); | 
|---|
| [389] | 115 |            | 
|---|
| [390] | 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']); | 
|---|
| [387] | 119 |            | 
|---|
| [390] | 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']); | 
|---|
| [387] | 123 |            | 
|---|
| [390] | 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']); | 
|---|
| [387] | 127 |            | 
|---|
| [390] | 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 |           } | 
|---|
| [376] | 132 |            | 
|---|
| [357] | 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>'. | 
|---|
| [389] | 139 |           __('Theme configuration upgraded.'). | 
|---|
| [357] | 140 |           '</p></div>'; | 
|---|
 | 141 |      } | 
|---|
 | 142 |      catch (Exception $e) | 
|---|
 | 143 |      { | 
|---|
 | 144 |           $core->error->add($e->getMessage()); | 
|---|
 | 145 |      } | 
|---|
 | 146 | } | 
|---|
 | 147 |  | 
|---|
| [390] | 148 | echo '</form>'; | 
|---|
 | 149 |  | 
|---|
| [389] | 150 | # HTML Tab | 
|---|
 | 151 |  | 
|---|
| [390] | 152 | echo '<div class="multi-part" id="themes-list'.($conf_tab == 'html' ? '' : '-html').'" title="'.__('Content').'">'; | 
|---|
 | 153 |  | 
|---|
 | 154 | echo '<form id="theme_config" action="blog_theme.php?conf=1" method="post" enctype="multipart/form-data">'; | 
|---|
| [389] | 155 |  | 
|---|
 | 156 | echo '<fieldset><legend>'.__('Header').'</legend>'. | 
|---|
 | 157 | '<p class="field"><label for="subtitle_hidden">'.__('Hide blog description:').' '. | 
|---|
 | 158 | form::checkbox('subtitle_hidden',1,$ductile_user['subtitle_hidden']).'</label>'.'</p>'. | 
|---|
 | 159 | '</fieldset>'; | 
|---|
 | 160 |  | 
|---|
| [390] | 161 | echo '<input type="hidden" name="conf_tab" value="html">'; | 
|---|
 | 162 | echo '<p class="clear"><input type="submit" value="'.__('Save').'" />'.$core->formNonce().'</p>'; | 
|---|
 | 163 | echo '</form>'; | 
|---|
 | 164 |  | 
|---|
| [389] | 165 | echo '</div>'; // Close tab | 
|---|
 | 166 |  | 
|---|
 | 167 | # CSS tab | 
|---|
 | 168 |  | 
|---|
| [390] | 169 | echo '<div class="multi-part" id="themes-list'.($conf_tab == 'css' ? '' : '-css').'" title="'.__('Presentation').'">'; | 
|---|
 | 170 |  | 
|---|
 | 171 | echo '<form id="theme_config" action="blog_theme.php?conf=1" method="post" enctype="multipart/form-data">'; | 
|---|
| [389] | 172 |  | 
|---|
| [387] | 173 | echo '<h3>'.__('General settings').'</h3>'; | 
|---|
 | 174 |  | 
|---|
| [376] | 175 | echo '<fieldset><legend>'.__('Fonts').'</legend>'. | 
|---|
| [388] | 176 | '<p class="field"><label for="body_font">'.__('Main:').' '. | 
|---|
| [376] | 177 | form::combo('body_font',$fonts,$ductile_user['body_font']).'</label></p>'. | 
|---|
 | 178 |  | 
|---|
| [388] | 179 | '<p class="field"><label for="alternate_font">'.__('Secondary:').' '. | 
|---|
| [376] | 180 | form::combo('alternate_font',$fonts,$ductile_user['alternate_font']).'</label></p>'. | 
|---|
 | 181 | '</fieldset>'; | 
|---|
 | 182 |  | 
|---|
| [387] | 183 | echo '<div class="two-cols">'; | 
|---|
 | 184 | echo '<div class="col">'; | 
|---|
 | 185 |  | 
|---|
 | 186 | echo '<fieldset><legend>'.__('Blog title').'</legend>'. | 
|---|
| [388] | 187 | '<p class="field"><label for="blog_title_w">'.__('In bold:').' '. | 
|---|
| [387] | 188 | form::checkbox('blog_title_w',1,$ductile_user['blog_title_w']).'</label>'.'</p>'. | 
|---|
 | 189 |  | 
|---|
| [388] | 190 | '<p class="field"><label for="blog_title_s">'.__('Font size:').'</label> '. | 
|---|
| [387] | 191 | form::field('blog_title_s',7,7,$ductile_user['blog_title_s']).' '.__('(in em by default)').'</p>'. | 
|---|
 | 192 |  | 
|---|
| [389] | 193 | '<p class="field picker"><label for="blog_title_c">'.__('Color:').'</label> '. | 
|---|
| [387] | 194 | form::field('blog_title_c',7,7,$ductile_user['blog_title_c'],'colorpicker').'</p>'. | 
|---|
 | 195 | '</fieldset>'; | 
|---|
 | 196 |  | 
|---|
 | 197 | echo '</div>'; | 
|---|
 | 198 | echo '<div class="col">'; | 
|---|
 | 199 |  | 
|---|
 | 200 | echo '<fieldset><legend>'.__('Post title').'</legend>'. | 
|---|
| [388] | 201 | '<p class="field"><label for="post_title_w">'.__('In bold:').' '. | 
|---|
| [387] | 202 | form::checkbox('post_title_w',1,$ductile_user['post_title_w']).'</label>'.'</p>'. | 
|---|
 | 203 |  | 
|---|
| [388] | 204 | '<p class="field"><label for="post_title_s">'.__('Font size:').'</label> '. | 
|---|
| [387] | 205 | form::field('post_title_s',7,7,$ductile_user['post_title_s']).' '.__('(in em by default)').'</p>'. | 
|---|
 | 206 |  | 
|---|
| [389] | 207 | '<p class="field picker"><label for="post_title_c">'.__('Color:').'</label> '. | 
|---|
| [387] | 208 | form::field('post_title_c',7,7,$ductile_user['post_title_c'],'colorpicker').'</p>'. | 
|---|
 | 209 | '</fieldset>'; | 
|---|
 | 210 |  | 
|---|
 | 211 | echo '</div>'; | 
|---|
 | 212 | echo '</div>'; | 
|---|
 | 213 |  | 
|---|
| [378] | 214 | echo '<fieldset><legend>'.__('Inside posts links').'</legend>'. | 
|---|
| [388] | 215 | '<p class="field"><label for="post_link_w">'.__('In bold:').' '. | 
|---|
| [387] | 216 | form::checkbox('post_link_w',1,$ductile_user['post_link_w']).'</label>'.'</p>'. | 
|---|
| [357] | 217 |  | 
|---|
| [389] | 218 | '<p class="field picker"><label for="post_link_v_c">'.__('Normal and visited links color:').'</label> '. | 
|---|
| [387] | 219 | form::field('post_link_v_c',7,7,$ductile_user['post_link_v_c'],'colorpicker').'</p>'. | 
|---|
| [357] | 220 |  | 
|---|
| [389] | 221 | '<p class="field picker"><label for="body_link_f_c">'.__('Active, hover and focus links color:').'</label> '. | 
|---|
| [387] | 222 | form::field('post_link_f_c',7,7,$ductile_user['post_link_f_c'],'colorpicker').'</p>'. | 
|---|
| [357] | 223 | '</fieldset>'; | 
|---|
 | 224 |  | 
|---|
| [387] | 225 | echo '<h3>'.__('Mobile specific settings').'</h3>'; | 
|---|
 | 226 |  | 
|---|
 | 227 | echo '<div class="two-cols">'; | 
|---|
 | 228 | echo '<div class="col">'; | 
|---|
 | 229 |  | 
|---|
 | 230 | echo '<fieldset><legend>'.__('Blog title').'</legend>'. | 
|---|
| [388] | 231 | '<p class="field"><label for="blog_title_w_m">'.__('In bold:').' '. | 
|---|
| [387] | 232 | form::checkbox('blog_title_w_m',1,$ductile_user['blog_title_w_m']).'</label>'.'</p>'. | 
|---|
 | 233 |  | 
|---|
| [388] | 234 | '<p class="field"><label for="blog_title_s_m">'.__('Font size:').'</label> '. | 
|---|
| [387] | 235 | form::field('blog_title_s_m',7,7,$ductile_user['blog_title_s_m']).' '.__('(in em by default)').'</p>'. | 
|---|
 | 236 |  | 
|---|
| [389] | 237 | '<p class="field picker"><label for="blog_title_c_m">'.__('Color:').'</label> '. | 
|---|
| [387] | 238 | form::field('blog_title_c_m',7,7,$ductile_user['blog_title_c_m'],'colorpicker').'</p>'. | 
|---|
 | 239 | '</fieldset>'; | 
|---|
 | 240 |  | 
|---|
 | 241 | echo '</div>'; | 
|---|
 | 242 | echo '<div class="col">'; | 
|---|
 | 243 |  | 
|---|
 | 244 | echo '<fieldset><legend>'.__('Post title').'</legend>'. | 
|---|
| [388] | 245 | '<p class="field"><label for="post_title_w_m">'.__('In bold:').' '. | 
|---|
| [387] | 246 | form::checkbox('post_title_w_m',1,$ductile_user['post_title_w_m']).'</label>'.'</p>'. | 
|---|
 | 247 |  | 
|---|
| [388] | 248 | '<p class="field"><label for="post_title_s_m">'.__('Font size:').'</label> '. | 
|---|
| [387] | 249 | form::field('post_title_s_m',7,7,$ductile_user['post_title_s_m']).' '.__('(in em by default)').'</p>'. | 
|---|
 | 250 |  | 
|---|
| [389] | 251 | '<p class="field picker"><label for="post_title_c_m">'.__('Color:').'</label> '. | 
|---|
| [387] | 252 | form::field('post_title_c_m',7,7,$ductile_user['post_title_c_m'],'colorpicker').'</p>'. | 
|---|
 | 253 | '</fieldset>'; | 
|---|
 | 254 |  | 
|---|
 | 255 | echo '</div>'; | 
|---|
 | 256 | echo '</div>'; | 
|---|
 | 257 |  | 
|---|
| [390] | 258 | echo '<input type="hidden" name="conf_tab" value="css">'; | 
|---|
 | 259 | echo '<p class="clear"><input type="submit" value="'.__('Save').'" />'.$core->formNonce().'</p>'; | 
|---|
 | 260 | echo '</form>'; | 
|---|
 | 261 |  | 
|---|
| [389] | 262 | echo '</div>'; // Close tab | 
|---|
 | 263 |  | 
|---|
| [390] | 264 | echo '<form style="display:none">'; | 
|---|
 | 265 |  | 
|---|
| [345] | 266 | ?> | 
|---|