blob: 0d4bb9a312c0d32784f42ae10ef2bd4f72d3fb1d (
plain)
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
|
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Smarty {formlabel} function plugin
*
* Type: function
* Name: formlabel
* Input:
* - label (required) - words that are displayed
* - mandatory (optional) - add a class formmandatory in the div
*/
function smarty_function_formlabel( $params,&$gBitSmarty ) {
$atts = '';
foreach($params as $key => $val) {
switch( $key ) {
case 'label':
$name = $val;
break;
case 'mandatory':
$mandatory = true;
default:
if( $val ) {
$atts .= ' '.$key.'="'.$val.'"';
}
break;
}
}
$html = '<div class="formlabel';
if (isset($mandatory) && $mandatory) {
$html .= ' formmandatory';
}
$html .= '">';
if( $atts != '' ) {
$html .= '<label'.$atts.'>';
}
if( empty( $params['no_translate'] ) ) {
$html .= tra( $name );
} else {
$html .= $name;
}
if( $atts != '' ) {
$html .= '</label>';
}
$html .= '</div>';
return $html;
}
?>
|