RadioButton.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Dojo
  17. * @subpackage View
  18. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /** Zend_Dojo_View_Helper_Dijit */
  23. require_once 'Zend/Dojo/View/Helper/Dijit.php';
  24. /**
  25. * Dojo RadioButton dijit
  26. *
  27. * @uses Zend_Dojo_View_Helper_Dijit
  28. * @package Zend_Dojo
  29. * @subpackage View
  30. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  31. * @license http://framework.zend.com/license/new-bsd New BSD License
  32. */
  33. class Zend_Dojo_View_Helper_RadioButton extends Zend_Dojo_View_Helper_Dijit
  34. {
  35. /**
  36. * Dijit being used
  37. * @var string
  38. */
  39. protected $_dijit = 'dijit.form.RadioButton';
  40. /**
  41. * Dojo module to use
  42. * @var string
  43. */
  44. protected $_module = 'dijit.form.CheckBox';
  45. /**
  46. * dijit.form.RadioButton
  47. *
  48. * @param string $id
  49. * @param string $value
  50. * @param array $params Parameters to use for dijit creation
  51. * @param array $attribs HTML attributes
  52. * @param array $options Array of radio options
  53. * @param string $listsep String with which to separate options
  54. * @return string
  55. */
  56. public function radioButton(
  57. $id,
  58. $value = null,
  59. array $params = array(),
  60. array $attribs = array(),
  61. array $options = null,
  62. $listsep = "<br />\n"
  63. ) {
  64. $attribs['name'] = $id;
  65. if (!array_key_exists('id', $attribs)) {
  66. $attribs['id'] = $id;
  67. }
  68. $attribs = $this->_prepareDijit($attribs, $params, 'element');
  69. if (is_array($options) && $this->_useProgrammatic() && !$this->_useProgrammaticNoScript()) {
  70. $baseId = $id;
  71. if (array_key_exists('id', $attribs)) {
  72. $baseId = $attribs['id'];
  73. }
  74. require_once 'Zend/Filter/Alnum.php';
  75. $filter = new Zend_Filter_Alnum();
  76. foreach (array_keys($options) as $key) {
  77. $optId = $baseId . '-' . $filter->filter($key);
  78. $this->_createDijit($this->_dijit, $optId, array());
  79. }
  80. }
  81. return $this->view->formRadio($id, $value, $attribs, $options, $listsep);
  82. }
  83. }