/** * Constructor. * * @param string $charset The charset to set for the email content. */ public function __construct($charset = 'iso-8859-1') { if (!Zend_Registry::isRegistered('Ztal_View')) { throw new Exception('No available Ztal View'); } $this->view = clone Zend_Registry::get('Ztal_View'); $this->view->layout()->disableLayout(); $this->view->setCompressWhitespace(true); parent::__construct($charset); }
/** * Pre-dispatch hook to create and install a replacement View object. * * @param Zend_Controller_Request_Abstract $request The requst object. * * @return void */ public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) { // Unregister the built-in autoloader spl_autoload_unregister(array('PHPTAL', 'autoload')); // Register the autoloader through Zend Zend_Loader_Autoloader::getInstance()->pushAutoloader(array('PHPTAL', 'autoload'), 'PHPTAL'); // We create an instance of our view wrapper and configure it // It extends Zend_View so we can configure it the same way $view = new Ztal_Tal_View($this->_options); if (Zend_Registry::isRegistered('Zend_Translate')) { //setup the translation facilities in PHPTal $translator = new Ztal_Tal_ZendTranslateTranslator($this->_options); $translator->useDomain($request->getControllerName()); $view->getEngine()->setTranslator($translator); } // Call out to an overloadable method to pickup the paths for // templates for the current module foreach ($this->_currentModuleTemplatePaths($request) as $currentPath) { $view->addTemplateRepositoryPath($currentPath); } // We configure the view renderer in order to use our PHPTAL view $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer'); $viewRenderer->setViewSuffix('phtml'); $view->layout()->setViewSuffix('phtml'); $viewRenderer->setView($view); Zend_Registry::set('Ztal_View', $view); }
/** * Revert the layout back to its previous state. * * @return void */ protected function _revertLayout() { if ($this->_layoutWasEnabled) { $this->view->layout()->enableLayout(); } }