Dotclear

source: themes/ductile/_public.php @ 515:953e6a577fce

Revision 515:953e6a577fce, 9.9 KB checked in by Franck <carnet.franck.paul@…>, 14 years ago (diff)

Rajout du choix de la couleur des titres sans lien dans le configurateur

RevLine 
[345]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
[419]15# Behaviors
[345]16$core->addBehavior('publicHeadContent',array('tplDuctileTheme','publicHeadContent'));
[429]17$core->addBehavior('publicInsideFooter',array('tplDuctileTheme','publicInsideFooter'));
[419]18
[345]19class tplDuctileTheme
20{
[429]21     public static function publicInsideFooter($core)
[419]22     {
23          $res = '';
24          $default = false;
[429]25          $img_url = $core->blog->settings->system->themes_url.'/'.$core->blog->settings->system->theme.'/img/';
[419]26
[429]27          $s = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_stickers');
[419]28
29          if ($s === null) {
30               $default = true;
31          } else {
32               $s = @unserialize($s);
33               if (!is_array($s)) {
34                    $default = true;
35               } else {
[444]36                    $s = array_filter($s,"tplDuctileTheme::cleanStickers");
[419]37                    if (count($s) == 0) {
38                         $default = true;
39                    } else {
40                         $count = 1;
41                         foreach ($s as $sticker) {
42                              $res .= self::setSticker($count,($count == count($s)),$sticker['label'],$sticker['url'],$img_url.$sticker['image']);
43                              $count++;
44                         }
45                    }
46               }
47          }
48
49          if ($default || $res == '') {
[429]50               $res = self::setSticker(1,true,__('Feed'),$core->blog->url.$core->url->getBase('feed').'/atom',$img_url.'sticker-feed.png');
[419]51          }
52
53          if ($res != '') {
54               $res = '<ul id="stickers">'."\n".$res.'</ul>'."\n";
[429]55               echo $res;
[419]56          }
57     }
58     
59     protected static function cleanStickers($s)
60     {
61          if (is_array($s)) {
62               if (isset($s['label']) && isset($s['url']) && isset($s['image'])) {
63                    if ($s['label'] != null && $s['url'] != null && $s['image'] != null) {
64                         return true;
65                    }
66               }
67          }
68          return false;
69     }
70     
71     protected static function setSticker($position,$last,$label,$url,$image)
72     {
73          return '<li id="sticker'.$position.'"'.($last ? ' class="last"' : '').'>'."\n".
74               '<a href="'.$url.'">'."\n".
75               '<img alt="" src="'.$image.'" />'."\n".
76               '<span>'.$label.'</span>'."\n".
77               '</a>'."\n".
78               '</li>'."\n";
79     }
80
[345]81     public static function publicHeadContent($core)
82     {
[357]83          echo 
84               '<style type="text/css">'."\n".
[421]85               '/* '.__('Additionnal style directives').' */'."\n".
[357]86               self::ductileStyleHelper().
87               "</style>\n";
88     }
89     
90     public static function ductileStyleHelper()
91     {
[394]92          $s = $GLOBALS['core']->blog->settings->themes->get($GLOBALS['core']->blog->settings->system->theme.'_style');
[357]93
94          if ($s === null) {
95               return;
96          }
97
98          $s = @unserialize($s);
99          if (!is_array($s)) {
100               return;
101          }
102
103          $css = array();
104
105          # Properties
[389]106         
107          # Blog description
108          $selectors = '#blogdesc';
109          if (isset($s['subtitle_hidden'])) self::prop($css,$selectors,'display',($s['subtitle_hidden'] ? 'none' : null));
[357]110
[376]111          # Main font
[387]112          $selectors = 'body, #supranav li a span, #comments.me, a.comment-number';
113          if (isset($s['body_font'])) self::prop($css,$selectors,'font-family',self::fontDef($s['body_font']));
[376]114
[378]115          # Secondary font
[387]116          $selectors = '#blogdesc, #supranav, #content-info, #subcategories, #comments-feed, #sidebar h2, #sidebar h3, #footer p';
117          if (isset($s['alternate_font'])) self::prop($css,$selectors,'font-family',self::fontDef($s['alternate_font']));
[378]118         
119          # Inside posts links font weight
[387]120          $selectors = '.post-excerpt a, .post-content a';
121          if (isset($s['post_link_w'])) self::prop($css,$selectors,'font-weight',($s['post_link_w'] ? 'bold' : 'normal'));
[376]122
[378]123          # Inside posts links colors (normal, visited)
[387]124          $selectors = '.post-excerpt a:link, .post-excerpt a:visited, .post-content a:link, .post-content a:visited';
125          if (isset($s['post_link_v_c'])) self::prop($css,$selectors,'color',$s['post_link_v_c']);
[378]126
127          # Inside posts links colors (hover, active, focus)
[387]128          $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';
129          if (isset($s['post_link_f_c'])) self::prop($css,$selectors,'color',$s['post_link_f_c']);
[357]130
[376]131          # Style directives
[357]132          $res = '';
133          foreach ($css as $selector => $values) {
134               $res .= $selector." {\n";
135               foreach ($values as $k => $v) {
136                    $res .= $k.':'.$v.";\n";
137               }
138               $res .= "}\n";
139          }
140
[387]141          # Large screens
142          $css_large = array();
143
144          # Blog title font weight
145          $selectors = 'h1, h1 a:link, h1 a:visited, h1 a:hover, h1 a:visited, h1 a:focus';
146          if (isset($s['blog_title_w'])) self::prop($css_large,$selectors,'font-weight',($s['blog_title_w'] ? 'bold' : 'normal'));
147         
148          # Blog title font size
149          $selectors = 'h1';
150          if (isset($s['blog_title_s'])) self::prop($css_large,$selectors,'font-size',$s['blog_title_s']);
151         
152          # Blog title color
153          $selectors = 'h1 a:link, h1 a:visited, h1 a:hover, h1 a:visited, h1 a:focus';
154          if (isset($s['blog_title_c'])) self::prop($css_large,$selectors,'color',$s['blog_title_c']);
155
156          # Post title font weight
157          $selectors = 'h2.post-title, h2.post-title a:link, h2.post-title a:visited, h2.post-title a:hover, h2.post-title a:visited, h2.post-title a:focus';
158          if (isset($s['post_title_w'])) self::prop($css_large,$selectors,'font-weight',($s['post_title_w'] ? 'bold' : 'normal'));
159         
160          # Post title font size
161          $selectors = 'h2.post-title';
162          if (isset($s['post_title_s'])) self::prop($css_large,$selectors,'font-size',$s['post_title_s']);
163         
164          # Post title color
165          $selectors = 'h2.post-title a:link, h2.post-title a:visited, h2.post-title a:hover, h2.post-title a:visited, h2.post-title a:focus';
166          if (isset($s['post_title_c'])) self::prop($css_large,$selectors,'color',$s['post_title_c']);
167
[515]168          # Simple title color (title without link)
169          $selectors = '#content-info h2, .post-title, .post h3, .post h4, .post h5, .post h6, .arch-block h3';
170          if (isset($s['post_simple_title_c'])) self::prop($css_large,$selectors,'color',$s['post_simple_title_c']);
171
[387]172          # Style directives for large screens
173          if (count($css_large)) {
174               $res .= '@media only screen and (min-width: 481px) {'."\n";
175               foreach ($css_large as $selector => $values) {
176                    $res .= $selector." {\n";
177                    foreach ($values as $k => $v) {
178                         $res .= $k.':'.$v.";\n";
179                    }
180                    $res .= "}\n";
181               }
182               $res .= "}\n";
183          }
184
185          # Small screens
186          $css_small = array();
187
188          # Blog title font weight
189          $selectors = 'h1, h1 a:link, h1 a:visited, h1 a:hover, h1 a:visited, h1 a:focus';
190          if (isset($s['blog_title_w_m'])) self::prop($css_small,$selectors,'font-weight',($s['blog_title_w_m'] ? 'bold' : 'normal'));
191         
192          # Blog title font size
193          $selectors = 'h1';
194          if (isset($s['blog_title_s_m'])) self::prop($css_small,$selectors,'font-size',$s['blog_title_s_m']);
195         
196          # Blog title color
197          $selectors = 'h1 a:link, h1 a:visited, h1 a:hover, h1 a:visited, h1 a:focus';
198          if (isset($s['blog_title_c_m'])) self::prop($css_small,$selectors,'color',$s['blog_title_c_m']);
199
200          # Post title font weight
201          $selectors = 'h2.post-title, h2.post-title a:link, h2.post-title a:visited, h2.post-title a:hover, h2.post-title a:visited, h2.post-title a:focus';
202          if (isset($s['post_title_w_m'])) self::prop($css_small,$selectors,'font-weight',($s['post_title_w_m'] ? 'bold' : 'normal'));
203         
204          # Post title font size
205          $selectors = 'h2.post-title';
206          if (isset($s['post_title_s_m'])) self::prop($css_small,$selectors,'font-size',$s['post_title_s_m']);
207         
208          # Post title color
209          $selectors = 'h2.post-title a:link, h2.post-title a:visited, h2.post-title a:hover, h2.post-title a:visited, h2.post-title a:focus';
210          if (isset($s['post_title_c_m'])) self::prop($css_small,$selectors,'color',$s['post_title_c_m']);
211
212          # Style directives for small screens
213          if (count($css_small)) {
214               $res .= '@media only screen and (max-width: 480px) {'."\n";
215               foreach ($css_small as $selector => $values) {
216                    $res .= $selector." {\n";
217                    foreach ($values as $k => $v) {
218                         $res .= $k.':'.$v.";\n";
219                    }
220                    $res .= "}\n";
221               }
222               $res .= "}\n";
223          }
224         
[357]225          return $res;
226     }
227
[376]228     protected static $fonts = array(
[377]229          // Theme standard
[376]230          'Ductile body' => '"Century Schoolbook", "Century Schoolbook L", Georgia, serif',
231          'Ductile alternate' => '"Franklin gothic medium", "arial narrow", "DejaVu Sans Condensed", "helvetica neue", helvetica, sans-serif',
[377]232
233          // Serif families
[376]234          'Times New Roman' => 'Cambria, "Hoefler Text", Utopia, "Liberation Serif", "Nimbus Roman No9 L Regular", Times, "Times New Roman", serif',
235          'Georgia' => 'Constantia, "Lucida Bright", Lucidabright, "Lucida Serif", Lucida, "DejaVu Serif," "Bitstream Vera Serif", "Liberation Serif", Georgia, serif',
236          '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',
[377]237
238          // Sans-serif families
[376]239          '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',
240          'Verdana' => 'Corbel, "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", "DejaVu Sans", "Bitstream Vera Sans", "Liberation Sans", Verdana, "Verdana Ref", sans-serif',
241          'Trebuchet MS' => '"Segoe UI", Candara, "Bitstream Vera Sans", "DejaVu Sans", "Bitstream Vera Sans", "Trebuchet MS", Verdana, "Verdana Ref", sans-serif',
[377]242
243          // Cursive families
[376]244          'Impact' => 'Impact, Haettenschweiler, "Franklin Gothic Bold", Charcoal, "Helvetica Inserat", "Bitstream Vera Sans Bold", "Arial Black", sans-serif',
[377]245
246          // Monospace families
[376]247          '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'
248     );
249
250     protected static function fontDef($c)
251     {
252          return isset(self::$fonts[$c]) ? self::$fonts[$c] : null;
253     }
254
[357]255     protected static function prop(&$css,$selector,$prop,$value)
256     {
257          if ($value) {
258               $css[$selector][$prop] = $value;
259          }
[345]260     }
261}
262?>
Note: See TracBrowser for help on using the repository browser.

Sites map