PageRenderTime 33ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/libraries/joomla/html/select.php

https://bitbucket.org/pastor399/newcastleunifc
PHP | 723 lines | 404 code | 69 blank | 250 comment | 62 complexity | cbdc51851d6c9c74b42d1574bef3cce5 MD5 | raw file
  1. <?php
  2. /**
  3. * @package Joomla.Platform
  4. * @subpackage HTML
  5. *
  6. * @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7. * @license GNU General Public License version 2 or later; see LICENSE
  8. */
  9. defined('JPATH_PLATFORM') or die;
  10. /**
  11. * Utility class for creating HTML select lists
  12. *
  13. * @package Joomla.Platform
  14. * @subpackage HTML
  15. * @since 11.1
  16. */
  17. abstract class JHtmlSelect
  18. {
  19. /**
  20. * Default values for options. Organized by option group.
  21. *
  22. * @var array
  23. * @since 11.1
  24. */
  25. static protected $optionDefaults = array(
  26. 'option' => array('option.attr' => null, 'option.disable' => 'disable', 'option.id' => null, 'option.key' => 'value',
  27. 'option.key.toHtml' => true, 'option.label' => null, 'option.label.toHtml' => true, 'option.text' => 'text',
  28. 'option.text.toHtml' => true));
  29. /**
  30. * Generates a yes/no radio list.
  31. *
  32. * @param string $name The value of the HTML name attribute
  33. * @param array $attribs Additional HTML attributes for the <select> tag
  34. * @param string $selected The key that is selected
  35. * @param string $yes Language key for Yes
  36. * @param string $no Language key for no
  37. * @param string $id The id for the field
  38. *
  39. * @return string HTML for the radio list
  40. *
  41. * @since 11.1
  42. * @see JFormFieldRadio
  43. */
  44. public static function booleanlist($name, $attribs = null, $selected = null, $yes = 'JYES', $no = 'JNO', $id = false)
  45. {
  46. $arr = array(JHtml::_('select.option', '0', JText::_($no)), JHtml::_('select.option', '1', JText::_($yes)));
  47. return JHtml::_('select.radiolist', $arr, $name, $attribs, 'value', 'text', (int) $selected, $id);
  48. }
  49. /**
  50. * Generates an HTML selection list.
  51. *
  52. * @param array $data An array of objects, arrays, or scalars.
  53. * @param string $name The value of the HTML name attribute.
  54. * @param mixed $attribs Additional HTML attributes for the <select> tag. This
  55. * can be an array of attributes, or an array of options. Treated as options
  56. * if it is the last argument passed. Valid options are:
  57. * Format options, see {@see JHtml::$formatOptions}.
  58. * Selection options, see {@see JHtmlSelect::options()}.
  59. * list.attr, string|array: Additional attributes for the select
  60. * element.
  61. * id, string: Value to use as the select element id attribute.
  62. * Defaults to the same as the name.
  63. * list.select, string|array: Identifies one or more option elements
  64. * to be selected, based on the option key values.
  65. * @param string $optKey The name of the object variable for the option value. If
  66. * set to null, the index of the value array is used.
  67. * @param string $optText The name of the object variable for the option text.
  68. * @param mixed $selected The key that is selected (accepts an array or a string).
  69. * @param mixed $idtag Value of the field id or null by default
  70. * @param boolean $translate True to translate
  71. *
  72. * @return string HTML for the select list.
  73. *
  74. * @since 11.1
  75. */
  76. public static function genericlist($data, $name, $attribs = null, $optKey = 'value', $optText = 'text', $selected = null, $idtag = false,
  77. $translate = false)
  78. {
  79. // Set default options
  80. $options = array_merge(JHtml::$formatOptions, array('format.depth' => 0, 'id' => false));
  81. if (is_array($attribs) && func_num_args() == 3)
  82. {
  83. // Assume we have an options array
  84. $options = array_merge($options, $attribs);
  85. }
  86. else
  87. {
  88. // Get options from the parameters
  89. $options['id'] = $idtag;
  90. $options['list.attr'] = $attribs;
  91. $options['list.translate'] = $translate;
  92. $options['option.key'] = $optKey;
  93. $options['option.text'] = $optText;
  94. $options['list.select'] = $selected;
  95. }
  96. $attribs = '';
  97. if (isset($options['list.attr']))
  98. {
  99. if (is_array($options['list.attr']))
  100. {
  101. $attribs = JArrayHelper::toString($options['list.attr']);
  102. }
  103. else
  104. {
  105. $attribs = $options['list.attr'];
  106. }
  107. if ($attribs != '')
  108. {
  109. $attribs = ' ' . $attribs;
  110. }
  111. }
  112. $id = $options['id'] !== false ? $options['id'] : $name;
  113. $id = str_replace(array('[', ']'), '', $id);
  114. $baseIndent = str_repeat($options['format.indent'], $options['format.depth']++);
  115. $html = $baseIndent . '<select' . ($id !== '' ? ' id="' . $id . '"' : '') . ' name="' . $name . '"' . $attribs . '>' . $options['format.eol']
  116. . self::options($data, $options) . $baseIndent . '</select>' . $options['format.eol'];
  117. return $html;
  118. }
  119. /**
  120. * Generates a grouped HTML selection list from nested arrays.
  121. *
  122. * @param array $data An array of groups, each of which is an array of options.
  123. * @param string $name The value of the HTML name attribute
  124. * @param array $options Options, an array of key/value pairs. Valid options are:
  125. * Format options, {@see JHtml::$formatOptions}.
  126. * Selection options. See {@see JHtmlSelect::options()}.
  127. * group.id: The property in each group to use as the group id
  128. * attribute. Defaults to none.
  129. * group.label: The property in each group to use as the group
  130. * label. Defaults to "text". If set to null, the data array index key is
  131. * used.
  132. * group.items: The property in each group to use as the array of
  133. * items in the group. Defaults to "items". If set to null, group.id and
  134. * group. label are forced to null and the data element is assumed to be a
  135. * list of selections.
  136. * id: Value to use as the select element id attribute. Defaults to
  137. * the same as the name.
  138. * list.attr: Attributes for the select element. Can be a string or
  139. * an array of key/value pairs. Defaults to none.
  140. * list.select: either the value of one selected option or an array
  141. * of selected options. Default: none.
  142. * list.translate: Boolean. If set, text and labels are translated via
  143. * JText::_().
  144. *
  145. * @return string HTML for the select list
  146. *
  147. * @since 11.1
  148. *
  149. * @throws RuntimeException If a group has contents that cannot be processed.
  150. */
  151. public static function groupedlist($data, $name, $options = array())
  152. {
  153. // Set default options and overwrite with anything passed in
  154. $options = array_merge(
  155. JHtml::$formatOptions,
  156. array('format.depth' => 0, 'group.items' => 'items', 'group.label' => 'text', 'group.label.toHtml' => true, 'id' => false),
  157. $options
  158. );
  159. // Apply option rules
  160. if ($options['group.items'] === null)
  161. {
  162. $options['group.label'] = null;
  163. }
  164. $attribs = '';
  165. if (isset($options['list.attr']))
  166. {
  167. if (is_array($options['list.attr']))
  168. {
  169. $attribs = JArrayHelper::toString($options['list.attr']);
  170. }
  171. else
  172. {
  173. $attribs = $options['list.attr'];
  174. }
  175. if ($attribs != '')
  176. {
  177. $attribs = ' ' . $attribs;
  178. }
  179. }
  180. $id = $options['id'] !== false ? $options['id'] : $name;
  181. $id = str_replace(array('[', ']'), '', $id);
  182. // Disable groups in the options.
  183. $options['groups'] = false;
  184. $baseIndent = str_repeat($options['format.indent'], $options['format.depth']++);
  185. $html = $baseIndent . '<select' . ($id !== '' ? ' id="' . $id . '"' : '') . ' name="' . $name . '"' . $attribs . '>' . $options['format.eol'];
  186. $groupIndent = str_repeat($options['format.indent'], $options['format.depth']++);
  187. foreach ($data as $dataKey => $group)
  188. {
  189. $label = $dataKey;
  190. $id = '';
  191. $noGroup = is_int($dataKey);
  192. if ($options['group.items'] == null)
  193. {
  194. // Sub-list is an associative array
  195. $subList = $group;
  196. }
  197. elseif (is_array($group))
  198. {
  199. // Sub-list is in an element of an array.
  200. $subList = $group[$options['group.items']];
  201. if (isset($group[$options['group.label']]))
  202. {
  203. $label = $group[$options['group.label']];
  204. $noGroup = false;
  205. }
  206. if (isset($options['group.id']) && isset($group[$options['group.id']]))
  207. {
  208. $id = $group[$options['group.id']];
  209. $noGroup = false;
  210. }
  211. }
  212. elseif (is_object($group))
  213. {
  214. // Sub-list is in a property of an object
  215. $subList = $group->$options['group.items'];
  216. if (isset($group->$options['group.label']))
  217. {
  218. $label = $group->$options['group.label'];
  219. $noGroup = false;
  220. }
  221. if (isset($options['group.id']) && isset($group->$options['group.id']))
  222. {
  223. $id = $group->$options['group.id'];
  224. $noGroup = false;
  225. }
  226. }
  227. else
  228. {
  229. throw new RuntimeException('Invalid group contents.', 1);
  230. }
  231. if ($noGroup)
  232. {
  233. $html .= self::options($subList, $options);
  234. }
  235. else
  236. {
  237. $html .= $groupIndent . '<optgroup' . (empty($id) ? '' : ' id="' . $id . '"') . ' label="'
  238. . ($options['group.label.toHtml'] ? htmlspecialchars($label, ENT_COMPAT, 'UTF-8') : $label) . '">' . $options['format.eol']
  239. . self::options($subList, $options) . $groupIndent . '</optgroup>' . $options['format.eol'];
  240. }
  241. }
  242. $html .= $baseIndent . '</select>' . $options['format.eol'];
  243. return $html;
  244. }
  245. /**
  246. * Generates a selection list of integers.
  247. *
  248. * @param integer $start The start integer
  249. * @param integer $end The end integer
  250. * @param integer $inc The increment
  251. * @param string $name The value of the HTML name attribute
  252. * @param mixed $attribs Additional HTML attributes for the <select> tag, an array of
  253. * attributes, or an array of options. Treated as options if it is the last
  254. * argument passed.
  255. * @param mixed $selected The key that is selected
  256. * @param string $format The printf format to be applied to the number
  257. *
  258. * @return string HTML for the select list
  259. *
  260. * @since 11.1
  261. */
  262. public static function integerlist($start, $end, $inc, $name, $attribs = null, $selected = null, $format = '')
  263. {
  264. // Set default options
  265. $options = array_merge(JHtml::$formatOptions, array('format.depth' => 0, 'option.format' => '', 'id' => null));
  266. if (is_array($attribs) && func_num_args() == 5)
  267. {
  268. // Assume we have an options array
  269. $options = array_merge($options, $attribs);
  270. // Extract the format and remove it from downstream options
  271. $format = $options['option.format'];
  272. unset($options['option.format']);
  273. }
  274. else
  275. {
  276. // Get options from the parameters
  277. $options['list.attr'] = $attribs;
  278. $options['list.select'] = $selected;
  279. }
  280. $start = (int) $start;
  281. $end = (int) $end;
  282. $inc = (int) $inc;
  283. $data = array();
  284. for ($i = $start; $i <= $end; $i += $inc)
  285. {
  286. $data[$i] = $format ? sprintf($format, $i) : $i;
  287. }
  288. // Tell genericlist() to use array keys
  289. $options['option.key'] = null;
  290. return JHtml::_('select.genericlist', $data, $name, $options);
  291. }
  292. /**
  293. * Create a placeholder for an option group.
  294. *
  295. * @param string $text The text for the option
  296. * @param string $optKey The returned object property name for the value
  297. * @param string $optText The returned object property name for the text
  298. *
  299. * @return object
  300. *
  301. * @deprecated 12.1 Use JHtmlSelect::groupedList()
  302. * @see JHtmlSelect::groupedList()
  303. * @since 11.1
  304. */
  305. public static function optgroup($text, $optKey = 'value', $optText = 'text')
  306. {
  307. JLog::add('JHtmlSelect::optgroup is deprecated.', JLog::WARNING, 'deprecated');
  308. // Set initial state
  309. static $state = 'open';
  310. // Toggle between open and close states:
  311. switch ($state)
  312. {
  313. case 'open':
  314. $obj = new stdClass;
  315. $obj->$optKey = '<OPTGROUP>';
  316. $obj->$optText = $text;
  317. $state = 'close';
  318. break;
  319. case 'close':
  320. $obj = new stdClass;
  321. $obj->$optKey = '</OPTGROUP>';
  322. $obj->$optText = $text;
  323. $state = 'open';
  324. break;
  325. }
  326. return $obj;
  327. }
  328. /**
  329. * Create an object that represents an option in an option list.
  330. *
  331. * @param string $value The value of the option
  332. * @param string $text The text for the option
  333. * @param mixed $optKey If a string, the returned object property name for
  334. * the value. If an array, options. Valid options are:
  335. * attr: String|array. Additional attributes for this option.
  336. * Defaults to none.
  337. * disable: Boolean. If set, this option is disabled.
  338. * label: String. The value for the option label.
  339. * option.attr: The property in each option array to use for
  340. * additional selection attributes. Defaults to none.
  341. * option.disable: The property that will hold the disabled state.
  342. * Defaults to "disable".
  343. * option.key: The property that will hold the selection value.
  344. * Defaults to "value".
  345. * option.label: The property in each option array to use as the
  346. * selection label attribute. If a "label" option is provided, defaults to
  347. * "label", if no label is given, defaults to null (none).
  348. * option.text: The property that will hold the the displayed text.
  349. * Defaults to "text". If set to null, the option array is assumed to be a
  350. * list of displayable scalars.
  351. * @param string $optText The property that will hold the the displayed text. This
  352. * parameter is ignored if an options array is passed.
  353. * @param boolean $disable Not used.
  354. *
  355. * @return object
  356. *
  357. * @since 11.1
  358. */
  359. public static function option($value, $text = '', $optKey = 'value', $optText = 'text', $disable = false)
  360. {
  361. $options = array('attr' => null, 'disable' => false, 'option.attr' => null, 'option.disable' => 'disable', 'option.key' => 'value',
  362. 'option.label' => null, 'option.text' => 'text');
  363. if (is_array($optKey))
  364. {
  365. // Merge in caller's options
  366. $options = array_merge($options, $optKey);
  367. }
  368. else
  369. {
  370. // Get options from the parameters
  371. $options['option.key'] = $optKey;
  372. $options['option.text'] = $optText;
  373. $options['disable'] = $disable;
  374. }
  375. $obj = new stdClass;
  376. $obj->$options['option.key'] = $value;
  377. $obj->$options['option.text'] = trim($text) ? $text : $value;
  378. /*
  379. * If a label is provided, save it. If no label is provided and there is
  380. * a label name, initialise to an empty string.
  381. */
  382. $hasProperty = $options['option.label'] !== null;
  383. if (isset($options['label']))
  384. {
  385. $labelProperty = $hasProperty ? $options['option.label'] : 'label';
  386. $obj->$labelProperty = $options['label'];
  387. }
  388. elseif ($hasProperty)
  389. {
  390. $obj->$options['option.label'] = '';
  391. }
  392. // Set attributes only if there is a property and a value
  393. if ($options['attr'] !== null)
  394. {
  395. $obj->$options['option.attr'] = $options['attr'];
  396. }
  397. // Set disable only if it has a property and a value
  398. if ($options['disable'] !== null)
  399. {
  400. $obj->$options['option.disable'] = $options['disable'];
  401. }
  402. return $obj;
  403. }
  404. /**
  405. * Generates the option tags for an HTML select list (with no select tag
  406. * surrounding the options).
  407. *
  408. * @param array $arr An array of objects, arrays, or values.
  409. * @param mixed $optKey If a string, this is the name of the object variable for
  410. * the option value. If null, the index of the array of objects is used. If
  411. * an array, this is a set of options, as key/value pairs. Valid options are:
  412. * -Format options, {@see JHtml::$formatOptions}.
  413. * -groups: Boolean. If set, looks for keys with the value
  414. * "&lt;optgroup>" and synthesizes groups from them. Deprecated. Defaults
  415. * true for backwards compatibility.
  416. * -list.select: either the value of one selected option or an array
  417. * of selected options. Default: none.
  418. * -list.translate: Boolean. If set, text and labels are translated via
  419. * JText::_(). Default is false.
  420. * -option.id: The property in each option array to use as the
  421. * selection id attribute. Defaults to none.
  422. * -option.key: The property in each option array to use as the
  423. * selection value. Defaults to "value". If set to null, the index of the
  424. * option array is used.
  425. * -option.label: The property in each option array to use as the
  426. * selection label attribute. Defaults to null (none).
  427. * -option.text: The property in each option array to use as the
  428. * displayed text. Defaults to "text". If set to null, the option array is
  429. * assumed to be a list of displayable scalars.
  430. * -option.attr: The property in each option array to use for
  431. * additional selection attributes. Defaults to none.
  432. * -option.disable: The property that will hold the disabled state.
  433. * Defaults to "disable".
  434. * -option.key: The property that will hold the selection value.
  435. * Defaults to "value".
  436. * -option.text: The property that will hold the the displayed text.
  437. * Defaults to "text". If set to null, the option array is assumed to be a
  438. * list of displayable scalars.
  439. * @param string $optText The name of the object variable for the option text.
  440. * @param mixed $selected The key that is selected (accepts an array or a string)
  441. * @param boolean $translate Translate the option values.
  442. *
  443. * @return string HTML for the select list
  444. *
  445. * @since 11.1
  446. */
  447. public static function options($arr, $optKey = 'value', $optText = 'text', $selected = null, $translate = false)
  448. {
  449. $options = array_merge(
  450. JHtml::$formatOptions,
  451. self::$optionDefaults['option'],
  452. array('format.depth' => 0, 'groups' => true, 'list.select' => null, 'list.translate' => false)
  453. );
  454. if (is_array($optKey))
  455. {
  456. // Set default options and overwrite with anything passed in
  457. $options = array_merge($options, $optKey);
  458. }
  459. else
  460. {
  461. // Get options from the parameters
  462. $options['option.key'] = $optKey;
  463. $options['option.text'] = $optText;
  464. $options['list.select'] = $selected;
  465. $options['list.translate'] = $translate;
  466. }
  467. $html = '';
  468. $baseIndent = str_repeat($options['format.indent'], $options['format.depth']);
  469. foreach ($arr as $elementKey => &$element)
  470. {
  471. $attr = '';
  472. $extra = '';
  473. $label = '';
  474. $id = '';
  475. if (is_array($element))
  476. {
  477. $key = $options['option.key'] === null ? $elementKey : $element[$options['option.key']];
  478. $text = $element[$options['option.text']];
  479. if (isset($element[$options['option.attr']]))
  480. {
  481. $attr = $element[$options['option.attr']];
  482. }
  483. if (isset($element[$options['option.id']]))
  484. {
  485. $id = $element[$options['option.id']];
  486. }
  487. if (isset($element[$options['option.label']]))
  488. {
  489. $label = $element[$options['option.label']];
  490. }
  491. if (isset($element[$options['option.disable']]) && $element[$options['option.disable']])
  492. {
  493. $extra .= ' disabled="disabled"';
  494. }
  495. }
  496. elseif (is_object($element))
  497. {
  498. $key = $options['option.key'] === null ? $elementKey : $element->$options['option.key'];
  499. $text = $element->$options['option.text'];
  500. if (isset($element->$options['option.attr']))
  501. {
  502. $attr = $element->$options['option.attr'];
  503. }
  504. if (isset($element->$options['option.id']))
  505. {
  506. $id = $element->$options['option.id'];
  507. }
  508. if (isset($element->$options['option.label']))
  509. {
  510. $label = $element->$options['option.label'];
  511. }
  512. if (isset($element->$options['option.disable']) && $element->$options['option.disable'])
  513. {
  514. $extra .= ' disabled="disabled"';
  515. }
  516. }
  517. else
  518. {
  519. // This is a simple associative array
  520. $key = $elementKey;
  521. $text = $element;
  522. }
  523. /*
  524. * The use of options that contain optgroup HTML elements was
  525. * somewhat hacked for J1.5. J1.6 introduces the grouplist() method
  526. * to handle this better. The old solution is retained through the
  527. * "groups" option, which defaults true in J1.6, but should be
  528. * deprecated at some point in the future.
  529. */
  530. $key = (string) $key;
  531. if ($options['groups'] && $key == '<OPTGROUP>')
  532. {
  533. $html .= $baseIndent . '<optgroup label="' . ($options['list.translate'] ? JText::_($text) : $text) . '">' . $options['format.eol'];
  534. $baseIndent = str_repeat($options['format.indent'], ++$options['format.depth']);
  535. }
  536. elseif ($options['groups'] && $key == '</OPTGROUP>')
  537. {
  538. $baseIndent = str_repeat($options['format.indent'], --$options['format.depth']);
  539. $html .= $baseIndent . '</optgroup>' . $options['format.eol'];
  540. }
  541. else
  542. {
  543. // If no string after hyphen - take hyphen out
  544. $splitText = explode(' - ', $text, 2);
  545. $text = $splitText[0];
  546. if (isset($splitText[1]))
  547. {
  548. $text .= ' - ' . $splitText[1];
  549. }
  550. if ($options['list.translate'] && !empty($label))
  551. {
  552. $label = JText::_($label);
  553. }
  554. if ($options['option.label.toHtml'])
  555. {
  556. $label = htmlentities($label);
  557. }
  558. if (is_array($attr))
  559. {
  560. $attr = JArrayHelper::toString($attr);
  561. }
  562. else
  563. {
  564. $attr = trim($attr);
  565. }
  566. $extra = ($id ? ' id="' . $id . '"' : '') . ($label ? ' label="' . $label . '"' : '') . ($attr ? ' ' . $attr : '') . $extra;
  567. if (is_array($options['list.select']))
  568. {
  569. foreach ($options['list.select'] as $val)
  570. {
  571. $key2 = is_object($val) ? $val->$options['option.key'] : $val;
  572. if ($key == $key2)
  573. {
  574. $extra .= ' selected="selected"';
  575. break;
  576. }
  577. }
  578. }
  579. elseif ((string) $key == (string) $options['list.select'])
  580. {
  581. $extra .= ' selected="selected"';
  582. }
  583. if ($options['list.translate'])
  584. {
  585. $text = JText::_($text);
  586. }
  587. // Generate the option, encoding as required
  588. $html .= $baseIndent . '<option value="' . ($options['option.key.toHtml'] ? htmlspecialchars($key, ENT_COMPAT, 'UTF-8') : $key) . '"'
  589. . $extra . '>';
  590. $html .= $options['option.text.toHtml'] ? htmlentities(html_entity_decode($text, ENT_COMPAT, 'UTF-8'), ENT_COMPAT, 'UTF-8') : $text;
  591. $html .= '</option>' . $options['format.eol'];
  592. }
  593. }
  594. return $html;
  595. }
  596. /**
  597. * Generates an HTML radio list.
  598. *
  599. * @param array $data An array of objects
  600. * @param string $name The value of the HTML name attribute
  601. * @param string $attribs Additional HTML attributes for the <select> tag
  602. * @param mixed $optKey The key that is selected
  603. * @param string $optText The name of the object variable for the option value
  604. * @param string $selected The name of the object variable for the option text
  605. * @param boolean $idtag Value of the field id or null by default
  606. * @param boolean $translate True if options will be translated
  607. *
  608. * @return string HTML for the select list
  609. *
  610. * @since 11.1
  611. */
  612. public static function radiolist($data, $name, $attribs = null, $optKey = 'value', $optText = 'text', $selected = null, $idtag = false,
  613. $translate = false)
  614. {
  615. reset($data);
  616. if (is_array($attribs))
  617. {
  618. $attribs = JArrayHelper::toString($attribs);
  619. }
  620. $id_text = $idtag ? $idtag : $name;
  621. $html = '<div class="controls">';
  622. foreach ($data as $obj)
  623. {
  624. $k = $obj->$optKey;
  625. $t = $translate ? JText::_($obj->$optText) : $obj->$optText;
  626. $id = (isset($obj->id) ? $obj->id : null);
  627. $extra = '';
  628. $extra .= $id ? ' id="' . $obj->id . '"' : '';
  629. if (is_array($selected))
  630. {
  631. foreach ($selected as $val)
  632. {
  633. $k2 = is_object($val) ? $val->$optKey : $val;
  634. if ($k == $k2)
  635. {
  636. $extra .= ' selected="selected"';
  637. break;
  638. }
  639. }
  640. }
  641. else
  642. {
  643. $extra .= ((string) $k == (string) $selected ? ' checked="checked"' : '');
  644. }
  645. $html .= "\n\t" . '<label for="' . $id_text . $k . '" id="' . $id_text . $k . '-lbl" class="radio">';
  646. $html .= "\n\t" . "\n\t" . '<input type="radio" name="' . $name . '" id="' . $id_text . $k . '" value="' . $k . '" ' . $extra . ' '
  647. . $attribs . '>' . $t;
  648. $html .= "\n\t" . '</label>';
  649. }
  650. $html .= '</div>';
  651. $html .= "\n";
  652. return $html;
  653. }
  654. }