diff -r 5b37998e522e -r 162c1de6545a web/lib/Zend/Dojo/View/Helper/ComboBox.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/web/lib/Zend/Dojo/View/Helper/ComboBox.php Fri Mar 11 15:05:35 2011 +0100 @@ -0,0 +1,151 @@ +_renderStore($params['store'], $id))) { + $params['store'] = $params['store']['store']; + if (is_string($store)) { + $html .= $store; + } + $html .= $this->_createFormElement($id, $value, $params, $attribs); + return $html; + } + unset($params['store']); + } elseif (array_key_exists('store', $params)) { + if (array_key_exists('storeType', $params)) { + $storeParams = array( + 'store' => $params['store'], + 'type' => $params['storeType'], + ); + unset($params['storeType']); + if (array_key_exists('storeParams', $params)) { + $storeParams['params'] = $params['storeParams']; + unset($params['storeParams']); + } + if (false !== ($store = $this->_renderStore($storeParams, $id))) { + if (is_string($store)) { + $html .= $store; + } + } + } + $html .= $this->_createFormElement($id, $value, $params, $attribs); + return $html; + } + + // do as normal select + $attribs = $this->_prepareDijit($attribs, $params, 'element'); + return $this->view->formSelect($id, $value, $attribs, $options); + } + + /** + * Render data store element + * + * Renders to dojo view helper + * + * @param array $params + * @return string|false + */ + protected function _renderStore(array $params, $id) + { + if (!array_key_exists('store', $params) || !array_key_exists('type', $params)) { + return false; + } + + $this->dojo->requireModule($params['type']); + + $extraParams = array(); + $storeParams = array( + 'dojoType' => $params['type'], + 'jsId' => $params['store'], + ); + + if (array_key_exists('params', $params)) { + $storeParams = array_merge($storeParams, $params['params']); + $extraParams = $params['params']; + } + + if ($this->_useProgrammatic()) { + if (!$this->_useProgrammaticNoScript()) { + require_once 'Zend/Json.php'; + $this->dojo->addJavascript('var ' . $storeParams['jsId'] . ";\n"); + $js = $storeParams['jsId'] . ' = ' + . 'new ' . $storeParams['dojoType'] . '(' + . Zend_Json::encode($extraParams) + . ");\n"; + $js = "function() {\n$js\n}"; + $this->dojo->_addZendLoad($js); + } + return true; + } + + return '_htmlAttribs($storeParams) . '>'; + } +}