PEEL Shopping
Open source ecommerce : PEEL Shopping
function.html_table.php
Go to the documentation of this file.
1 <?php
50 function smarty_function_html_table($params, $template)
51 {
52  $table_attr = 'border="1"';
53  $tr_attr = '';
54  $th_attr = '';
55  $td_attr = '';
56  $cols = $cols_count = 3;
57  $rows = 3;
58  $trailpad = '&nbsp;';
59  $vdir = 'down';
60  $hdir = 'right';
61  $inner = 'cols';
62  $caption = '';
63  $loop = null;
64 
65  if (!isset($params['loop'])) {
66  trigger_error("html_table: missing 'loop' parameter",E_USER_WARNING);
67  return;
68  }
69 
70  foreach ($params as $_key => $_value) {
71  switch ($_key) {
72  case 'loop':
73  $$_key = (array)$_value;
74  break;
75 
76  case 'cols':
77  if (is_array($_value) && !empty($_value)) {
78  $cols = $_value;
79  $cols_count = count($_value);
80  } elseif (!is_numeric($_value) && is_string($_value) && !empty($_value)) {
81  $cols = explode(',', $_value);
82  $cols_count = count($cols);
83  } elseif (!empty($_value)) {
84  $cols_count = (int)$_value;
85  } else {
86  $cols_count = $cols;
87  }
88  break;
89 
90  case 'rows':
91  $$_key = (int)$_value;
92  break;
93 
94  case 'table_attr':
95  case 'trailpad':
96  case 'hdir':
97  case 'vdir':
98  case 'inner':
99  case 'caption':
100  $$_key = (string)$_value;
101  break;
102 
103  case 'tr_attr':
104  case 'td_attr':
105  case 'th_attr':
106  $$_key = $_value;
107  break;
108  }
109  }
110 
111  $loop_count = count($loop);
112  if (empty($params['rows'])) {
113  /* no rows specified */
114  $rows = ceil($loop_count / $cols_count);
115  } elseif (empty($params['cols'])) {
116  if (!empty($params['rows'])) {
117  /* no cols specified, but rows */
118  $cols_count = ceil($loop_count / $rows);
119  }
120  }
121 
122  $output = "<table $table_attr>\n";
123 
124  if (!empty($caption)) {
125  $output .= '<caption>' . $caption . "</caption>\n";
126  }
127 
128  if (is_array($cols)) {
129  $cols = ($hdir == 'right') ? $cols : array_reverse($cols);
130  $output .= "<thead><tr>\n";
131 
132  for ($r = 0; $r < $cols_count; $r++) {
133  $output .= '<th' . smarty_function_html_table_cycle('th', $th_attr, $r) . '>';
134  $output .= $cols[$r];
135  $output .= "</th>\n";
136  }
137  $output .= "</tr></thead>\n";
138  }
139 
140  $output .= "<tbody>\n";
141  for ($r = 0; $r < $rows; $r++) {
142  $output .= "<tr" . smarty_function_html_table_cycle('tr', $tr_attr, $r) . ">\n";
143  $rx = ($vdir == 'down') ? $r * $cols_count : ($rows-1 - $r) * $cols_count;
144 
145  for ($c = 0; $c < $cols_count; $c++) {
146  $x = ($hdir == 'right') ? $rx + $c : $rx + $cols_count-1 - $c;
147  if ($inner != 'cols') {
148  /* shuffle x to loop over rows*/
149  $x = floor($x / $cols_count) + ($x % $cols_count) * $rows;
150  }
151 
152  if ($x < $loop_count) {
153  $output .= "<td" . smarty_function_html_table_cycle('td', $td_attr, $c) . ">" . $loop[$x] . "</td>\n";
154  } else {
155  $output .= "<td" . smarty_function_html_table_cycle('td', $td_attr, $c) . ">$trailpad</td>\n";
156  }
157  }
158  $output .= "</tr>\n";
159  }
160  $output .= "</tbody>\n";
161  $output .= "</table>\n";
162 
163  return $output;
164 }
165 
166 function smarty_function_html_table_cycle($name, $var, $no)
167 {
168  if (!is_array($var)) {
169  $ret = $var;
170  } else {
171  $ret = $var[$no % count($var)];
172  }
173 
174  return ($ret) ? ' ' . $ret : '';
175 }
176 
177 ?>
smarty_function_html_table_cycle($name, $var, $no)
if(strlen($date2)== '10') if($type== 'users-by-age'&&a_priv('admin_users', true)) elseif($type== 'forums-count'&&a_priv('admin_content', true)) elseif($type== 'forums-categories'&&a_priv('admin_content', true)) elseif($type== 'users-count'&&a_priv('admin_users', true)) elseif($type== 'product-categories'&&a_priv('admin_products', true)) elseif($type== 'users-by-sex'&&a_priv('admin_users', true)) elseif($type== 'users-by-country'&&a_priv('admin_users', true)) elseif($type== 'sales'&&a_priv('admin_sales', true))
Definition: chart-data.php:160
smarty_function_html_table($params, $template)
Smarty {html_table} function plugin.

This documentation for Open ecommerce PEEL Shopping and PEEL.fr has been generated by Doxygen on Thu Oct 15 2015 14:41:16 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.