public function preDispatch(\Zend_Controller_Request_Http $request)
 {
     parent::preDispatch($request);
     if (Tool::isRequestToAdminBackend($request) && !Tool::isDomainAllowedToAdminBackend($request)) {
         $this->handleErrorPage();
     }
 }
Пример #2
0
 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     parent::routeStartup($request);
     /**
      * 
      * Отключение плагинов Evil_Acces && Evil_Auth 
      * для экономии запросов, при сливе любого трафика на определенные контроллеры
      * Например это нужно чтоб считать какуюнить левую анонимную статистику и не засирать бд
      * ну и для той цели которая нужна мне)
      * @author NuR
      */
     $config = Zend_Registry::get('config');
     $ingore = Evil_Array::get('evil.auth.ignoreControllers', $config);
     if (is_array($ingore)) {
         if (in_array($request->getControllerName(), $ingore)) {
             return null;
         }
     }
     $this->init();
     if (Zend_Controller_Front::getInstance()->getDispatcher()->isDispatchable($request)) {
         if ($this->denied($request->getParam('id'), $request->getControllerName(), $request->getActionName())) {
             /**
              * я считаю что так будет лучше
              * @author NuR
              */
             $this->_response->setRedirect('/');
             //	throw new Evil_Exception ( 'Access Denied for ' . $request->getControllerName () . '::' . $request->getActionName (), 403 );
         }
     } else {
         throw new Evil_Exception('Not found ' . $request->getControllerName() . '::' . $request->getActionName(), 404);
     }
 }
Пример #3
0
 public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
 {
     $layout = Zend_Layout::startMvc();
     $layout->setLayoutPath(APP_PATH . '/default/views/scripts/layouts');
     $layout->setLayout('default');
     parent::dispatchLoopShutdown();
 }
Пример #4
0
 public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
 {
     $file = APP_PATH . '/' . $this->getRequest()->getModuleName() . '/views/scripts/layouts';
     $layout = Zend_Layout::startMvc();
     $layout->setLayoutPath(file_exists($file) ? $file : APP_PATH . '/default/views/scripts/layouts');
     $layout->setLayout('default');
     parent::dispatchLoopShutdown();
 }
Пример #5
0
 public function __construct($options = null)
 {
     $this->_front_controller = Zend_Controller_Front::getInstance();
     $this->dispatcher = $dispatcher;
     // TODO $this->dispatcher->connect('task.cache.clear', array('sfDynamicsCache', 'clearSuperCache'));
     array(Dynamics_Configuration::ROUTING_SERVICE_CLASS => 'sfDynamicsRouting', Dynamics_Configuration::WEB_DIR => sfConfig::get('sf_web_dir'), Dynamics_Configuration::CACHE_SERVICE_CLASS => 'sfDynamicsSymfonyCacheAdapter', Dynamics_Configuration::CACHE_SERVICE_OPTIONS => array(array('implementation' => 'Dynamics_Cache_NoCache', 'cache_dir' => '/tmp')));
     parent::__construct($this->configuration);
 }
