Dotclear

source: themes/ductile/_public.php @ 378:a103e2765a14

Revision 378:a103e2765a14, 4.5 KB checked in by Franck <carnet.franck.paul@…>, 14 years ago (diff)

Configuration des polices - step 2 : couleurs et graisse des liens + divers

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 -----------------------------------------
12
13if (!defined('DC_RC_PATH')) { return; }
14
15$core->addBehavior('publicHeadContent',array('tplDuctileTheme','publicHeadContent'));
16
17class tplDuctileTheme
18{
19     public static function publicHeadContent($core)
20     {
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          # Main font
46          $main_font_selectors = 'body, #supranav li a span, #comments.me, a.comment-number';
47          if (isset($s['body_font'])) self::prop($css,$main_font_selectors,'font-family',self::fontDef($s['body_font']));
48
49          # Secondary font
50          $alternate_font_selectors = '#blogdesc, #supranav, #content-info, #subcategories, #comments-feed, #sidebar h2, #sidebar h3, #footer p';
51          if (isset($s['alternate_font'])) self::prop($css,$alternate_font_selectors,'font-family',self::fontDef($s['alternate_font']));
52         
53          # Inside posts links font weight
54          $links = '.post-excerpt a, .post-content a';
55          if (isset($s['body_link_w'])) self::prop($css,$links,'font-weight',($s['body_link_w'] ? 'bold' : 'normal'));
56
57          # Inside posts links colors (normal, visited)
58          $links_selectors = '.post-excerpt a:link, .post-excerpt a:visited, .post-content a:link, .post-content a:visited';
59          if (isset($s['body_link_v_c'])) self::prop($css,$links_selectors,'color',$s['body_link_v_c']);
60
61          # Inside posts links colors (hover, active, focus)
62          $links_alternate_selectors = '.post-excerpt a:hover, .post-excerpt a:active, .post-excerpt a:focus, .post-content a:hover, .post-content a:active, .post-content a:focus';
63          if (isset($s['body_link_f_c'])) self::prop($css,$links_alternate_selectors,'color',$s['body_link_f_c']);
64
65          # Style directives
66          $res = '';
67          foreach ($css as $selector => $values) {
68               $res .= $selector." {\n";
69               foreach ($values as $k => $v) {
70                    $res .= $k.':'.$v.";\n";
71               }
72               $res .= "}\n";
73          }
74
75          return $res;
76     }
77
78     protected static $fonts = array(
79          // Theme standard
80          'Ductile body' => '"Century Schoolbook", "Century Schoolbook L", Georgia, serif',
81          'Ductile alternate' => '"Franklin gothic medium", "arial narrow", "DejaVu Sans Condensed", "helvetica neue", helvetica, sans-serif',
82
83          // Serif families
84          'Times New Roman' => 'Cambria, "Hoefler Text", Utopia, "Liberation Serif", "Nimbus Roman No9 L Regular", Times, "Times New Roman", serif',
85          'Georgia' => 'Constantia, "Lucida Bright", Lucidabright, "Lucida Serif", Lucida, "DejaVu Serif," "Bitstream Vera Serif", "Liberation Serif", Georgia, serif',
86          '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',
87
88          // Sans-serif families
89          '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',
90          'Verdana' => 'Corbel, "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", "Bitstream Vera Sans", "Liberation Sans", Verdana, "Verdana Ref", sans-serif',
91          'Trebuchet MS' => '"Segoe UI", Candara, "Bitstream Vera Sans", "DejaVu Sans", "Bitstream Vera Sans", "Trebuchet MS", Verdana, "Verdana Ref", sans-serif',
92
93          // Cursive families
94          'Impact' => 'Impact, Haettenschweiler, "Franklin Gothic Bold", Charcoal, "Helvetica Inserat", "Bitstream Vera Sans Bold", "Arial Black", sans-serif',
95
96          // Monospace families
97          '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'
98     );
99
100     protected static function fontDef($c)
101     {
102          return isset(self::$fonts[$c]) ? self::$fonts[$c] : null;
103     }
104
105     protected static function prop(&$css,$selector,$prop,$value)
106     {
107          if ($value) {
108               $css[$selector][$prop] = $value;
109          }
110     }
111}
112?>
Note: See TracBrowser for help on using the repository browser.

Sites map