| [345] | 1 | <?php |
|---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
|---|
| [631] | 3 | # This file is part of Ductile, a theme for Dotclear |
|---|
| [345] | 4 | # |
|---|
| [631] | 5 | # Copyright (c) 2011 - Association Dotclear |
|---|
| [345] | 6 | # Licensed under the GPL version 2.0 license. |
|---|
| 7 | # See LICENSE file or |
|---|
| 8 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
|---|
| 9 | # |
|---|
| 10 | # -- END LICENSE BLOCK ----------------------------------------- |
|---|
| 11 | if (!defined('DC_CONTEXT_ADMIN')) { return; } |
|---|
| 12 | |
|---|
| [421] | 13 | l10n::set(dirname(__FILE__).'/locales/'.$_lang.'/admin'); |
|---|
| [357] | 14 | |
|---|
| [604] | 15 | $img_url = $core->blog->settings->system->themes_url.'/'.$core->blog->settings->system->theme.'/img/'; |
|---|
| [627] | 16 | $img_url = http::concatURL($core->blog->url,$img_url); |
|---|
| [604] | 17 | $img_path = dirname(__FILE__).'/img/'; |
|---|
| 18 | |
|---|
| [657] | 19 | $tpl_path = dirname(__FILE__).'/tpl/'; |
|---|
| 20 | |
|---|
| [611] | 21 | $standalone_config = (boolean) $core->themes->moduleInfo($core->blog->settings->system->theme,'standalone_config'); |
|---|
| 22 | |
|---|
| [563] | 23 | $list_types = array( |
|---|
| 24 | __('Title') => 'title', |
|---|
| 25 | __('Short') => 'short', |
|---|
| 26 | __('Full') => 'full' |
|---|
| 27 | ); |
|---|
| [657] | 28 | // Get all _entry-*.html in tpl folder of theme |
|---|
| 29 | $list_types_templates = files::scandir($tpl_path); |
|---|
| 30 | if (is_array($list_types_templates)) { |
|---|
| 31 | foreach ($list_types_templates as $v) { |
|---|
| 32 | if (preg_match('/^_entry\-(.*)\.html$/',$v,$m)) { |
|---|
| 33 | if (isset($m[1])) { |
|---|
| 34 | if (!in_array($m[1],$list_types)) { |
|---|
| 35 | // template not already in full list |
|---|
| 36 | $list_types[__($m[1])] = $m[1]; |
|---|
| 37 | } |
|---|
| 38 | } |
|---|
| 39 | } |
|---|
| 40 | } |
|---|
| 41 | } |
|---|
| 42 | |
|---|
| 43 | |
|---|
| [563] | 44 | |
|---|
| 45 | $contexts = array( |
|---|
| 46 | 'default' => __('Home (first page)'), |
|---|
| 47 | 'default-page' => __('Home (other pages)'), |
|---|
| 48 | 'category' => __('Entries for a category'), |
|---|
| 49 | 'tag' => __('Entries for a tag'), |
|---|
| 50 | 'search' => __('Search result entries'), |
|---|
| [564] | 51 | 'archive' => __('Month archive entries') |
|---|
| [563] | 52 | ); |
|---|
| 53 | |
|---|
| [376] | 54 | $fonts = array( |
|---|
| 55 | __('default') => '', |
|---|
| 56 | __('Ductile primary') => 'Ductile body', |
|---|
| 57 | __('Ductile secondary') => 'Ductile alternate', |
|---|
| 58 | __('Times New Roman') => 'Times New Roman', |
|---|
| 59 | __('Georgia') => 'Georgia', |
|---|
| 60 | __('Garamond') => 'Garamond', |
|---|
| 61 | __('Helvetica/Arial') => 'Helvetica/Arial', |
|---|
| 62 | __('Verdana') => 'Verdana', |
|---|
| 63 | __('Trebuchet MS') => 'Trebuchet MS', |
|---|
| 64 | __('Impact') => 'Impact', |
|---|
| 65 | __('Monospace') => 'Monospace' |
|---|
| 66 | ); |
|---|
| 67 | |
|---|
| [387] | 68 | function adjustFontSize($s) |
|---|
| 69 | { |
|---|
| 70 | if (preg_match('/^([0-9.]+)\s*(%|pt|px|em|ex)?$/',$s,$m)) { |
|---|
| 71 | if (empty($m[2])) { |
|---|
| 72 | $m[2] = 'em'; |
|---|
| 73 | } |
|---|
| 74 | return $m[1].$m[2]; |
|---|
| 75 | } |
|---|
| 76 | |
|---|
| 77 | return null; |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| [656] | 80 | $font_families = array( |
|---|
| 81 | // Theme standard |
|---|
| 82 | 'Ductile body' => '"Century Schoolbook", "Century Schoolbook L", Georgia, serif', |
|---|
| 83 | 'Ductile alternate' => '"Franklin gothic medium", "arial narrow", "DejaVu Sans Condensed", "helvetica neue", helvetica, sans-serif', |
|---|
| 84 | |
|---|
| 85 | // Serif families |
|---|
| 86 | 'Times New Roman' => 'Cambria, "Hoefler Text", Utopia, "Liberation Serif", "Nimbus Roman No9 L Regular", Times, "Times New Roman", serif', |
|---|
| 87 | 'Georgia' => 'Constantia, "Lucida Bright", Lucidabright, "Lucida Serif", Lucida, "DejaVu Serif", "Bitstream Vera Serif", "Liberation Serif", Georgia, serif', |
|---|
| 88 | 'Garamond' => '"Palatino Linotype", Palatino, Palladio, "URW Palladio L", "Book Antiqua", Baskerville, "Bookman Old Style", "Bitstream Charter", "Nimbus Roman No9 L", Garamond, "Apple Garamond", "ITC Garamond Narrow", "New Century Schoolbook", "Century Schoolbook", "Century Schoolbook L", Georgia, serif', |
|---|
| 89 | |
|---|
| 90 | // Sans-serif families |
|---|
| 91 | 'Helvetica/Arial' => 'Frutiger, "Frutiger Linotype", Univers, Calibri, "Gill Sans", "Gill Sans MT", "Myriad Pro", Myriad, "DejaVu Sans Condensed", "Liberation Sans", "Nimbus Sans L", Tahoma, Geneva, "Helvetica Neue", Helvetica, Arial, sans-serif', |
|---|
| 92 | 'Verdana' => 'Corbel, "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", "Bitstream Vera Sans", "Liberation Sans", Verdana, "Verdana Ref", sans-serif', |
|---|
| 93 | 'Trebuchet MS' => '"Segoe UI", Candara, "Bitstream Vera Sans", "DejaVu Sans", "Bitstream Vera Sans", "Trebuchet MS", Verdana, "Verdana Ref", sans-serif', |
|---|
| 94 | |
|---|
| 95 | // Cursive families |
|---|
| 96 | 'Impact' => 'Impact, Haettenschweiler, "Franklin Gothic Bold", Charcoal, "Helvetica Inserat", "Bitstream Vera Sans Bold", "Arial Black", sans-serif', |
|---|
| 97 | |
|---|
| 98 | // Monospace families |
|---|
| 99 | 'Monospace' => 'Consolas, "Andale Mono WT", "Andale Mono", "Lucida Console", "Lucida Sans Typewriter", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Liberation Mono", "Nimbus Mono L", Monaco, "Courier New", Courier, monospace' |
|---|
| 100 | ); |
|---|
| 101 | |
|---|
| 102 | function fontDef($c) |
|---|
| 103 | { |
|---|
| 104 | global $font_families; |
|---|
| 105 | |
|---|
| 106 | return isset($font_families[$c]) ? '<span style="position:absolute;top:0;left:32em;">'.$font_families[$c].'</span>' : ''; |
|---|
| 107 | } |
|---|
| 108 | |
|---|
| [357] | 109 | function adjustColor($c) |
|---|
| 110 | { |
|---|
| 111 | if ($c === '') { |
|---|
| 112 | return ''; |
|---|
| 113 | } |
|---|
| 114 | |
|---|
| 115 | $c = strtoupper($c); |
|---|
| 116 | |
|---|
| 117 | if (preg_match('/^[A-F0-9]{3,6}$/',$c)) { |
|---|
| 118 | $c = '#'.$c; |
|---|
| 119 | } |
|---|
| 120 | |
|---|
| 121 | if (preg_match('/^#[A-F0-9]{6}$/',$c)) { |
|---|
| 122 | return $c; |
|---|
| 123 | } |
|---|
| 124 | |
|---|
| 125 | if (preg_match('/^#[A-F0-9]{3,}$/',$c)) { |
|---|
| 126 | 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); |
|---|
| 127 | } |
|---|
| 128 | |
|---|
| 129 | return ''; |
|---|
| 130 | } |
|---|
| 131 | |
|---|
| [653] | 132 | function computeContrastRatio($color,$background) |
|---|
| [649] | 133 | { |
|---|
| 134 | // Compute contrast ratio between two colors |
|---|
| 135 | |
|---|
| [653] | 136 | $color = adjustColor($color); |
|---|
| 137 | if (($color == '') || (strlen($color) != 7)) return 0; |
|---|
| 138 | $background = adjustColor($background); |
|---|
| 139 | if (($background == '') || (strlen($background) != 7)) return 0; |
|---|
| [649] | 140 | |
|---|
| [653] | 141 | $l1 = (0.2126 * pow(hexdec(substr($color,1,2))/255,2.2)) + |
|---|
| 142 | (0.7152 * pow(hexdec(substr($color,3,2))/255,2.2)) + |
|---|
| 143 | (0.0722 * pow(hexdec(substr($color,5,2))/255,2.2)); |
|---|
| 144 | |
|---|
| 145 | $l2 = (0.2126 * pow(hexdec(substr($background,1,2))/255,2.2)) + |
|---|
| 146 | (0.7152 * pow(hexdec(substr($background,3,2))/255,2.2)) + |
|---|
| 147 | (0.0722 * pow(hexdec(substr($background,5,2))/255,2.2)); |
|---|
| [649] | 148 | |
|---|
| 149 | if ($l1 > $l2) { |
|---|
| [653] | 150 | $ratio = ($l1 + 0.05) / ($l2 + 0.05); |
|---|
| [649] | 151 | } else { |
|---|
| [653] | 152 | $ratio = ($l2 + 0.05) / ($l1 + 0.05); |
|---|
| [649] | 153 | } |
|---|
| [653] | 154 | return $ratio; |
|---|
| [649] | 155 | } |
|---|
| 156 | |
|---|
| [653] | 157 | function contrastRatioLevel($ratio,$size,$bold) |
|---|
| 158 | { |
|---|
| 159 | if ($size == '') { |
|---|
| 160 | return ''; |
|---|
| 161 | } |
|---|
| 162 | |
|---|
| 163 | // Eval font size in em (assume base font size in pixels equal to 16) |
|---|
| 164 | if (preg_match('/^([0-9.]+)\s*(%|pt|px|em|ex)?$/',$size,$m)) { |
|---|
| 165 | if (empty($m[2])) { |
|---|
| 166 | $m[2] = 'em'; |
|---|
| 167 | } |
|---|
| 168 | } else { |
|---|
| 169 | return ''; |
|---|
| 170 | } |
|---|
| 171 | switch ($m[2]) { |
|---|
| 172 | case '%': |
|---|
| 173 | $s = (float) $m[1] / 100; |
|---|
| 174 | break; |
|---|
| 175 | case 'pt': |
|---|
| 176 | $s = (float) $m[1] / 12; |
|---|
| 177 | break; |
|---|
| 178 | case 'px': |
|---|
| 179 | $s = (float) $m[1] / 16; |
|---|
| 180 | break; |
|---|
| 181 | case 'em': |
|---|
| 182 | $s = (float) $m[1]; |
|---|
| 183 | break; |
|---|
| 184 | case 'ex': |
|---|
| 185 | $s = (float) $m[1] / 2; |
|---|
| 186 | break; |
|---|
| 187 | default: |
|---|
| 188 | return ''; |
|---|
| 189 | } |
|---|
| 190 | |
|---|
| 191 | $large = ((($s > 1.5) && ($bold == false)) || (($s > 1.2) && ($bold == true))); |
|---|
| 192 | |
|---|
| 193 | // Check ratio |
|---|
| 194 | if ($ratio > 7) { |
|---|
| 195 | return 'AAA'; |
|---|
| 196 | } elseif (($ratio > 4.5) && $large) { |
|---|
| 197 | return 'AAA'; |
|---|
| 198 | } elseif ($ratio > 4.5) { |
|---|
| 199 | return 'AA'; |
|---|
| 200 | } elseif (($ratio > 3) && $large) { |
|---|
| 201 | return 'AA'; |
|---|
| 202 | } |
|---|
| 203 | return ''; |
|---|
| 204 | } |
|---|
| 205 | |
|---|
| 206 | function contrastRatio($color,$background,$size='',$bold=false) |
|---|
| 207 | { |
|---|
| 208 | if (($color != '') && ($background != '')) { |
|---|
| 209 | $ratio = computeContrastRatio($color,$background); |
|---|
| 210 | $level = contrastRatioLevel($ratio,$size,$bold); |
|---|
| 211 | return |
|---|
| [655] | 212 | '<span style="position:absolute;top:0;left:23em;">'. |
|---|
| 213 | sprintf(__('ratio %.1f'),$ratio). |
|---|
| 214 | ($level != '' ? ' '.sprintf(__('(%s)'),$level) : ''). |
|---|
| 215 | '</span>'; |
|---|
| [649] | 216 | } |
|---|
| 217 | return ''; |
|---|
| 218 | } |
|---|
| 219 | |
|---|
| [357] | 220 | $ductile_base = array( |
|---|
| [389] | 221 | // HTML |
|---|
| 222 | 'subtitle_hidden' => null, |
|---|
| 223 | // CSS |
|---|
| [376] | 224 | 'body_font' => null, |
|---|
| [387] | 225 | 'alternate_font' => null, |
|---|
| 226 | 'blog_title_w' => null, |
|---|
| 227 | 'blog_title_s' => null, |
|---|
| 228 | 'blog_title_c' => null, |
|---|
| 229 | 'post_title_w' => null, |
|---|
| 230 | 'post_title_s' => null, |
|---|
| 231 | 'post_title_c' => null, |
|---|
| 232 | 'post_link_w' => null, |
|---|
| 233 | 'post_link_v_c' => null, |
|---|
| 234 | 'post_link_f_c' => null, |
|---|
| 235 | 'blog_title_w_m' => null, |
|---|
| 236 | 'blog_title_s_m' => null, |
|---|
| 237 | 'blog_title_c_m' => null, |
|---|
| 238 | 'post_title_w_m' => null, |
|---|
| 239 | 'post_title_s_m' => null, |
|---|
| [515] | 240 | 'post_title_c_m' => null, |
|---|
| 241 | 'post_simple_title_c' => null |
|---|
| [357] | 242 | ); |
|---|
| 243 | |
|---|
| [563] | 244 | $ductile_lists_base = array( |
|---|
| [646] | 245 | 'default' => 'short', |
|---|
| 246 | 'default-page' => 'short', |
|---|
| 247 | 'category' => 'short', |
|---|
| 248 | 'tag' => 'short', |
|---|
| 249 | 'search' => 'short', |
|---|
| [667] | 250 | 'archive' => 'short' |
|---|
| [563] | 251 | ); |
|---|
| 252 | |
|---|
| [583] | 253 | $ductile_counts_base = array( |
|---|
| 254 | 'default' => null, |
|---|
| 255 | 'category' => null, |
|---|
| 256 | 'tag' => null, |
|---|
| 257 | 'search' => null |
|---|
| 258 | ); |
|---|
| 259 | |
|---|
| [605] | 260 | $ductile_user = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_style'); |
|---|
| 261 | $ductile_user = @unserialize($ductile_user); |
|---|
| 262 | if (!is_array($ductile_user)) { |
|---|
| 263 | $ductile_user = array(); |
|---|
| 264 | } |
|---|
| 265 | $ductile_user = array_merge($ductile_base,$ductile_user); |
|---|
| 266 | |
|---|
| 267 | $ductile_lists = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_entries_lists'); |
|---|
| 268 | $ductile_lists = @unserialize($ductile_lists); |
|---|
| 269 | if (!is_array($ductile_lists)) { |
|---|
| 270 | $ductile_lists = $ductile_lists_base; |
|---|
| 271 | } |
|---|
| 272 | |
|---|
| 273 | $ductile_counts = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_entries_counts'); |
|---|
| 274 | $ductile_counts = @unserialize($ductile_counts); |
|---|
| 275 | if (!is_array($ductile_counts)) { |
|---|
| 276 | $ductile_counts = $ductile_counts_base; |
|---|
| 277 | } |
|---|
| 278 | |
|---|
| 279 | $ductile_stickers = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_stickers'); |
|---|
| 280 | $ductile_stickers = @unserialize($ductile_stickers); |
|---|
| 281 | |
|---|
| [614] | 282 | // If no stickers defined, add feed Atom one |
|---|
| 283 | if (!is_array($ductile_stickers)) { |
|---|
| 284 | $ductile_stickers = array(array( |
|---|
| 285 | 'label' => __('Subscribe'), |
|---|
| [773] | 286 | 'url' => $core->url->getURLFor('feed','atom'), |
|---|
| [614] | 287 | 'image' => 'sticker-feed.png' |
|---|
| 288 | )); |
|---|
| 289 | } |
|---|
| 290 | |
|---|
| [605] | 291 | $ductile_stickers_full = array(); |
|---|
| 292 | // Get all sticker images already used |
|---|
| 293 | if (is_array($ductile_stickers)) { |
|---|
| 294 | foreach ($ductile_stickers as $v) { |
|---|
| 295 | $ductile_stickers_full[] = $v['image']; |
|---|
| 296 | } |
|---|
| 297 | } |
|---|
| 298 | // Get all sticker-*.png in img folder of theme |
|---|
| 299 | $ductile_stickers_images = files::scandir($img_path); |
|---|
| 300 | if (is_array($ductile_stickers_images)) { |
|---|
| 301 | foreach ($ductile_stickers_images as $v) { |
|---|
| 302 | if (preg_match('/^sticker\-(.*)\.png$/',$v)) { |
|---|
| 303 | if (!in_array($v,$ductile_stickers_full)) { |
|---|
| 304 | // image not already used |
|---|
| 305 | $ductile_stickers[] = array( |
|---|
| 306 | 'label' => null, |
|---|
| 307 | 'url' => null, |
|---|
| 308 | 'image' => $v); |
|---|
| 309 | } |
|---|
| 310 | } |
|---|
| 311 | } |
|---|
| 312 | } |
|---|
| 313 | |
|---|
| [390] | 314 | $conf_tab = isset($_POST['conf_tab']) ? $_POST['conf_tab'] : 'html'; |
|---|
| 315 | |
|---|
| [357] | 316 | if (!empty($_POST)) |
|---|
| 317 | { |
|---|
| 318 | try |
|---|
| 319 | { |
|---|
| [389] | 320 | # HTML |
|---|
| [390] | 321 | if ($conf_tab == 'html') { |
|---|
| 322 | $ductile_user['subtitle_hidden'] = (integer) !empty($_POST['subtitle_hidden']); |
|---|
| [605] | 323 | |
|---|
| [604] | 324 | $ductile_stickers = array(); |
|---|
| [605] | 325 | for ($i = 0; $i < count($_POST['sticker_image']); $i++) { |
|---|
| 326 | $ductile_stickers[] = array( |
|---|
| 327 | 'label' => $_POST['sticker_label'][$i], |
|---|
| 328 | 'url' => $_POST['sticker_url'][$i], |
|---|
| 329 | 'image' => $_POST['sticker_image'][$i] |
|---|
| 330 | ); |
|---|
| 331 | } |
|---|
| 332 | |
|---|
| 333 | $order = array(); |
|---|
| 334 | if (empty($_POST['ds_order']) && !empty($_POST['order'])) { |
|---|
| 335 | $order = $_POST['order']; |
|---|
| 336 | asort($order); |
|---|
| 337 | $order = array_keys($order); |
|---|
| 338 | } |
|---|
| 339 | if (!empty($order)) { |
|---|
| 340 | $new_ductile_stickers = array(); |
|---|
| 341 | foreach ($order as $i => $k) { |
|---|
| 342 | $new_ductile_stickers[] = array( |
|---|
| 343 | 'label' => $ductile_stickers[$k]['label'], |
|---|
| 344 | 'url' => $ductile_stickers[$k]['url'], |
|---|
| 345 | 'image' => $ductile_stickers[$k]['image'] |
|---|
| [604] | 346 | ); |
|---|
| 347 | } |
|---|
| [605] | 348 | $ductile_stickers = $new_ductile_stickers; |
|---|
| [419] | 349 | } |
|---|
| [605] | 350 | |
|---|
| [563] | 351 | for ($i = 0; $i < count($_POST['list_type']); $i++) { |
|---|
| 352 | $ductile_lists[$_POST['list_ctx'][$i]] = $_POST['list_type'][$i]; |
|---|
| 353 | } |
|---|
| 354 | |
|---|
| [583] | 355 | for ($i = 0; $i < count($_POST['count_nb']); $i++) { |
|---|
| 356 | $ductile_counts[$_POST['count_ctx'][$i]] = $_POST['count_nb'][$i]; |
|---|
| 357 | } |
|---|
| 358 | |
|---|
| [390] | 359 | } |
|---|
| [389] | 360 | |
|---|
| 361 | # CSS |
|---|
| [390] | 362 | if ($conf_tab == 'css') { |
|---|
| 363 | $ductile_user['body_font'] = $_POST['body_font']; |
|---|
| 364 | $ductile_user['alternate_font'] = $_POST['alternate_font']; |
|---|
| 365 | |
|---|
| 366 | $ductile_user['blog_title_w'] = (integer) !empty($_POST['blog_title_w']); |
|---|
| 367 | $ductile_user['blog_title_s'] = adjustFontSize($_POST['blog_title_s']); |
|---|
| 368 | $ductile_user['blog_title_c'] = adjustColor($_POST['blog_title_c']); |
|---|
| [389] | 369 | |
|---|
| [390] | 370 | $ductile_user['post_title_w'] = (integer) !empty($_POST['post_title_w']); |
|---|
| 371 | $ductile_user['post_title_s'] = adjustFontSize($_POST['post_title_s']); |
|---|
| 372 | $ductile_user['post_title_c'] = adjustColor($_POST['post_title_c']); |
|---|
| [387] | 373 | |
|---|
| [390] | 374 | $ductile_user['post_link_w'] = (integer) !empty($_POST['post_link_w']); |
|---|
| 375 | $ductile_user['post_link_v_c'] = adjustColor($_POST['post_link_v_c']); |
|---|
| 376 | $ductile_user['post_link_f_c'] = adjustColor($_POST['post_link_f_c']); |
|---|
| [387] | 377 | |
|---|
| [515] | 378 | $ductile_user['post_simple_title_c'] = adjustColor($_POST['post_simple_title_c']); |
|---|
| 379 | |
|---|
| [390] | 380 | $ductile_user['blog_title_w_m'] = (integer) !empty($_POST['blog_title_w_m']); |
|---|
| 381 | $ductile_user['blog_title_s_m'] = adjustFontSize($_POST['blog_title_s_m']); |
|---|
| 382 | $ductile_user['blog_title_c_m'] = adjustColor($_POST['blog_title_c_m']); |
|---|
| [387] | 383 | |
|---|
| [390] | 384 | $ductile_user['post_title_w_m'] = (integer) !empty($_POST['post_title_w_m']); |
|---|
| 385 | $ductile_user['post_title_s_m'] = adjustFontSize($_POST['post_title_s_m']); |
|---|
| 386 | $ductile_user['post_title_c_m'] = adjustColor($_POST['post_title_c_m']); |
|---|
| 387 | } |
|---|
| [376] | 388 | |
|---|
| [357] | 389 | $core->blog->settings->addNamespace('themes'); |
|---|
| [394] | 390 | $core->blog->settings->themes->put($core->blog->settings->system->theme.'_style',serialize($ductile_user)); |
|---|
| [419] | 391 | $core->blog->settings->themes->put($core->blog->settings->system->theme.'_stickers',serialize($ductile_stickers)); |
|---|
| [563] | 392 | $core->blog->settings->themes->put($core->blog->settings->system->theme.'_entries_lists',serialize($ductile_lists)); |
|---|
| [583] | 393 | $core->blog->settings->themes->put($core->blog->settings->system->theme.'_entries_counts',serialize($ductile_counts)); |
|---|
| [572] | 394 | |
|---|
| 395 | // Blog refresh |
|---|
| [357] | 396 | $core->blog->triggerBlog(); |
|---|
| 397 | |
|---|
| [572] | 398 | // Template cache reset |
|---|
| 399 | $core->emptyTemplatesCache(); |
|---|
| 400 | |
|---|
| [357] | 401 | echo |
|---|
| 402 | '<div class="message"><p>'. |
|---|
| [389] | 403 | __('Theme configuration upgraded.'). |
|---|
| [357] | 404 | '</p></div>'; |
|---|
| 405 | } |
|---|
| 406 | catch (Exception $e) |
|---|
| 407 | { |
|---|
| 408 | $core->error->add($e->getMessage()); |
|---|
| 409 | } |
|---|
| 410 | } |
|---|
| 411 | |
|---|
| [613] | 412 | // Legacy mode |
|---|
| 413 | if (!$standalone_config) echo '</form>'; |
|---|
| 414 | |
|---|
| [389] | 415 | # HTML Tab |
|---|
| 416 | |
|---|
| [390] | 417 | echo '<div class="multi-part" id="themes-list'.($conf_tab == 'html' ? '' : '-html').'" title="'.__('Content').'">'; |
|---|
| 418 | |
|---|
| 419 | echo '<form id="theme_config" action="blog_theme.php?conf=1" method="post" enctype="multipart/form-data">'; |
|---|
| [389] | 420 | |
|---|
| 421 | echo '<fieldset><legend>'.__('Header').'</legend>'. |
|---|
| 422 | '<p class="field"><label for="subtitle_hidden">'.__('Hide blog description:').' '. |
|---|
| [612] | 423 | form::checkbox('subtitle_hidden',1,$ductile_user['subtitle_hidden']).'</label>'.'</p>'; |
|---|
| 424 | if ($core->plugins->moduleExists('simpleMenu')) |
|---|
| 425 | { |
|---|
| 426 | echo '<p>'.sprintf(__('To configure the top menu go to the <a href="%s">Simple Menu administration page</a>.'),'plugin.php?p=simpleMenu').'</p>'; |
|---|
| 427 | } |
|---|
| 428 | echo '</fieldset>'; |
|---|
| [389] | 429 | |
|---|
| [425] | 430 | echo '<fieldset><legend>'.__('Stickers').'</legend>'; |
|---|
| [419] | 431 | |
|---|
| [605] | 432 | echo '<table class="dragable">'.'<caption>'.__('Stickers (footer)').'</caption>'. |
|---|
| [419] | 433 | '<thead>'. |
|---|
| 434 | '<tr>'. |
|---|
| [605] | 435 | '<th scope="col">'.'</th>'. |
|---|
| [604] | 436 | '<th scope="col">'.__('Image').'</th>'. |
|---|
| [419] | 437 | '<th scope="col">'.__('Label').'</th>'. |
|---|
| 438 | '<th scope="col">'.__('URL').'</th>'. |
|---|
| 439 | '</tr>'. |
|---|
| 440 | '</thead>'. |
|---|
| [605] | 441 | '<tbody id="stickerslist">'; |
|---|
| 442 | $count = 0; |
|---|
| 443 | foreach ($ductile_stickers as $i => $v) { |
|---|
| 444 | $count++; |
|---|
| [604] | 445 | echo |
|---|
| [605] | 446 | '<tr class="line" id="l_'.$i.'">'. |
|---|
| 447 | '<td class="handle minimal">'.form::field(array('order['.$i.']'),2,3,$count,'position','',false). |
|---|
| 448 | form::hidden(array('dynorder[]','dynorder-'.$i),$i).'</td>'. |
|---|
| 449 | '<td>'.form::hidden(array('sticker_image[]'),$v['image']).'<img src="'.$img_url.$v['image'].'" /> '.'</td>'. |
|---|
| 450 | '<td scope="raw">'.form::field(array('sticker_label[]','dsl-'.$i),20,255,$v['label']).'</td>'. |
|---|
| 451 | '<td>'.form::field(array('sticker_url[]','dsu-'.$i),40,255,$v['url']).'</td>'. |
|---|
| [604] | 452 | '</tr>'; |
|---|
| 453 | } |
|---|
| 454 | echo |
|---|
| [419] | 455 | '</tbody>'. |
|---|
| 456 | '</table>'; |
|---|
| 457 | |
|---|
| [425] | 458 | echo '</fieldset>'; |
|---|
| [419] | 459 | |
|---|
| [583] | 460 | echo '<fieldset><legend>'.__('Entries list types and limits').'</legend>'; |
|---|
| [563] | 461 | |
|---|
| 462 | echo '<table id="entrieslist">'.'<caption>'.__('Entries lists').'</caption>'. |
|---|
| 463 | '<thead>'. |
|---|
| 464 | '<tr>'. |
|---|
| 465 | '<th scope="col">'.__('Context').'</th>'. |
|---|
| 466 | '<th scope="col">'.__('Entries list type').'</th>'. |
|---|
| [583] | 467 | '<th scope="col">'.__('Number of entries').'</th>'. |
|---|
| [563] | 468 | '</tr>'. |
|---|
| 469 | '</thead>'. |
|---|
| 470 | '<tbody>'; |
|---|
| 471 | foreach ($ductile_lists as $k => $v) { |
|---|
| 472 | echo |
|---|
| 473 | '<tr>'. |
|---|
| 474 | '<td scope="raw">'.$contexts[$k].'</td>'. |
|---|
| [583] | 475 | '<td>'.form::hidden(array('list_ctx[]'),$k).form::combo(array('list_type[]'),$list_types,$v).'</td>'; |
|---|
| 476 | if (array_key_exists($k,$ductile_counts)) { |
|---|
| 477 | echo '<td>'.form::hidden(array('count_ctx[]'),$k).form::field(array('count_nb[]'),2,3,$ductile_counts[$k]).'</td>'; |
|---|
| 478 | } else { |
|---|
| 479 | echo '<td></td>'; |
|---|
| 480 | } |
|---|
| 481 | echo |
|---|
| [563] | 482 | '</tr>'; |
|---|
| 483 | } |
|---|
| 484 | echo |
|---|
| 485 | '</tbody>'. |
|---|
| 486 | '</table>'; |
|---|
| 487 | |
|---|
| 488 | echo '</fieldset>'; |
|---|
| 489 | |
|---|
| [390] | 490 | echo '<input type="hidden" name="conf_tab" value="html">'; |
|---|
| [605] | 491 | echo '<p class="clear">'.form::hidden('ds_order','').'<input type="submit" value="'.__('Save').'" />'.$core->formNonce().'</p>'; |
|---|
| [390] | 492 | echo '</form>'; |
|---|
| 493 | |
|---|
| [389] | 494 | echo '</div>'; // Close tab |
|---|
| 495 | |
|---|
| 496 | # CSS tab |
|---|
| 497 | |
|---|
| [390] | 498 | echo '<div class="multi-part" id="themes-list'.($conf_tab == 'css' ? '' : '-css').'" title="'.__('Presentation').'">'; |
|---|
| 499 | |
|---|
| 500 | echo '<form id="theme_config" action="blog_theme.php?conf=1" method="post" enctype="multipart/form-data">'; |
|---|
| [389] | 501 | |
|---|
| [387] | 502 | echo '<h3>'.__('General settings').'</h3>'; |
|---|
| 503 | |
|---|
| [376] | 504 | echo '<fieldset><legend>'.__('Fonts').'</legend>'. |
|---|
| [388] | 505 | '<p class="field"><label for="body_font">'.__('Main:').' '. |
|---|
| [656] | 506 | form::combo('body_font',$fonts,$ductile_user['body_font']).'</label>'. |
|---|
| 507 | (!empty($ductile_user['body_font']) ? ' '.fontDef($ductile_user['body_font']) : ''). |
|---|
| 508 | '</p>'. |
|---|
| [376] | 509 | |
|---|
| [388] | 510 | '<p class="field"><label for="alternate_font">'.__('Secondary:').' '. |
|---|
| [656] | 511 | form::combo('alternate_font',$fonts,$ductile_user['alternate_font']).'</label>'. |
|---|
| 512 | (!empty($ductile_user['alternate_font']) ? ' '.fontDef($ductile_user['alternate_font']) : ''). |
|---|
| 513 | '</p>'. |
|---|
| [376] | 514 | '</fieldset>'; |
|---|
| 515 | |
|---|
| [387] | 516 | echo '<div class="two-cols">'; |
|---|
| 517 | echo '<div class="col">'; |
|---|
| 518 | |
|---|
| 519 | echo '<fieldset><legend>'.__('Blog title').'</legend>'. |
|---|
| [388] | 520 | '<p class="field"><label for="blog_title_w">'.__('In bold:').' '. |
|---|
| [387] | 521 | form::checkbox('blog_title_w',1,$ductile_user['blog_title_w']).'</label>'.'</p>'. |
|---|
| 522 | |
|---|
| [395] | 523 | '<p class="field"><label for="blog_title_s">'.__('Font size (in em by default):').'</label> '. |
|---|
| 524 | form::field('blog_title_s',7,7,$ductile_user['blog_title_s']).'</p>'. |
|---|
| [387] | 525 | |
|---|
| [389] | 526 | '<p class="field picker"><label for="blog_title_c">'.__('Color:').'</label> '. |
|---|
| [653] | 527 | form::field('blog_title_c',7,7,$ductile_user['blog_title_c'],'colorpicker'). |
|---|
| 528 | contrastRatio($ductile_user['blog_title_c'],'#ffffff', |
|---|
| 529 | (!empty($ductile_user['blog_title_s']) ? $ductile_user['blog_title_s'] : '2em'), |
|---|
| 530 | $ductile_user['blog_title_w']). |
|---|
| 531 | '</p>'. |
|---|
| [387] | 532 | '</fieldset>'; |
|---|
| 533 | |
|---|
| 534 | echo '</div>'; |
|---|
| 535 | echo '<div class="col">'; |
|---|
| 536 | |
|---|
| 537 | echo '<fieldset><legend>'.__('Post title').'</legend>'. |
|---|
| [388] | 538 | '<p class="field"><label for="post_title_w">'.__('In bold:').' '. |
|---|
| [387] | 539 | form::checkbox('post_title_w',1,$ductile_user['post_title_w']).'</label>'.'</p>'. |
|---|
| 540 | |
|---|
| [395] | 541 | '<p class="field"><label for="post_title_s">'.__('Font size (in em by default):').'</label> '. |
|---|
| 542 | form::field('post_title_s',7,7,$ductile_user['post_title_s']).'</p>'. |
|---|
| [387] | 543 | |
|---|
| [389] | 544 | '<p class="field picker"><label for="post_title_c">'.__('Color:').'</label> '. |
|---|
| [653] | 545 | form::field('post_title_c',7,7,$ductile_user['post_title_c'],'colorpicker'). |
|---|
| 546 | contrastRatio($ductile_user['post_title_c'],'#ffffff', |
|---|
| 547 | (!empty($ductile_user['post_title_s']) ? $ductile_user['post_title_s'] : '2.5em'), |
|---|
| 548 | $ductile_user['post_title_w']). |
|---|
| 549 | '</p>'. |
|---|
| [387] | 550 | '</fieldset>'; |
|---|
| 551 | |
|---|
| 552 | echo '</div>'; |
|---|
| 553 | echo '</div>'; |
|---|
| 554 | |
|---|
| [515] | 555 | echo '<fieldset><legend>'.__('Titles without link').'</legend>'. |
|---|
| 556 | |
|---|
| 557 | '<p class="field picker"><label for="post_simple_title_c">'.__('Color:').'</label> '. |
|---|
| [653] | 558 | form::field('post_simple_title_c',7,7,$ductile_user['post_simple_title_c'],'colorpicker'). |
|---|
| 559 | contrastRatio($ductile_user['post_simple_title_c'],'#ffffff', |
|---|
| 560 | '1.1em', // H5 minimum size |
|---|
| 561 | false). |
|---|
| 562 | '</p>'. |
|---|
| [515] | 563 | '</fieldset>'; |
|---|
| 564 | |
|---|
| [378] | 565 | echo '<fieldset><legend>'.__('Inside posts links').'</legend>'. |
|---|
| [388] | 566 | '<p class="field"><label for="post_link_w">'.__('In bold:').' '. |
|---|
| [387] | 567 | form::checkbox('post_link_w',1,$ductile_user['post_link_w']).'</label>'.'</p>'. |
|---|
| [357] | 568 | |
|---|
| [389] | 569 | '<p class="field picker"><label for="post_link_v_c">'.__('Normal and visited links color:').'</label> '. |
|---|
| [653] | 570 | form::field('post_link_v_c',7,7,$ductile_user['post_link_v_c'],'colorpicker'). |
|---|
| 571 | contrastRatio($ductile_user['post_link_v_c'],'#ffffff', |
|---|
| 572 | '1em', |
|---|
| 573 | $ductile_user['post_link_w']). |
|---|
| 574 | '</p>'. |
|---|
| [357] | 575 | |
|---|
| [648] | 576 | '<p class="field picker"><label for="post_link_f_c">'.__('Active, hover and focus links color:').'</label> '. |
|---|
| [653] | 577 | form::field('post_link_f_c',7,7,$ductile_user['post_link_f_c'],'colorpicker'). |
|---|
| 578 | contrastRatio($ductile_user['post_link_f_c'],'#ebebee', |
|---|
| 579 | '1em', |
|---|
| 580 | $ductile_user['post_link_w']). |
|---|
| 581 | '</p>'. |
|---|
| [357] | 582 | '</fieldset>'; |
|---|
| 583 | |
|---|
| [387] | 584 | echo '<h3>'.__('Mobile specific settings').'</h3>'; |
|---|
| 585 | |
|---|
| 586 | echo '<div class="two-cols">'; |
|---|
| 587 | echo '<div class="col">'; |
|---|
| 588 | |
|---|
| 589 | echo '<fieldset><legend>'.__('Blog title').'</legend>'. |
|---|
| [388] | 590 | '<p class="field"><label for="blog_title_w_m">'.__('In bold:').' '. |
|---|
| [387] | 591 | form::checkbox('blog_title_w_m',1,$ductile_user['blog_title_w_m']).'</label>'.'</p>'. |
|---|
| 592 | |
|---|
| [395] | 593 | '<p class="field"><label for="blog_title_s_m">'.__('Font size (in em by default):').'</label> '. |
|---|
| 594 | form::field('blog_title_s_m',7,7,$ductile_user['blog_title_s_m']).'</p>'. |
|---|
| [387] | 595 | |
|---|
| [389] | 596 | '<p class="field picker"><label for="blog_title_c_m">'.__('Color:').'</label> '. |
|---|
| [653] | 597 | form::field('blog_title_c_m',7,7,$ductile_user['blog_title_c_m'],'colorpicker'). |
|---|
| 598 | contrastRatio($ductile_user['blog_title_c_m'],'#d7d7dc', |
|---|
| 599 | (!empty($ductile_user['blog_title_s_m']) ? $ductile_user['blog_title_s_m'] : '1.8em'), |
|---|
| 600 | $ductile_user['blog_title_w_m']). |
|---|
| 601 | '</p>'. |
|---|
| [387] | 602 | '</fieldset>'; |
|---|
| 603 | |
|---|
| 604 | echo '</div>'; |
|---|
| 605 | echo '<div class="col">'; |
|---|
| 606 | |
|---|
| 607 | echo '<fieldset><legend>'.__('Post title').'</legend>'. |
|---|
| [388] | 608 | '<p class="field"><label for="post_title_w_m">'.__('In bold:').' '. |
|---|
| [387] | 609 | form::checkbox('post_title_w_m',1,$ductile_user['post_title_w_m']).'</label>'.'</p>'. |
|---|
| 610 | |
|---|
| [395] | 611 | '<p class="field"><label for="post_title_s_m">'.__('Font size (in em by default):').'</label> '. |
|---|
| 612 | form::field('post_title_s_m',7,7,$ductile_user['post_title_s_m']).'</p>'. |
|---|
| [387] | 613 | |
|---|
| [389] | 614 | '<p class="field picker"><label for="post_title_c_m">'.__('Color:').'</label> '. |
|---|
| [653] | 615 | form::field('post_title_c_m',7,7,$ductile_user['post_title_c_m'],'colorpicker'). |
|---|
| 616 | contrastRatio($ductile_user['post_title_c_m'],'#ffffff', |
|---|
| 617 | (!empty($ductile_user['post_title_s_m']) ? $ductile_user['post_title_s_m'] : '1.5em'), |
|---|
| 618 | $ductile_user['post_title_w_m']). |
|---|
| 619 | '</p>'. |
|---|
| [387] | 620 | '</fieldset>'; |
|---|
| 621 | |
|---|
| 622 | echo '</div>'; |
|---|
| 623 | echo '</div>'; |
|---|
| 624 | |
|---|
| [390] | 625 | echo '<input type="hidden" name="conf_tab" value="css">'; |
|---|
| 626 | echo '<p class="clear"><input type="submit" value="'.__('Save').'" />'.$core->formNonce().'</p>'; |
|---|
| 627 | echo '</form>'; |
|---|
| 628 | |
|---|
| [389] | 629 | echo '</div>'; // Close tab |
|---|
| 630 | |
|---|
| [634] | 631 | dcPage::helpBlock('ductile'); |
|---|
| 632 | |
|---|
| [613] | 633 | // Legacy mode |
|---|
| 634 | if (!$standalone_config) echo '<form style="display:none">'; |
|---|
| [622] | 635 | ?> |
|---|