public
Description: Git mirror of the CMS Made Simple 2.0 rewrite
Homepage: http://cmsmadesimple.org
Clone URL: git://github.com/tedkulp/cmsmadesimple-2-0.git
Search Repo:
tedkulp (author)
Sun Apr 27 07:29:54 -0700 2008
commit  1d4e393fe0cae8142711a915f87157611a76f101
tree    5ae931db88ca7b522756bf319e6cfc6ccda35924
parent  5c1eb285cfb340bd5332b019ff18afc44a4d5881
cmsmadesimple-2-0 / plugins / function.valid_css.php
100644 123 lines (110 sloc) 5.112 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
#CMS - CMS Made Simple
#(c)2004-2008 by Ted Kulp (ted@cmsmadesimple.org)
#This project's homepage is: http://cmsmadesimple.sf.net
#
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
function smarty_cms_function_valid_css($params, &$smarty)
{
    $link_url =
  (isset($params['url']) && trim($params['url']) != '')
  ? $params['url']
        : 'http://jigsaw.w3.org/css-validator/check/referer'
    ;
    
    $link_target =
  (isset($params['target']) && trim($params['target']) != '')
  ? $params['target']
  : ''
    ;
    $link_target_html = $link_target != '' ? ' target="' . $link_target . '"' : '';
    
    $link_class =
  (isset($params['class']) && trim($params['class']) != '')
  ? $params['class']
  : ''
    ;
    $link_class_html = $link_class != '' ? ' class="' . $link_class . '"' : '';
    
    $link_text =
  (isset($params['text']) && trim($params['text']) != '')
  ? $params['text']
  : 'valid CSS 2.1'
    ;
    
    $use_image = ((! isset($params['image'])) || $params['image'] != 'false');
    
    $image_src =
  (isset($params['src']) && trim($params['src']) != '')
  ? $params['src']
  : 'http://jigsaw.w3.org/css-validator/images/vcss'
    ;
    
    $image_alt = isset($params['alt']) ? $params['alt'] : $link_text;
    
    $image_width =
  (isset($params['width']) && trim($params['width']) != '')
  ? $params['width']
  : '88'
    ;
    $image_height =
  (isset($params['height']) && trim($params['height']) != '')
  ? $params['height']
  : '31'
    ;
    $image_size_html = ' width="' . $image_width . '" height="' . $image_height . '"';
    
    $image_class =
  (isset($params['image_class']) && trim($params['image_class']) != '')
  ? $params['image_class']
  : ''
    ;
    $image_class_html = $image_class != '' ? ' class="' . $image_class . '"' : '';
    
    $html = '<a href="' . $link_url . '"' . $link_class_html . $link_target_html . '>';
    $html .=
  $use_image
  ? '<img src="' . $image_src . '" alt="' . $image_alt . '"' . $image_size_html . $image_class_html . ' border="0" />'
  : $link_text;
    $html .= '</a>';
    
    return $html;
}
 
function smarty_cms_help_function_valid_css()
{
?>
<h3>What does this do?</h3>
<p>Returns a link to the w3c CSS validator.</p>
<h3>How do I use it?</h3>
<p>Just insert the tag into your template/page like: <code>{valid_css}</code></p>
<h3>What parameters does it take?</h3>
<p>
<ul>
<li><em>(optional)</em> url (string) - The URL used for validation, if none is given http://jigsaw.w3.org/css-validator/check/referer is used.</li>
  <li><em>(optional)</em> class (string) - If set, this will be used as class attribute for the link (a) element</li>
  <li><em>(optional)</em> target (string) - If set, this will be used as target attribute for the link (a) element</li>
  <li><em>(optional)</em> image (true/false) - If set to false, a text link will be used instead of an image/icon.</li>
  <li><em>(optional)</em> text (string) - If set, this will be used for the link text or alternate text for the image. Default is 'Valid CSS 2.1'.<br /> When an image is used, the given string will also be used for the image alt attribute (by default, this can be overridden by using the 'alt' parameter).</li>
  <li><em>(optional)</em> image_class (string) - Only if 'image' is not set to false. If set, this will be used as class attribute for the image (img) element</li>
<li><em>(optional)</em> src (string) - Only if 'image' is not set to false. The icon to show. Default is http://jigsaw.w3.org/css-validator/images/vcss</li>
<li><em>(optional)</em> width (string) - Only if 'image' is not set to false. The image width. Default is 88 (width of http://jigsaw.w3.org/css-validator/images/vcss)</li>
<li><em>(optional)</em> height (string) - Only if 'image' is not set to false. The image height. Default is 31 (height of http://jigsaw.w3.org/css-validator/images/vcss)</li>
  <li><em>(optional)</em> alt (string) - Only if 'image' is not set to false. The alternate text ('alt' attribute) for the image (element). If none is given the link text will be used.</li>
</ul>
</p>
<?php
}
 
function smarty_cms_about_function_valid_css()
{
?>
<p>Author: Tatu Wikman&lt;tatu.wikman[at]gmail.com&gt;</p>
<p>Version: 1.0</p>
<p>
Change History:<br/>
None
</p>
<p>Thanks go to Dick Ittmann for valid_xhtml tag which is used as a base for this tag</p>
<?php
}
?>