web/lib/Zend/Dojo/View/Helper/RadioButton.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     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-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    20  * @version    $Id: RadioButton.php 20096 2010-01-06 02:05:09Z bkarwin $
       
    21  */
       
    22 
       
    23 /** Zend_Dojo_View_Helper_Dijit */
       
    24 require_once 'Zend/Dojo/View/Helper/Dijit.php';
       
    25 
       
    26 /**
       
    27  * Dojo RadioButton dijit
       
    28  *
       
    29  * @uses       Zend_Dojo_View_Helper_Dijit
       
    30  * @package    Zend_Dojo
       
    31  * @subpackage View
       
    32  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    33  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    34   */
       
    35 class Zend_Dojo_View_Helper_RadioButton extends Zend_Dojo_View_Helper_Dijit
       
    36 {
       
    37     /**
       
    38      * Dijit being used
       
    39      * @var string
       
    40      */
       
    41     protected $_dijit  = 'dijit.form.RadioButton';
       
    42 
       
    43     /**
       
    44      * Dojo module to use
       
    45      * @var string
       
    46      */
       
    47     protected $_module = 'dijit.form.CheckBox';
       
    48 
       
    49     /**
       
    50      * dijit.form.RadioButton
       
    51      *
       
    52      * @param  string $id
       
    53      * @param  string $value
       
    54      * @param  array $params  Parameters to use for dijit creation
       
    55      * @param  array $attribs HTML attributes
       
    56      * @param  array $options Array of radio options
       
    57      * @param  string $listsep String with which to separate options
       
    58      * @return string
       
    59      */
       
    60     public function radioButton(
       
    61         $id,
       
    62         $value = null,
       
    63         array $params = array(),
       
    64         array $attribs = array(),
       
    65         array $options = null,
       
    66         $listsep = "<br />\n"
       
    67     ) {
       
    68         $attribs['name'] = $id;
       
    69         if (!array_key_exists('id', $attribs)) {
       
    70             $attribs['id'] = $id;
       
    71         }
       
    72         $attribs = $this->_prepareDijit($attribs, $params, 'element');
       
    73 
       
    74         if (is_array($options) && $this->_useProgrammatic() && !$this->_useProgrammaticNoScript()) {
       
    75             $baseId = $id;
       
    76             if (array_key_exists('id', $attribs)) {
       
    77                 $baseId = $attribs['id'];
       
    78             }
       
    79             require_once 'Zend/Filter/Alnum.php';
       
    80             $filter = new Zend_Filter_Alnum();
       
    81             foreach (array_keys($options) as $key) {
       
    82                 $optId = $baseId . '-' . $filter->filter($key);
       
    83                 $this->_createDijit($this->_dijit, $optId, array());
       
    84             }
       
    85         }
       
    86 
       
    87         return $this->view->formRadio($id, $value, $attribs, $options, $listsep);
       
    88     }
       
    89 }