/[corp_html]/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

Diff of /inc/Smarty.local.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by dpavlin, Sat Mar 17 15:46:05 2001 UTC revision 1.5 by dpavlin, Sun Mar 18 23:36:26 2001 UTC
# Line 104  function smarty_func_html_checkboxes() Line 104  function smarty_func_html_checkboxes()
104                  return $html_result;                  return $html_result;
105  }  }
106    
107  // filesize  // $filename|filesize:"dir":"unit"
108    //
109    // dir -- path to file (or "")
110    // unit -- Mb|Kb|auto
111    
112  function smarty_mod_filesize($file,$unit)  function smarty_mod_filesize($file,$dir,$unit="")
113  {  {
114          $path=dirname($GLOBALS[SCRIPT_FILENAME])."/$file";          $path=dirname($GLOBALS[SCRIPT_FILENAME])."/$dir/$file";
         print "-- $path --";  
115    
116          if ($size=filesize($path)) {          if ($size=filesize($path)) {
117                  switch ($unit) {                  switch ($unit) {
118                          case 'Mb':                          case 'Mb':
119                          case 'mb':                          case 'mb':
120                                  return sprintf("%02.1d Mb",$size/(1024*1024));                                  return sprintf("%2.1f Mb",$size/(1024*1024));
121                          case 'Kb':                          case 'Kb':
122                          case 'kb':                          case 'kb':
123                                  return sprintf("%02.1d Mb",$size/1024);                                  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;                  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  ?>  ?>
165    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.5

  ViewVC Help
Powered by ViewVC 1.1.26