blob: 736914d5ad2aba054f62c71f5655c7c6cf677703 (
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
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
|
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Smarty {formfeedback} function plugin
*
* Type: function
* Name: formfeedback
* Input:
* - warning, error or success are defined css styles, but you can feed it anything
*/
function smarty_function_formfeedback( $params, &$gBitSmarty ) {
detoxify( $params );
if( !empty( $params['hash'] ) ) {
$hash = &$params['hash'];
} else {
// maybe params were passed in separately
$hash = &$params;
}
$feedback = '';
$i = 0;
$color = isset( $hash['color'] )?$hash['color']:"000000";
foreach( $hash as $key => $val ) {
if( $val ) {
$gBitSmarty->loadPlugin( 'smarty_modifier_biticon' );
$keys = array( 'warning', 'success', 'error', 'important' );
if( in_array( $key, $keys )) {
switch( $key ) {
case 'success':
$alertClass = 'alert alert-success';
break;
case 'warning':
$alertClass = 'alert';
break;
case 'error':
$alertClass = 'alert alert-error';
break;
case 'important':
default:
$alertClass = 'alert alert-info';
break;
}
if( !is_array( $val ) ) {
$val = array( $val );
}
foreach( $val as $valText ) {
if( is_array( $valText ) ) {
foreach( $valText as $text ) {
$feedback .= '<div class="'.$alertClass.'">'.$text.'</div>';
}
} else {
$feedback .= '<div class="'.$alertClass.'">'.$valText.'</div>';
}
}
} else {
/* unfortunately this plugin was written a little strictly and so it expects all params to be display text
* to allow setting of a background color we have to exclude that param when rendering out the html
* otherwise we'll render the color as text. -wjames5
*/
if ( $key != 'color' ) {
if( is_array( $val ) ) {
foreach( $val as $text ) {
$feedback .= '<div class="'.$key.'">'.$text.'</div>';
}
} else {
$feedback .= '<div class="'.$key.'">'.$val.'</div>';
}
}
}
}
}
$html = '';
if( !empty( $feedback ) ) {
$html = '<div class="feedback">';
$html .= $feedback;
$html .= '</div>';
}
return $html;
}
?>
|