Dotclear

source: themes/ductile/_config.php @ 357:b01c0e011e2f

Revision 357:b01c0e011e2f, 2.3 KB checked in by Franck <carnet.franck.paul@…>, 14 years ago (diff)

Mise en place des premiers réglages : couleur des liens

Line 
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 -----------------------------------------
12if (!defined('DC_CONTEXT_ADMIN')) { return; }
13
14l10n::set(dirname(__FILE__).'/locales/'.$_lang.'/main');
15
16function 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);
47if (!is_array($ductile_user)) {
48     $ductile_user = array();
49}
50
51$ductile_user = array_merge($ductile_base,$ductile_user);
52
53if (!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
76echo '<fieldset><legend>'.__('Links').'</legend>'.
77'<p class="field"><label for="body_link_c">'.__('Links color:').' '.
78form::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:').' '.
81form::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:').' '.
84form::field('body_link_f_c',7,7,$ductile_user['body_link_f_c'],'colorpicker').'</label></p>'.
85'</fieldset>';
86
87?>
Note: See TracBrowser for help on using the repository browser.

Sites map