| 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_w' => 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_w'] = (integer) !empty($_POST['body_link_w']); | 
|---|
| 74 |  | 
|---|
| 75 |           $ductile_user['body_link_v_c'] = adjustColor($_POST['body_link_v_c']); | 
|---|
| 76 |           $ductile_user['body_link_f_c'] = adjustColor($_POST['body_link_f_c']); | 
|---|
| 77 |            | 
|---|
| 78 |           $ductile_user['body_font'] = $_POST['body_font']; | 
|---|
| 79 |           $ductile_user['alternate_font'] = $_POST['alternate_font']; | 
|---|
| 80 |            | 
|---|
| 81 |           $core->blog->settings->addNamespace('themes'); | 
|---|
| 82 |           $core->blog->settings->themes->put('ductile_style',serialize($ductile_user)); | 
|---|
| 83 |           $core->blog->triggerBlog(); | 
|---|
| 84 |  | 
|---|
| 85 |           echo | 
|---|
| 86 |           '<div class="message"><p>'. | 
|---|
| 87 |           __('Style sheet upgraded.'). | 
|---|
| 88 |           '</p></div>'; | 
|---|
| 89 |      } | 
|---|
| 90 |      catch (Exception $e) | 
|---|
| 91 |      { | 
|---|
| 92 |           $core->error->add($e->getMessage()); | 
|---|
| 93 |      } | 
|---|
| 94 | } | 
|---|
| 95 |  | 
|---|
| 96 | echo '<fieldset><legend>'.__('Fonts').'</legend>'. | 
|---|
| 97 | '<p class="field"><label for="body_font">'.__('Main font:').' '. | 
|---|
| 98 | form::combo('body_font',$fonts,$ductile_user['body_font']).'</label></p>'. | 
|---|
| 99 |  | 
|---|
| 100 | '<p class="field"><label for="alternate_font">'.__('Secondary font:').' '. | 
|---|
| 101 | form::combo('alternate_font',$fonts,$ductile_user['alternate_font']).'</label></p>'. | 
|---|
| 102 | '</fieldset>'; | 
|---|
| 103 |  | 
|---|
| 104 | echo '<fieldset><legend>'.__('Inside posts links').'</legend>'. | 
|---|
| 105 | '<p class="field"><label for="body_link_w">'.__('Links in bold:').' '. | 
|---|
| 106 | form::checkbox('body_link_w',1,$ductile_user['body_link_w']).'</label>'.'</p>'. | 
|---|
| 107 |  | 
|---|
| 108 | '<p class="field"><label for="body_link_v_c">'.__('Normal and visited links color:').'</label> '. | 
|---|
| 109 | form::field('body_link_v_c',7,7,$ductile_user['body_link_v_c'],'colorpicker').'</p>'. | 
|---|
| 110 |  | 
|---|
| 111 | '<p class="field"><label for="body_link_f_c">'.__('Active, hover and focus links color:').'</label> '. | 
|---|
| 112 | form::field('body_link_f_c',7,7,$ductile_user['body_link_f_c'],'colorpicker').'</p>'. | 
|---|
| 113 | '</fieldset>'; | 
|---|
| 114 |  | 
|---|
| 115 | ?> | 
|---|