File indexing completed on 2024-12-29 05:27:35

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Dojo
0017  * @subpackage View
0018  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0019  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0020  * @version    $Id$
0021  */
0022 
0023 /** Zend_Dojo_View_Helper_Dijit */
0024 // require_once 'Zend/Dojo/View/Helper/Dijit.php';
0025 
0026 /**
0027  * Dojo RadioButton dijit
0028  *
0029  * @uses       Zend_Dojo_View_Helper_Dijit
0030  * @package    Zend_Dojo
0031  * @subpackage View
0032  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0033  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0034   */
0035 class Zend_Dojo_View_Helper_RadioButton extends Zend_Dojo_View_Helper_Dijit
0036 {
0037     /**
0038      * Dijit being used
0039      * @var string
0040      */
0041     protected $_dijit  = 'dijit.form.RadioButton';
0042 
0043     /**
0044      * Dojo module to use
0045      * @var string
0046      */
0047     protected $_module = 'dijit.form.CheckBox';
0048 
0049     /**
0050      * dijit.form.RadioButton
0051      *
0052      * @param  string $id
0053      * @param  string $value
0054      * @param  array $params  Parameters to use for dijit creation
0055      * @param  array $attribs HTML attributes
0056      * @param  array $options Array of radio options
0057      * @param  string $listsep String with which to separate options
0058      * @return string
0059      */
0060     public function radioButton(
0061         $id,
0062         $value = null,
0063         array $params = array(),
0064         array $attribs = array(),
0065         array $options = null,
0066         $listsep = "<br />\n"
0067     ) {
0068         $attribs['name'] = $id;
0069         if (!array_key_exists('id', $attribs)) {
0070             $attribs['id'] = $id;
0071         }
0072         $attribs = $this->_prepareDijit($attribs, $params, 'element');
0073 
0074         if (is_array($options) && $this->_useProgrammatic() && !$this->_useProgrammaticNoScript()) {
0075             $baseId = $id;
0076             if (array_key_exists('id', $attribs)) {
0077                 $baseId = $attribs['id'];
0078             }
0079             // require_once 'Zend/Filter/Alnum.php';
0080             $filter = new Zend_Filter_Alnum();
0081             foreach (array_keys($options) as $key) {
0082                 $optId = $baseId . '-' . $filter->filter($key);
0083                 $this->_createDijit($this->_dijit, $optId, array());
0084             }
0085         }
0086 
0087         return $this->view->formRadio($id, $value, $attribs, $options, $listsep);
0088     }
0089 }