Exemplo n.º 1
0
 /**
  * Render a hook's content
  *
  * @param string $name template to use
  * @param string $module module to fetch template from
  * @param string $controller controller to fetch template from, defaults to 'hooks'
  *
  * @return string Rendered content
  *
  */
 public function render($name, $module, $controller = "hooks")
 {
     $layout = Zend_Layout::getMvcInstance();
     // Reset view script paths
     $this->view->setScriptPath(null);
     // Build new ones for hooks
     $this->view->addBasePath(ZfApplication::$_base_path . "/app/{$module}/views", $module . "_View");
     //$this->view->addScriptPath(ZfApplication::$_base_path."/app/$module/Views/");
     $this->view->addScriptPath($layout->getLayoutPath() . "default/templates/{$module}");
     $this->view->addScriptPath($layout->getLayoutPath() . $layout->getLayout() . "/templates/{$module}");
     return $this->view->render($controller . "/" . $name);
 }
Exemplo n.º 2
0
 /**
  * Tries to render a delegate action's default template if it exists.
  *
  * Because we can't always know the short name of a delegate (like we can
  * with a controller), the default view spec of :controller/:action:suffix
  * won't work for us. This means we can't just prepend our default paths to
  * the view script paths. Instead, this function changes the viewRenderer
  * spec to just :action:suffix, puts in the default dirs, tries to render
  * and then flips back the settings afterwards. 
  *
  * @todo Ugly, needs refactoring
  * @param Zend_Controller_Action_Helper_ViewRenderer $viewRenderer
  * @param Zend_View_Abstract $view
  * @param string $action Name of the action, without the "Action" suffix
  */
 protected function _renderDefaultScript($viewRenderer, $view, $action)
 {
     //No settings? Abort to save cycles
     $defaultPaths = $this->getDefaultScriptPaths();
     if (empty($defaultPaths)) {
         return;
     }
     //Save the old settings
     $oldSpec = $viewRenderer->getNoController();
     $oldPaths = $view->getScriptPaths();
     //Set the viewrenderer spec to look inside a flat directory
     $viewRenderer->setNoController(true);
     $view->setScriptPath($defaultPaths);
     $path = $viewRenderer->getViewScript($action);
     //relative path
     $fullPath = $view->getScriptPath($path);
     //absolute path
     //We use the full path to make sure this template actually exists on
     //disc but Zend_View will only accept a path relative to a script dir.
     if (!empty($fullPath) !== false) {
         $viewRenderer->renderScript($path);
     }
     //Reset view settings so we don't botch anything afterwards?
     $viewRenderer->setNoController($oldSpec);
     $view->setScriptPath($oldPaths);
 }
Exemplo n.º 3
0
 public function setScriptPath($path)
 {
     $this->_pathSet = false;
     return parent::setScriptPath($path);
 }
Exemplo n.º 4
0
 /**
  * Reset the view's script paths and set new ones for use in the block
  *
  * @param Zend_View_Abstract $view
  */
 private function resetViewScripts(Zend_View_Abstract $view)
 {
     $layout = Zend_Layout::getMvcInstance();
     // Reset view script paths
     $view->setScriptPath(null);
     $module = ucfirst($this->module);
     // Build new ones for blocks
     $view->addBasePath(ZfApplication::$_base_path . "/app/{$module}/views", $module . "_View");
     $view->addScriptPath(ZfApplication::$_base_path . "/app/{$module}/views/scripts/blocks");
     $view->addScriptPath($layout->getLayoutPath() . "default/templates/blocks");
     $view->addScriptPath($layout->getLayoutPath() . "default/templates/{$module}/blocks");
     $view->addScriptPath($layout->getLayoutPath() . $layout->getLayout() . "/templates/blocks");
     $view->addScriptPath($layout->getLayoutPath() . $layout->getLayout() . "/templates/{$module}/blocks");
 }