Пример #6
0
 /**	@brief Changement de langue.
  * 
  * Exploitation du cache de l'application pour stocker l'instance de Zend_Translate correspondant.
  * Si le cache n'est pas présent, une nouvelle instance est créée, puis stockée dans le cache de Zend_Translate.
  * 
  * @see		Controller/Plugin/Zend_Controller_Plugin_Abstract::routeShutdown()
  * @throws	exception Projet_Exception en cas d'erreur au cours de la requête.
  * @return	void.
  */
 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     parent::routeShutdown($request);
     // Récupération du paramètre de langue passée dans l'URL
     $sLocal = $this->getRequest()->getParam('language') ? $this->getRequest()->getParam('language') : self::DEFAULT_LANGUAGE;
     // Récupération du local dans une combinaison du type "fr_FR"
     $aLanguage = explode("_", $sLocal);
     $sLanguage = isset($aLanguage[0]) ? $aLanguage[0] : self::DEFAULT_LANGUAGE;
     # Récupération de "fr"
     $sCountry = isset($aLanguage[1]) ? $aLanguage[1] : self::DEFAULT_COUNTRY;
     # Récupération de "FR"
     // Fonctionnalité réalisée si le fichier de langue n'existe pas
     if (!file_exists(LANGUAGE_PATH . $sLanguage . '.ini')) {
         $sLanguage = self::DEFAULT_LANGUAGE;
     }
     // Récupération du cache de la langue en cours dans le cache de Zend_Translate
     if ((bool) APP_CACHE) {
         $oCacheTranslate = Zend_Translate::getCache();
         $oTranslate = $oCacheTranslate->load($sLanguage);
     } else {
         $oTranslate = null;
     }
     // Fonctionnalité réalisé si
     if (empty($oTranslate)) {
         // Initialisation de la langue
         try {
             // Chargement du Zend_Translate
             $oTranslate = new Zend_Translate(array('adapter' => 'ini', 'content' => LANGUAGE_PATH . $sLanguage . '.ini', 'locale' => $sLocal));
             $sFichier = LANGUAGE_PATH . $sLanguage . '.php';
             if (file_exists($sFichier)) {
                 //traduction des erreurs de formulaires
                 $oTranslate->addTranslation(array('content' => new Zend_Translate('array', $sFichier, $sLanguage)));
             }
             if ((bool) APP_CACHE) {
                 // Enregistrement de la langue dans le cache
                 $oCacheTranslate = Zend_Translate::getCache();
                 $oCacheTranslate->save($oTranslate, $sLanguage);
             }
         } catch (Exception $e) {
             if ((bool) APP_CACHE) {
                 // Suppression du cache
                 $oCacheTranslate->remove($sLanguage);
             }
             // Création d'une exception au niveau du projet
             die($e->getMessage());
             throw new Projet_Exception($e->getMessage(), __METHOD__, $e);
         }
     }
     // Enregistrement du Zend_Translate dans les fonctionnalités de l'application
     Zend_Registry::set("Zend_Locale", $sLocal);
     Zend_Registry::set("Zend_Translate", $oTranslate);
     // Potentiellement inutile vu la ligne précédente...
     Zend_Form::setDefaultTranslator($oTranslate);
     Zend_Validate_Abstract::setDefaultTranslator($oTranslate);
     // Language par défaut pour toutes les routes
     Zend_Controller_Front::getInstance()->getRouter()->setGlobalParam('language', $sLocal);
 }
Пример #7
0
 public function preDispatch($request)
 {
     parent::preDispatch($request);
     $this->setupStandardLoggers();
     $wizard = Zend_Controller_Action_HelperBroker::getStaticHelper('Wizard');
     $pl = $this;
     // domknięcie uruchamiającę metodę dispatchLoopShutdown() przy przekierowaniu w wizardzie
     $wizard->registerPreRedirectCallback(1);
 }
Пример #8
0
 public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
 {
     parent::dispatchLoopStartup($request);
     $layout = Zend_Layout::startMvc();
     /**
      * pega o nome do módulo em que está trabalhando e define o caminho do mesmo
      */
     $layout->setLayout($request->getModuleName())->setLayoutPath(APPLICATION_PATH . '/modules/' . $request->getModuleName() . '/layouts/scripts');
 }
Пример #9
0
 public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
 {
     $config = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getApplication()->getOptions();
     $file = str_replace(':module', $this->getRequest()->getModuleName(), $config['sys']['layout']);
     $layout = Zend_Layout::startMvc();
     $layout->setLayoutPath(file_exists($file) ? $file : str_replace(':module', 'default', $config['sys']['layout']));
     $layout->setLayout('default');
     parent::dispatchLoopShutdown();
 }
Пример #10
0
 public function preDispatch(\Zend_Controller_Request_Abstract $request)
 {
     $this->hasIdentity();
     if (!$this->_hasIdentity) {
         $request->setControllerName('auth');
         $request->setActionName('login');
         $request->setDispatched();
     }
     parent::preDispatch($request);
 }
 public function preDispatch(\Zend_Controller_Request_Abstract $request)
 {
     parent::preDispatch($request);
     /** @var \Pimcore\Controller\Action\Helper\ViewRenderer $renderer */
     $renderer = \Zend_Controller_Action_HelperBroker::getExistingHelper('ViewRenderer');
     $renderer->initView();
     /** @var \Pimcore\View $view */
     $view = $renderer->view;
     $view->addHelperPath(PIMCORE_PLUGINS_PATH . '/LuceneSearch/lib/LuceneSearch/Helper/View', 'LuceneSearch\\Helper\\View');
 }
Пример #12
0
 public function postDispatch(Zend_Controller_Request_Abstract $request)
 {
     $this->_view = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view');
     $response = $this->getResponse();
     $body = $response->getBody();
     $messages = new Agana_View_Helper_FlashMessages();
     $messages = $messages->flashMessages();
     $response->setBody($messages);
     $response->appendBody($body);
     parent::postDispatch($request);
 }
Пример #13
0
 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     parent::routeStartup($request);
     $config = Zend_Registry::get('config');
     $ingore = Evil_Array::get('evil.auth.ignoreControllers', $config);
     if (is_array($ingore)) {
         if (in_array($request->getControllerName(), $ingore)) {
             return null;
         }
     }
     $this->init();
     $this->audit();
 }
