Dotclear

source: themes/ductile/_public.php @ 563:87842010f794

Revision 563:87842010f794, 10.5 KB checked in by Franck <carnet.franck.paul@…>, 14 years ago (diff)

Mise en place gestion paramétrée des types de liste de billets (home, catégorie, search, tag, archive-month)

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

Sites map