Beispiel #1
0
 /**
  * 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->escape($module) . '", "' . $this->view->escape($path) . '");';
         }
     }
     $modules = $this->getModules();
     if (!empty($modules)) {
         foreach ($modules as $module) {
             $js[] = 'dojo.require("' . $this->view->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;
 }
Beispiel #2
0
 /**
  * Render element label
  *
  * @param  \Zend\Form\Element $element
  * @param  \Zend\View\ViewEngine $view
  * @return string
  */
 public function renderLabel(Form\Element $element, View $view)
 {
     $label = $element->getLabel();
     if (empty($label)) {
         $label = $element->getName();
     }
     return $this->getMarkupElementLabelStart() . $view->escape($label) . $this->getMarkupElementLabelEnd();
 }