All pastes #520398 Raw Edit

Something

public php v1 · immutable
#520398 ·published 2007-05-29 22:31 UTC
rendered paste body
<?php class MySouth_Controller_Plugin_Template extends Zend_Controller_Plugin_Abstract {        static protected $_allowedTemplates = array('main');        /**     * View     *     * @var Zend_View     */    protected $_view = null;        /**     * Template Directory     *     * @param Zend_View $view     */    protected $_templateDirectory = null;        public function __construct(Zend_View $view, $templateDirectory)    {        $this->_view = $view;        $this->_templateDirectory = $templateDirectory;    }        public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)    {        // set default variables for this template so E-NOTICE doesnt complain        $this->_view->user                  = Zend_Auth::getInstance()->getIdentity();        $this->_view->allowed_templates     = array();        $this->_view->javascripts           = array();        $this->_view->styles                = array();        $this->_view->styles_conditionals   = array();        $this->_view->dojodebug             = false;        $this->_view->dojoinits             = array();        $this->_view->dojowidgetids         = array();        $this->_view->dojorequires          = array();        $this->_view->dojostyles            = array();    }        public function dispatchLoopShutdown()    {        $view_template = $this->getRequest()->getParam('template', 'main'); // view param from url        $view_template = ( ($view_template != 'main') && (in_array($view_template, $this->_view->allowed_templates)) ) ? $view_template : 'main';                // get flash messages & pass to view        $messenger = new FlashMessenger();        $this->_view->messages = $messenger->getMessages();        $this->_view->content  = $this->_response->getBody();                // set since this is our last usage of view        $this->_view->setScriptPath($this->_templateDirectory);                try {                        switch ($view_template) {                case 'json':                    $this->_response->setHeader('content-type', 'text/x-json');                    break;                case 'dialog':                    $this->_response->setBody($this->_view->render('dialog.phtml'));                    break;                default:                    $this->_response->setBody($this->_view->render('main.phtml'));                    break;            }                } catch (Exception $e) {            die($e->getMessage());        }        return;    }}