| 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 | |
|---|
| 14 | l10n::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 | |
|---|
| 30 | function adjustColor($c) |
|---|
| 31 | { |
|---|
| 32 | if ($c === '') { |
|---|
| 33 | return ''; |
|---|
| 34 | } |
|---|
| 35 | |
|---|
| 36 | $c = strtoupper($c); |
|---|
| 37 | |
|---|
| 38 | if (preg_match('/^[A-F0-9]{3,6}$/',$c)) { |
|---|
| 39 | $c = '#'.$c; |
|---|
| 40 | } |
|---|
| 41 | |
|---|
| 42 | if (preg_match('/^#[A-F0-9]{6}$/',$c)) { |
|---|
| 43 | return $c; |
|---|
| 44 | } |
|---|
| 45 | |
|---|
| 46 | if (preg_match('/^#[A-F0-9]{3,}$/',$c)) { |
|---|
| 47 | 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); |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | return ''; |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | $ductile_base = array( |
|---|
| 54 | 'body_link_c' => null, |
|---|
| 55 | 'body_link_v_c' => null, |
|---|
| 56 | 'body_link_f_c' => null, |
|---|
| 57 | 'body_font' => null, |
|---|
| 58 | 'alternate_font' => null |
|---|
| 59 | ); |
|---|
| 60 | |
|---|
| 61 | $ductile_user = $core->blog->settings->themes->ductile_style; |
|---|
| 62 | $ductile_user = @unserialize($ductile_user); |
|---|
| 63 | if (!is_array($ductile_user)) { |
|---|
| 64 | $ductile_user = array(); |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | $ductile_user = array_merge($ductile_base,$ductile_user); |
|---|
| 68 | |
|---|
| 69 | if (!empty($_POST)) |
|---|
| 70 | { |
|---|
| 71 | try |
|---|
| 72 | { |
|---|
| 73 | $ductile_user['body_link_c'] = adjustColor($_POST['body_link_c']); |
|---|
| 74 | $ductile_user['body_link_f_c'] = adjustColor($_POST['body_link_f_c']); |
|---|
| 75 | $ductile_user['body_link_v_c'] = adjustColor($_POST['body_link_v_c']); |
|---|
| 76 | |
|---|
| 77 | $ductile_user['body_font'] = $_POST['body_font']; |
|---|
| 78 | $ductile_user['alternate_font'] = $_POST['alternate_font']; |
|---|
| 79 | |
|---|
| 80 | $core->blog->settings->addNamespace('themes'); |
|---|
| 81 | $core->blog->settings->themes->put('ductile_style',serialize($ductile_user)); |
|---|
| 82 | $core->blog->triggerBlog(); |
|---|
| 83 | |
|---|
| 84 | echo |
|---|
| 85 | '<div class="message"><p>'. |
|---|
| 86 | __('Style sheet upgraded.'). |
|---|
| 87 | '</p></div>'; |
|---|
| 88 | } |
|---|
| 89 | catch (Exception $e) |
|---|
| 90 | { |
|---|
| 91 | $core->error->add($e->getMessage()); |
|---|
| 92 | } |
|---|
| 93 | } |
|---|
| 94 | |
|---|
| 95 | echo '<fieldset><legend>'.__('Fonts').'</legend>'. |
|---|
| 96 | '<p class="field"><label for="body_font">'.__('Main font:').' '. |
|---|
| 97 | form::combo('body_font',$fonts,$ductile_user['body_font']).'</label></p>'. |
|---|
| 98 | |
|---|
| 99 | '<p class="field"><label for="alternate_font">'.__('Alternate font:').' '. |
|---|
| 100 | form::combo('alternate_font',$fonts,$ductile_user['alternate_font']).'</label></p>'. |
|---|
| 101 | '</fieldset>'; |
|---|
| 102 | |
|---|
| 103 | echo '<fieldset><legend>'.__('Links').'</legend>'. |
|---|
| 104 | '<p class="field"><label for="body_link_c">'.__('Links color:').' '. |
|---|
| 105 | form::field('body_link_c',7,7,$ductile_user['body_link_c'],'colorpicker').'</label></p>'. |
|---|
| 106 | |
|---|
| 107 | '<p class="field"><label for="body_link_v_c">'.__('Visited links color:').' '. |
|---|
| 108 | form::field('body_link_v_c',7,7,$ductile_user['body_link_v_c'],'colorpicker').'</label></p>'. |
|---|
| 109 | |
|---|
| 110 | '<p class="field"><label for="body_link_f_c">'.__('Focus links color:').' '. |
|---|
| 111 | form::field('body_link_f_c',7,7,$ductile_user['body_link_f_c'],'colorpicker').'</label></p>'. |
|---|
| 112 | '</fieldset>'; |
|---|
| 113 | |
|---|
| 114 | ?> |
|---|