PEEL Shopping
Open source ecommerce : PEEL Shopping
function.html_radios.php
Go to the documentation of this file.
1 <?php
45 function smarty_function_html_radios($params, $template)
46 {
47  require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
48 
49  $name = 'radio';
50  $values = null;
51  $options = null;
52  $selected = null;
53  $separator = '';
54  $escape = true;
55  $labels = true;
56  $label_ids = false;
57  $output = null;
58  $extra = '';
59 
60  foreach($params as $_key => $_val) {
61  switch ($_key) {
62  case 'name':
63  case 'separator':
64  $$_key = (string) $_val;
65  break;
66 
67  case 'checked':
68  case 'selected':
69  if (is_array($_val)) {
70  trigger_error('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING);
71  } elseif (is_object($_val)) {
72  if (method_exists($_val, "__toString")) {
73  $selected = smarty_function_escape_special_chars((string) $_val->__toString());
74  } else {
75  trigger_error("html_radios: selected attribute is an object of class '". get_class($_val) ."' without __toString() method", E_USER_NOTICE);
76  }
77  } else {
78  $selected = (string) $_val;
79  }
80  break;
81 
82  case 'escape':
83  case 'labels':
84  case 'label_ids':
85  $$_key = (bool) $_val;
86  break;
87 
88  case 'options':
89  $$_key = (array) $_val;
90  break;
91 
92  case 'values':
93  case 'output':
94  $$_key = array_values((array) $_val);
95  break;
96 
97  case 'radios':
98  trigger_error('html_radios: the use of the "radios" attribute is deprecated, use "options" instead', E_USER_WARNING);
99  $options = (array) $_val;
100  break;
101 
102  case 'assign':
103  break;
104 
105  case 'strict': break;
106 
107  case 'disabled':
108  case 'readonly':
109  if (!empty($params['strict'])) {
110  if (!is_scalar($_val)) {
111  trigger_error("html_options: $_key attribute must be a scalar, only boolean true or string '$_key' will actually add the attribute", E_USER_NOTICE);
112  }
113 
114  if ($_val === true || $_val === $_key) {
115  $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_key) . '"';
116  }
117 
118  break;
119  }
120  // omit break; to fall through!
121 
122  default:
123  if (!is_array($_val)) {
124  $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
125  } else {
126  trigger_error("html_radios: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
127  }
128  break;
129  }
130  }
131 
132  if (!isset($options) && !isset($values)) {
133  /* raise error here? */
134  return '';
135  }
136 
137  $_html_result = array();
138 
139  if (isset($options)) {
140  foreach ($options as $_key => $_val) {
141  $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids, $escape);
142  }
143  } else {
144  foreach ($values as $_i => $_key) {
145  $_val = isset($output[$_i]) ? $output[$_i] : '';
146  $_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids, $escape);
147  }
148  }
149 
150  if (!empty($params['assign'])) {
151  $template->assign($params['assign'], $_html_result);
152  } else {
153  return implode("\n", $_html_result);
154  }
155 }
156 
157 function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids, $escape)
158 {
159  $_output = '';
160 
161  if (is_object($value)) {
162  if (method_exists($value, "__toString")) {
163  $value = (string) $value->__toString();
164  } else {
165  trigger_error("html_options: value is an object of class '". get_class($value) ."' without __toString() method", E_USER_NOTICE);
166  return '';
167  }
168  } else {
169  $value = (string) $value;
170  }
171 
172  if (is_object($output)) {
173  if (method_exists($output, "__toString")) {
174  $output = (string) $output->__toString();
175  } else {
176  trigger_error("html_options: output is an object of class '". get_class($output) ."' without __toString() method", E_USER_NOTICE);
177  return '';
178  }
179  } else {
180  $output = (string) $output;
181  }
182 
183  if ($labels) {
184  if ($label_ids) {
185  $_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_', $name . '_' . $value));
186  $_output .= '<label for="' . $_id . '">';
187  } else {
188  $_output .= '<label>';
189  }
190  }
191 
192  $name = smarty_function_escape_special_chars($name);
193  $value = smarty_function_escape_special_chars($value);
194  if ($escape) {
195  $output = smarty_function_escape_special_chars($output);
196  }
197 
198  $_output .= '<input type="radio" name="' . $name . '" value="' . $value . '"';
199 
200  if ($labels && $label_ids) {
201  $_output .= ' id="' . $_id . '"';
202  }
203 
204  if ($value === $selected) {
205  $_output .= ' checked="checked"';
206  }
207 
208  $_output .= $extra . ' />' . $output;
209  if ($labels) {
210  $_output .= '</label>';
211  }
212 
213  $_output .= $separator;
214  return $_output;
215 }
216 
217 ?>
static $_UTF8_MODIFIER
Flag denoting if PCRE should run in UTF-8 mode.
smarty_function_html_radios($params, $template)
Smarty {html_radios} function plugin.
smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids, $escape)
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

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.