/[hr-web]/inc/Smarty.local.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /inc/Smarty.local.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Wed Apr 25 13:18:50 2001 UTC (23 years ago) by dpavlin
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +0 -1 lines
promjene za finalnu verziju

1 dpavlin 1.1 <?php
2    
3     //-----------------------------------------
4     // Custom made by Dobrica Pavlinusic <dpavlin@rot13.org>
5    
6     function smarty_func_img() {
7     extract(func_get_arg(0));
8    
9     $f=Array();
10    
11     global $img_time;
12     if (!isset($img_time)) {
13     $img_time=time();
14     }
15    
16    
17     if (isset($dir)) {
18     $tdir=dirname($GLOBALS[SCRIPT_FILENAME])."/$dir";
19     $h=opendir($dir);
20     $pics=0;
21     while ($tmp = readdir($h)) {
22     if (is_file("$tdir/$tmp") && substr($tmp,0,1)!=".") {
23     // print "$tdir/$tmp<br>\n";
24     $f[]=$tmp;
25     $pics++;
26     }
27     }
28     closedir($h);
29     // $f=shuffle($f);
30     $ord=($img_time+$nr) % $pics;
31     $src="$dir/$f[$ord]";
32     }
33    
34     $add="";
35     if (isset($border)) {
36     $add.=" border=\"$border\"";
37     }
38     if (isset($alt)) {
39     $add.=" alt=\"$alt\"";
40     }
41     if (isset($align)) {
42     $add.=" align=\"$align\"";
43     }
44     if (isset($hspace)) {
45     $add.=" hspace=\"$hspace\"";
46     }
47     if (isset($vspace)) {
48     $add.=" vspace=\"$vspace\"";
49     }
50    
51     $out="";
52     $product_link = array (
53     "andol.gif"=>"human_health.php?search=andol&show_description=on#results",
54     "andol_c.jpg"=>"human_health.php?search=andol%25c&show_description=on#results",
55     "bisolex.jpg"=>"human_health.php?search=bisolex&show_description=on#results",
56     "plibex.gif"=>"human_health.php?search=plibex&show_description=on#results",
57     "plivit_b.gif"=>"human_health.php?search=plivit%25b&show_description=on#results",
58     "plivit_b6.gif"=>"human_health.php?search=plivit%25b6&show_description=on#results",
59     "plivit_c.gif"=>"human_health.php?search=plivit%25c&show_description=on#results",
60     );
61    
62     $pic=basename($src);
63     if ($product_link[$pic]) {
64     $out.="<a href=\"$product_link[$pic]\">";
65     $add.=" border=\"0\"";
66     }
67    
68     $size = GetImageSize(dirname($GLOBALS[SCRIPT_FILENAME])."/$src");
69     $out.="<img src=\"$src\" $size[3]$add>";
70     if ($product_link[$pic]) {
71     $out.="</a>";
72     }
73     print $out;
74     }
75    
76     // checkboxes
77    
78     function smarty_func_html_checkboxes()
79     {
80     $print_result = true;
81    
82     extract(func_get_arg(0));
83    
84     settype($output, 'array');
85     settype($values, 'array');
86    
87     $html_result = "";
88    
89     for ($i = 0; $i < count($output); $i++) {
90     /* By default, check value against $selected */
91     $sel_check = $values[$i];
92     if (isset($before)) $html_result.=$before;
93     $html_result .= "<input type=checkbox name=\"".$values[$i]."\"";
94     if (isset($GLOBALS[$values[$i]])) {
95     $html_result .= " checked";
96     }
97     $html_result .= ">".$output[$i]."\n";
98     if (isset($after)) $html_result.=$after;
99     }
100    
101     if ($print_result)
102     print $html_result;
103     else
104     return $html_result;
105     }
106    
107     // $filename|filesize:"dir":"unit"
108     //
109     // dir -- path to file (or "")
110     // unit -- Mb|Kb|auto
111    
112     function smarty_mod_filesize($file,$dir,$unit="")
113     {
114     $path=dirname($GLOBALS[SCRIPT_FILENAME])."/$dir/$file";
115    
116     if ($size=filesize($path)) {
117     switch ($unit) {
118     case 'Mb':
119     case 'mb':
120     return sprintf("%2.1f Mb",$size/(1024*1024));
121     case 'Kb':
122     case 'kb':
123     return sprintf("%2.1f Mb",$size/1024);
124     case 'auto':
125     $size=$size/1024; # Kb
126     if ($size > 1024) {
127     return sprintf("%2.1f Mb",$size/1024);
128     } else {
129     return sprintf("%2.1f Kb",$size);
130     }
131    
132     }
133     return $size;
134     }
135     }
136    
137     // input functions (input, rinput)
138    
139     function smarty_func_input() {
140     extract(func_get_arg(0));
141     print "<input name=\"$name\" size=\"$size\" value=\"".$GLOBALS[$name]."\">";
142     print "<input type=\"hidden\" name=\"inputs_required[]\" value=\"$name\">";
143     if ($type) print "<input type=\"hidden\" name=\"inputs_required_type[$name]\" value=\"$type\">";
144     }
145    
146     function smarty_func_rinput() {
147     extract(func_get_arg(0));
148     global $inputs_required_type;
149     $ok=1;
150     if (! isset($GLOBALS[$name]) || $GLOBALS[$name] == "") {
151     $ok=0;
152     } else {
153     switch($inputs_required_type[$name]) {
154     case 'email':
155     if (!strstr($GLOBALS[$name],'@')) $ok=0;
156     }
157     }
158     if ($ok) {
159     print "$desc";
160     } else {
161     print "<b>$desc</b>";
162     }
163     }
164     ?>

  ViewVC Help
Powered by ViewVC 1.1.26