/** * Render dojo module paths and requires * * @return string */ protected function _renderExtras() { $js = array(); $modulePaths = $this->getModulePaths(); if (!empty($modulePaths)) { foreach ($modulePaths as $module => $path) { $js[] = 'dojo.registerModulePath("' . $this->view->vars()->escape($module) . '", "' . $this->view->vars()->escape($path) . '");'; } } $modules = $this->getModules(); if (!empty($modules)) { foreach ($modules as $module) { $js[] = 'dojo.require("' . $this->view->vars()->escape($module) . '");'; } } $onLoadActions = array(); // Get Zend specific onLoad actions; these will always be first to // ensure that dijits are created in the correct order foreach ($this->_getZendLoadActions() as $callback) { $onLoadActions[] = 'dojo.addOnLoad(' . $callback . ');'; } // Get all other onLoad actions foreach ($this->getOnLoadActions() as $callback) { $onLoadActions[] = 'dojo.addOnLoad(' . $callback . ');'; } $javascript = implode("\n ", $this->getJavascript()); $content = ''; if (!empty($js)) { $content .= implode("\n ", $js) . "\n"; } if (!empty($onLoadActions)) { $content .= implode("\n ", $onLoadActions) . "\n"; } if (!empty($javascript)) { $content .= $javascript . "\n"; } if (preg_match('/^\\s*$/s', $content)) { return ''; } $html = '<script type="text/javascript">' . PHP_EOL . ($this->_isXhtml ? '//<![CDATA[' : '//<!--') . PHP_EOL . $content . ($this->_isXhtml ? '//]]>' : '//-->') . PHP_EOL . PHP_EOL . '</script>'; return $html; }
/** * Render element label * * @param \Zend\Form\Element $element * @param \Zend\View\Renderer $view * @return string */ public function renderLabel(Form\Element $element, View $view) { $label = $element->getLabel(); if (empty($label)) { $label = $element->getName(); } return $this->getMarkupElementLabelStart() . $view->vars()->escape($label) . $this->getMarkupElementLabelEnd(); }