Пример #14
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $layout = Zend_Layout::getMvcInstance();
     $layoutsDir = $layout->getLayoutPath();
     $bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
     $config = $bootstrap->getOptions();
     if (file_exists($layoutsDir . '_layouts' . DIRECTORY_SEPARATOR . 'brands' . DIRECTORY_SEPARATOR . strtolower($config['brand']['name']) . DIRECTORY_SEPARATOR . "layout.phtml")) {
         $layout->setLayout('_layouts' . DIRECTORY_SEPARATOR . 'brands' . DIRECTORY_SEPARATOR . strtolower($config['brand']['name']) . DIRECTORY_SEPARATOR . "layout");
     } else {
         $layout->setLayout('_layouts' . DIRECTORY_SEPARATOR . "layout");
     }
     parent::preDispatch($request);
 }
Пример #15
0
 /**
  * @param Zend_Controller_Request_Abstract $request 
  */
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     parent::preDispatch($request);
     $action = $request->getActionName();
     $controller = $request->getControllerName();
     $view = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer')->view;
     $bootstrap = Zend_Controller_Front::getInstance()->getParam('bootstrap');
     $siteOptions = $bootstrap->getOption('site');
     $view->headScript()->appendFile('/js/jquery.min.js');
     $view->headLink()->appendStylesheet('/css/style.css');
     $view->headTitle($siteOptions['default']['title'], 'SET');
     $view->action = $action;
     $view->controller = $controller;
 }
Пример #16
0
 public function postDispatch(Zend_Controller_Request_Abstract $request)
 {
     parent::postDispatch($request);
     if ($this->_active) {
         // get the front controller plugin and the zend error handler
         $front = Zend_Controller_Front::getInstance();
         $error = $front->getPlugin('Daiquiri_Controller_Plugin_ErrorHandler');
         // check if an exception is present
         if (!$error->getResponse()->isException()) {
             // destroy the session
             Zend_Session::destroy();
         }
     }
 }
Пример #17
0
 public function postDispatch(\Zend_Controller_Request_Abstract $request)
 {
     parent::postDispatch($request);
     $layout = \Zend_Layout::getMvcInstance();
     if ($layout && $layout->isEnabled() !== FALSE) {
         \Pimcore::getEventManager()->attach('toolbox.addAsset', function (\Zend_EventManager_Event $e) {
             $assetHandler = $e->getTarget();
             $assetHandler->appendScript('toolbox-wysiwyg', '/plugins/Toolbox/static/js/wysiwyg.js', array(), array('showInFrontEnd' => false));
             $assetHandler->appendScript('toolbox-parallax', '/plugins/Toolbox/static/js/frontend/jquery.parallax-scroll.min.js', array(), array('showInFrontEnd' => true));
             $assetHandler->appendScript('vimeo-api', '/plugins/Toolbox/static/js/frontend/vimeo-api.min.js', array(), array('showInFrontEnd' => true));
             $assetHandler->appendScript('toolbox-frontend', '/plugins/Toolbox/static/js/frontend/toolbox.js', array(), array('showInFrontEnd' => true));
         });
     }
 }
Пример #18
0
 /**
  * @brief   preDispatch method - called by Front Controller before dispatch
  * @param   Zend_Controller_Request_Abstract $request: request object
  * 
  * Checks whether HTTP/1.1 header contains 'Accept' and it is set to
  * 'application/json' or 'application/html'. Disables the layout. For JSON it 
  * disables also the redering of the view.
  */
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     parent::preDispatch($request);
     // get the accept  headers
     $this->_header = $request->getHeader('Accept');
     if (in_array($this->_header, array('application/json', 'application/html'))) {
         // disable layout
         $layout = Zend_Controller_Action_HelperBroker::getExistingHelper('Layout');
         $layout->disableLayout();
         if ($this->_header === 'application/json') {
             $viewRenderer = Zend_Controller_Action_HelperBroker::getExistingHelper('viewRenderer');
             $viewRenderer->setNeverRender(true);
         }
     }
 }
Пример #19
0
 public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
 {
     parent::dispatchLoopStartup($request);
     $id = Zend_Session::getId();
     $cm = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('cachemanager');
     $standard_cache = $cm->getCache('standardcache');
     $rq = $standard_cache->load($id . '_cache');
     if (is_array($rq)) {
         $cm = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('cachemanager');
         $request_cache = $cm->getCache('requestcache');
         foreach ($rq as $cacheName) {
             $request_cache->remove($cacheName);
         }
     }
 }
