1 <?php
3 function smarty_function_factory($params, &$smarty)
4 {
6 // Capture params
7 foreach(array('type','id','name','title','value','maxlength',
8 'onfocus','onclick','onkeyup') as $var){
9 $$var = (isset($params[$var]))? $params[$var] : "";
10 $tmp = "{$var}Ready";
11 $$tmp = (isset($params[$var]))? "{$var}=\"{$params[$var]}\"" : "";
12 }
14 $str = "";
15 switch($type){
17 // Generate a password input field, with CapsLock detection.
18 case 'password' :
20 // Maxlength has a default of 40 characters
21 $maxlengthReady = (empty($maxlength))?'maxlength="40"': $maxlengthReady;
22 $str .= "<input {$nameReady} {$idReady} {$valueReady} {$maxlengthReady}
23 {$titleReady} {$onfocusReady} {$onkeyupReady} type='password'
24 onkeypress=\"
25 if (capslock(event)){
26 $('{$id}').style.backgroundImage='url(images/caps.png)'
27 } else {
28 $('{$id}').style.backgroundImage= ''
29 }\">";
30 }
31 return($str);
32 }
34 ?>