public function testGetViewScriptWithNoControllerSet() { $this->request->setModuleName('bar')->setControllerName('index')->setActionName('test'); $controller = new Bar_IndexController($this->request, $this->response, array()); $this->helper->setNoController(); $expected = 'test.phtml'; $this->assertEquals($expected, $this->helper->getViewScript()); }
/** * 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); }
{ throw new Exception("CANT_WRITE Can't write to directory " . $smarty_view_compiles); } if (!is_writable($smarty_cache_dir)) { throw new Exception("CANT_WRITE Can't write to directory " . $smarty_cache_dir); } $smarty_config_array['compile_dir'] = $smarty_view_compiles; $smarty_config_array['cache_dir'] = $smarty_cache_dir; } $smarty_config_array['plugins_dir'] = $smarty_plugins_dirs; Zend_Registry::set('smarty_config', $smarty_config_array); $view = new RivetyCore_View_Renderer(null, $smarty_config_array); $view_renderer = new Zend_Controller_Action_Helper_ViewRenderer($view); $view_renderer ->setNoController(true) ->setViewBasePathSpec($theme_locations['frontend']['current_theme']['path'] . '/tpl_controllers/:module') ->setViewScriptPathSpec(':controller/:action.:suffix') ->setViewScriptPathNoControllerSpec(':action.:suffix') ->setViewSuffix('tpl'); Zend_Controller_Action_HelperBroker::addHelper($view_renderer); if ($isInstalled) { $front->registerPlugin(new AclPlugin); $params = array('front_controller' => $front); $RivetyCore_plugin->doAction('bootstrap', $params); // ACTION HOOK } else { $front->registerPlugin(new InstallPlugin);
} $smarty_config_array['compile_dir'] = $smarty_view_compiles; $smarty_config_array['cache_dir'] = $smarty_cache_dir; } $smarty_config_array['plugins_dir'] = $smarty_plugins_dirs; Zend_Registry::set('smarty_config', $smarty_config_array); $view = new Bolts_View_Renderer(null, $smarty_config_array); // Setup controller $front = Zend_Controller_Front::getInstance(); $front->setDefaultModule("bolts"); $front->addModuleDirectory($core_module_dir); $front->addModuleDirectory($module_dir); $front->throwExceptions(true); $front->setParam('noViewRenderer', false); $view_renderer = new Zend_Controller_Action_Helper_ViewRenderer($view); $view_renderer->setNoController(true)->setViewBasePathSpec($theme_locations['frontend']['current_theme']['path'] . '/modules/:module')->setViewScriptPathSpec(':controller/:action.:suffix')->setViewScriptPathNoControllerSpec(':action.:suffix')->setViewSuffix('tpl'); Zend_Controller_Action_HelperBroker::addHelper($view_renderer); if ($isInstalled) { $front->registerPlugin(new AclPlugin()); $Bolts_plugin->doAction('bootstrap', array('front_controller' => $front)); // ACTION HOOK } else { $front->registerPlugin(new InstallPlugin()); } $router = new Zend_Controller_Router_Rewrite(); $front->setRouter($router); if ($isInstalled) { if (Bolts_Registry::get('enable_localization') == '1') { $router->addRoute('default', new Zend_Controller_Router_Route(":locale/:module/:controller/:action/*", array('locale' => '', 'module' => "bolts", 'controller' => "index", 'action' => "index"))); } else { $router->addRoute('default', new Zend_Controller_Router_Route(":module/:controller/:action/*", array('module' => "bolts", 'controller' => "index", 'action' => "index")));