Пример #20
0
 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     $layout = Zend_Layout::getMvcInstance();
     $layoutConfig = Zend_Json::decode(file_get_contents(APPLICATION_PATH . '/configs/layout.json'), true);
     $layoutName = 'layout';
     if (isset($layoutConfig[$request->getControllerName()])) {
         if (is_array($layoutConfig[$request->getControllerName()]) && isset($layoutConfig[$request->getControllerName()][$request->getActionName()])) {
             $layoutName = $layoutConfig[$request->getControllerName()][$request->getActionName()];
         } else {
             $layoutName = $layoutConfig[$request->getControllerName()];
         }
     }
     $layout->setLayout('layouts/' . $layoutName);
     parent::routeShutdown($request);
 }
Пример #21
0
 /**
  * 
  */
 protected function _setBreadCrumb()
 {
     $currentModule = $this->_request->getModuleName();
     if ('default' == $currentModule) {
         return false;
     }
     if (empty($this->_modulesName[$currentModule])) {
         return false;
     }
     $view = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view');
     $view->breadcrumb()->addStep(array('label' => $this->_modulesName[$currentModule], 'url' => $currentModule));
     if ($currentModule == 'report') {
         $view = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('view');
         $view->headScript()->appendFile($view->baseUrl('public/scripts/app/report.js'));
     }
 }
Пример #22
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $storage = Zend_Auth::getInstance()->getStorage();
     if ($storage->isEmpty()) {
         $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/auth.ini');
         $currentController = $request->getControllerName();
         foreach ($config->auth->adminControllers as $adminController) {
             if (strtolower($adminController) == $currentController) {
                 // FORM login
                 $request->setControllerName('Login');
                 $request->setActionName('index');
             }
         }
     }
     return parent::preDispatch($request);
 }
Пример #23
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     parent::preDispatch($request);
     $Zrt = new Zend_Session_Namespace('Zrt');
     if (!isset($Zrt->config->lang)) {
         $zl = new Zend_Locale();
         $Zrt->config->lang = $zl->getLanguage();
     }
     if ($Zrt->config->lang !== 'en' && $Zrt->config->lang !== 'de' && $Zrt->config->lang !== 'es' && $Zrt->config->lang !== 'pl') {
         $Zrt->config->lang = 'en';
     }
     if (!isset($Zrt->config->idlang)) {
         $_idioma = new Zrt_Models_Bussines_Idioma();
         $Zrt->config->idlang = $_idioma->getByPrefijo($Zrt->config->lang)->id;
     }
     $translate = new Zend_Translate(Zend_Translate::AN_GETTEXT, APPLICATION_PATH . '/configs/locale/', $Zrt->config->lang, array('scan' => Zend_Translate::LOCALE_FILENAME), $Zrt->config->lang);
     Zend_Registry::set('Zend_Translate', $translate);
     /* translate para Zend_Validate */
     $translator = new Zend_Translate(Zend_Translate::AN_ARRAY, APPLICATION_PATH . '/configs/resources/languages/', $Zrt->config->lang, array('scan' => Zend_Translate::LOCALE_DIRECTORY));
     Zend_Validate_Abstract::setDefaultTranslator($translator);
     /*         * variables para la vista* */
     $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
     if (null === $viewRenderer->view) {
         $viewRenderer->initView();
     }
     $view = $viewRenderer->view;
     $view->assign('sessionZrt', $Zrt);
     /*         * variables para la vista* */
     /* translate para Zend_Validate */
     /* formulario idioma */
     /* fixme formulario idiomapais */
     //        $data = array( );
     //        if ( isset( $Zrt->config->lang ) )
     //            {
     //            if ( isset( $Zrt->config->idlang ) )
     //                {
     //                $data['idioma'] = $Zrt->config->idlang;
     //                }
     //            if ( isset( $Zrt->config->idpais ) )
     //                {
     //                $data['pais'] = $Zrt->config->idpais;
     //                }
     //            }
     /**/
     /* formulario idioma */
 }
Пример #24
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     parent::preDispatch($request);
     $Zrt = new Zend_Session_Namespace('Zrt');
     $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
     if (null === $viewRenderer->view) {
         $viewRenderer->initView();
     }
     $view = $viewRenderer->view;
     if (!isset($Zrt->currency->id)) {
         $Zrt->currency->id = 1;
     }
     if (!isset($Zrt->currency->code)) {
         $Zrt->currency->code = "CH";
     }
     if (!isset($Zrt->currency->codeGoogle)) {
         $Zrt->currency->codeGoogle = "CHF";
     }
     $view->assign('formCurrency', new Zrt_Form_Currency(array('data' => array('moneda_id' => $Zrt->currency->id))));
     $view->assign('currency', $Zrt->currency);
 }
