Changeset 357:b01c0e011e2f
- Timestamp:
- 06/13/11 15:31:04 (14 years ago)
- Branch:
- themes
- Location:
- themes/ductile
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
themes/ductile/_config.php
r345 r357 12 12 if (!defined('DC_CONTEXT_ADMIN')) { return; } 13 13 14 echo 15 '<p class="area">Ici, bientôt, la configuration du thème Ductile.</p>'; 14 l10n::set(dirname(__FILE__).'/locales/'.$_lang.'/main'); 15 16 function adjustColor($c) 17 { 18 if ($c === '') { 19 return ''; 20 } 21 22 $c = strtoupper($c); 23 24 if (preg_match('/^[A-F0-9]{3,6}$/',$c)) { 25 $c = '#'.$c; 26 } 27 28 if (preg_match('/^#[A-F0-9]{6}$/',$c)) { 29 return $c; 30 } 31 32 if (preg_match('/^#[A-F0-9]{3,}$/',$c)) { 33 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); 34 } 35 36 return ''; 37 } 38 39 $ductile_base = array( 40 'body_link_c' => null, 41 'body_link_v_c' => null, 42 'body_link_f_c' => null 43 ); 44 45 $ductile_user = $core->blog->settings->themes->ductile_style; 46 $ductile_user = @unserialize($ductile_user); 47 if (!is_array($ductile_user)) { 48 $ductile_user = array(); 49 } 50 51 $ductile_user = array_merge($ductile_base,$ductile_user); 52 53 if (!empty($_POST)) 54 { 55 try 56 { 57 $ductile_user['body_link_c'] = adjustColor($_POST['body_link_c']); 58 $ductile_user['body_link_f_c'] = adjustColor($_POST['body_link_f_c']); 59 $ductile_user['body_link_v_c'] = adjustColor($_POST['body_link_v_c']); 60 61 $core->blog->settings->addNamespace('themes'); 62 $core->blog->settings->themes->put('ductile_style',serialize($ductile_user)); 63 $core->blog->triggerBlog(); 64 65 echo 66 '<div class="message"><p>'. 67 __('Style sheet upgraded.'). 68 '</p></div>'; 69 } 70 catch (Exception $e) 71 { 72 $core->error->add($e->getMessage()); 73 } 74 } 75 76 echo '<fieldset><legend>'.__('Links').'</legend>'. 77 '<p class="field"><label for="body_link_c">'.__('Links color:').' '. 78 form::field('body_link_c',7,7,$ductile_user['body_link_c'],'colorpicker').'</label></p>'. 79 80 '<p class="field"><label for="body_link_v_c">'.__('Visited links color:').' '. 81 form::field('body_link_v_c',7,7,$ductile_user['body_link_v_c'],'colorpicker').'</label></p>'. 82 83 '<p class="field"><label for="body_link_f_c">'.__('Focus links color:').' '. 84 form::field('body_link_f_c',7,7,$ductile_user['body_link_f_c'],'colorpicker').'</label></p>'. 85 '</fieldset>'; 86 16 87 ?> -
themes/ductile/_public.php
r345 r357 19 19 public static function publicHeadContent($core) 20 20 { 21 echo '<style type="text/css">'."\n".'/* Additionnal style directives */'."\n</style>\n"; 21 echo 22 '<style type="text/css">'."\n". 23 '/* Additionnal style directives */'."\n". 24 self::ductileStyleHelper(). 25 "</style>\n"; 26 } 27 28 public static function ductileStyleHelper() 29 { 30 $s = $GLOBALS['core']->blog->settings->themes->ductile_style; 31 32 if ($s === null) { 33 return; 34 } 35 36 $s = @unserialize($s); 37 if (!is_array($s)) { 38 return; 39 } 40 41 $css = array(); 42 43 # Properties 44 45 self::prop($css,'a','color',$s['body_link_c']); 46 self::prop($css,'a:visited','color',$s['body_link_v_c']); 47 self::prop($css,'a:hover, a:focus, a:active','color',$s['body_link_f_c']); 48 49 $res = ''; 50 foreach ($css as $selector => $values) { 51 $res .= $selector." {\n"; 52 foreach ($values as $k => $v) { 53 $res .= $k.':'.$v.";\n"; 54 } 55 $res .= "}\n"; 56 } 57 58 return $res; 59 } 60 61 protected static function prop(&$css,$selector,$prop,$value) 62 { 63 if ($value) { 64 $css[$selector][$prop] = $value; 65 } 22 66 } 23 67 }
Note: See TracChangeset
for help on using the changeset viewer.