51 $table_attr =
'border="1"';
55 $cols = $cols_count = 3;
63 if (!isset($params[
'loop'])) {
64 $smarty->trigger_error(
"html_table: missing 'loop' parameter");
68 foreach ($params as $_key=>$_value) {
71 $$_key = (array)$_value;
75 if (is_array($_value) && !empty($_value)) {
77 $cols_count = count($_value);
78 } elseif (!is_numeric($_value) && is_string($_value) && !empty($_value)) {
79 $cols = explode(
',', $_value);
80 $cols_count = count($cols);
81 } elseif (!empty($_value)) {
82 $cols_count = (int)$_value;
89 $$_key = (int)$_value;
98 $$_key = (string)$_value;
109 $loop_count = count($loop);
110 if (empty($params[
'rows'])) {
112 $rows = ceil($loop_count/$cols_count);
113 } elseif (empty($params[
'cols'])) {
114 if (!empty($params[
'rows'])) {
116 $cols_count = ceil($loop_count/$rows);
120 $output =
"<table $table_attr>\n";
122 if (!empty($caption)) {
123 $output .=
'<caption>' . $caption .
"</caption>\n";
126 if (is_array($cols)) {
127 $cols = ($hdir ==
'right') ? $cols : array_reverse($cols);
128 $output .=
"<thead><tr>\n";
130 for ($r=0; $r<$cols_count; $r++) {
132 $output .= $cols[$r];
133 $output .=
"</th>\n";
135 $output .=
"</tr></thead>\n";
138 $output .=
"<tbody>\n";
139 for ($r=0; $r<$rows; $r++) {
141 $rx = ($vdir ==
'down') ? $r*$cols_count : ($rows-1-$r)*$cols_count;
143 for ($c=0; $c<$cols_count; $c++) {
144 $x = ($hdir ==
'right') ? $rx+$c : $rx+$cols_count-1-$c;
145 if ($inner!=
'cols') {
147 $x = floor($x/$cols_count) + ($x%$cols_count)*$rows;
150 if ($x<$loop_count) {
156 $output .=
"</tr>\n";
158 $output .=
"</tbody>\n";
159 $output .=
"</table>\n";
165 if(!is_array(
$var)) {
171 return (
$ret) ?
' '.$ret :
'';