Пример #25
0
 public function postDispatch(\Zend_Controller_Request_Abstract $request)
 {
     $allowRequestLog = true;
     if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
         if (in_array($_SERVER['HTTP_X_FORWARDED_FOR'], $this->restrictedIP)) {
             $allowRequestLog = false;
         }
     }
     if ($allowRequestLog) {
         parent::postDispatch($request);
         try {
             $cm = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('Requestlogger');
             $logger = $cm->getLogObject();
             $logger->setEventItem('start_at', date("c", $_SERVER['REQUEST_TIME']));
             $logger->setEventItem('end_at', date("c", microtime(true)));
             $logger->setEventItem('execute_time', microtime(true) - $_SERVER['REQUEST_TIME']);
             $logger->log('Zakonczono wykonanie akcji', Zend_Log::INFO);
         } catch (Exception $e) {
             throw $e;
         }
     }
 }
Пример #26
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     parent::preDispatch($request);
     $acl = new Zend_Acl();
     //adding Roles
     $acl->addRole(new Zend_Acl_Role(""))->addRole(new Zend_Acl_Role("guest"), "")->addRole(new Zend_Acl_role("user"), "guest")->addRole(new Zend_Acl_role("admin"), "user");
     //Adding Resources
     $acl->add(new Zend_Acl_Resource("default"))->add(new Zend_Acl_Resource("admin"))->add(new Zend_Acl_Resource("user"))->add(new Zend_Acl_Resource("error"));
     //set up access a roles
     $acl->allow(null, array("error", "error"));
     //set up access a Guest
     $acl->allow("guest", "default");
     //access a user
     $acl->allow("user", "default");
     $acl->allow('user', 'user');
     //access of admistrator
     $acl->allow('admin', null);
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $identity = $auth->getIdentity();
         $role = strtolower($identity->role);
     } else {
         $role = 'guest';
     }
     $module = $request->module;
     $controller = $request->controller;
     $action = $request->action;
     if (!$acl->isAllowed($role, $module, $controller, $action)) {
         if ($role == 'guest' or $role === "") {
             $request->setModuleName('default');
             $request->setControllerName('usuario');
             $request->setActionName('index');
         } else {
             $request->setModuleName('default');
             $request->setControllerName("error");
             $request->setActionName("noauth");
         }
     }
 }
Пример #27
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     parent::preDispatch($request);
     $front = Zend_Controller_Front::getInstance();
     $dispatcher = $front->getDispatcher();
     $controllerClass = $dispatcher->loadClass($dispatcher->getControllerClass($request));
     $controller = new $controllerClass($request, $front->getResponse(), $front->getParams());
     $actionMethod = $dispatcher->getActionMethod($request);
     $actions = get_class_methods($controller);
     if (!$dispatcher->isDispatchable($request) || !in_array($actionMethod, $actions)) {
         return $controller->__call($request->getActionName(), $request->getParams());
     }
     $bootstrap = $front->getParam('bootstrap');
     $acl = $bootstrap->getResource('Acl');
     $user = $bootstrap->getResource('User');
     $role = empty($user) ? 'guest' : $user->role;
     $resources = $acl->getResources();
     if (!in_array($request->getControllerName(), $resources)) {
         trigger_error("Resource '{$request->getControllerName()}' doesn't match any configured resources.\n                Please, add it into acl.xml configuration file", E_USER_ERROR);
     }
     if (!$acl->isAllowed($role, $request->getControllerName(), $request->getActionName())) {
         throw new Rabotal_Exception_Access('Access denied!', 403);
     }
 }
Пример #28
0
 public function routeStartup(Zend_Controller_Request_Abstract $request)
 {
     parent::routeStartup($request);
 }
Пример #29
0
 /**
  * Set response object
  *
  * @param Zend_Controller_Response_Abstract $response
  * @return Zend_Controller_Plugin_Abstract
  */
 public function setResponse(Zend_Controller_Response_Abstract $response)
 {
     return parent::setResponse($response);
 }
Пример #30
0
 /**
  * Set response object, both for this and the boostrap class.
  *
  * If the bootstrap class has a setResponse method it is set.
  *
  * @param \Zend_Controller_Response_Abstract $response
  * @return \Zend_Controller_Plugin_Abstract
  */
 public function setResponse(\Zend_Controller_Response_Abstract $response)
 {
     $this->_escort->setResponse($response);
     return parent::setResponse($response);
 }