本文整理汇总了PHP中Zend_Controller_Action::preDispatch方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Controller_Action::preDispatch方法的具体用法?PHP Zend_Controller_Action::preDispatch怎么用?PHP Zend_Controller_Action::preDispatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Controller_Action
的用法示例。
在下文中一共展示了Zend_Controller_Action::preDispatch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: preDispatch
public function preDispatch()
{
parent::preDispatch();
Centurion_Signal::factory('pre_dispatch')->send($this);
//TODO: temporary, implement a way in Zend_Navigation_Page_Mvc to active a page in all actions
$pages = $this->view->navigation()->findBy('uri', $this->_request->getRequestUri(), true);
if (count($pages) === 0) {
$tempPages = $this->view->navigation()->findBy('controller', $this->_request->getControllerName(), true);
$pages = array();
foreach ($tempPages as $key => $page) {
if ($page->module == $this->_request->getModuleName()) {
$pages[] = $page;
}
}
if (count($pages) === 0) {
if (Zend_Controller_Front::getInstance()->getRouter()->getCurrentRouteName() !== 'default') {
$pages = $this->view->navigation()->findBy('route', Zend_Controller_Front::getInstance()->getRouter()->getCurrentRouteName(), true);
}
}
}
foreach ($pages as $key => $page) {
$page->active = true;
$page->setActive(true);
}
}
示例2: preDispatch
/**
* Setzt alle Daten des Layouts aus den Einstellungsdateien
* @throw Zend_Controller_Dispatcher_Exception
*/
public function preDispatch()
{
parent::preDispatch();
$modulename = $this->getRequest()->getModuleName();
$this->view->modulename = $modulename;
$controllername = $this->getRequest()->getControllerName();
$this->view->controllername = $controllername;
$actionname = $this->getRequest()->getActionName();
$recordAccount = null;
if (Zend_Registry::get('Dragon_Package_Registry')->isAvailable('DragonX', 'Account') && Zend_Registry::get('Dragon_Package_Registry')->isAvailable('DragonX', 'Emailaddress')) {
$sessionNamespace = new Zend_Session_Namespace();
if (isset($sessionNamespace->sessionhash)) {
$logicSession = new DragonX_Account_Logic_Session();
try {
$recordAccount = $logicSession->getAccount($sessionNamespace->sessionhash);
$this->view->sessionhash = $sessionNamespace->sessionhash;
Zend_Registry::set('recordAccount', $recordAccount);
$this->view->recordAccount = $recordAccount;
$logicEmailaddress = new DragonX_Emailaddress_Logic_Emailaddress();
$this->view->recordEmailaddress = $logicEmailaddress->getEmailaddress($recordAccount);
$logicDeletion = new DragonX_Account_Logic_Deletion();
$recordDeletion = $logicDeletion->getDeletion($recordAccount);
if (isset($recordDeletion)) {
$this->view->recordDeletion = $recordDeletion;
}
} catch (Exception $exception) {
$sessionNamespace->unsetAll();
if ($modulename == 'homepage' && $controllername == 'account' && $actionname == 'logout') {
$this->_helper->FlashMessenger('<div class="alert alert-success">Abmeldung erfolgreich</div>');
} else {
$this->_helper->FlashMessenger('<div class="alert alert-error">Die Session ist abgelaufen. Profil muss neu angemeldet werden</div>');
}
}
}
}
$this->view->configApplication = new Dragon_Application_Config('dragon/application/application');
$modulenamearray = explode('_', $modulename);
$controllerarea = end($modulenamearray);
$this->view->controllerarea = $controllerarea;
switch ($controllerarea) {
case 'homepage':
$this->view->configNavigation = new Dragon_Application_Config('dragonx/homepage/navigation/homepage');
break;
case 'administration':
if (!Zend_Registry::get('Dragon_Package_Registry')->isAvailable('DragonX', 'Account') || !Zend_Registry::get('Dragon_Package_Registry')->isAvailable('DragonX', 'Emailaddress')) {
throw new Dragon_Application_Exception_User('incorrect controller', array('controllername' => $controllername));
}
if (!isset($recordAccount)) {
$this->_helper->FlashMessenger('<div class="alert alert-error">Die Session wurde noch nicht gestartet oder ist abgelaufen. Profil muss angemeldet werden</div>');
$this->_redirect('account/showlogin?' . http_build_query(array('redirect' => $modulename . '/' . $controllername . '/' . $actionname)));
}
if (Zend_Registry::get('Dragon_Package_Registry')->isAvailable('DragonX', 'Acl')) {
$logicAcl = new DragonX_Acl_Logic_Acl();
$this->view->resources = $logicAcl->getResources($recordAccount);
}
$this->view->configNavigation = new Dragon_Application_Config('dragonx/homepage/navigation/administration');
break;
}
}
示例3: preDispatch
public function preDispatch()
{
parent::preDispatch();
$auth = Zend_Auth::getInstance();
if (!$auth->hasIdentity()) {
$this->_redirect('auth/login');
}
}
示例4: preDispatch
public function preDispatch()
{
X_Debug::i("Required action: [" . $this->getRequest()->getControllerName() . '/' . $this->getRequest()->getActionName() . ']');
parent::preDispatch();
// call plugins trigger
// TODO check if plugin broker should be called before parent::preDispatch
X_VlcShares_Plugins::broker()->gen_beforePageBuild($this);
//$this->_helper->url->url()
}
示例5: preDispatch
public function preDispatch()
{
parent::preDispatch();
$request = $this->getRequest();
parent::__call($request->getActionName(), array());
if (!$this->checkActionAccess($request->getControllerName(), $request->getActionName())) {
throw new Rabotal_Exception_Access('Access denied!', 403);
}
}
示例6: preDispatch
public function preDispatch()
{
$this->view->baseUrl = $this->getRequest()->getBaseUrl();
$themeDir = Zend_Registry::get("themeDir");
require_once "{$themeDir}/config.php";
if ($this->getRequest()->disableLayout) {
$this->_helper->layout()->disableLayout();
}
return parent::preDispatch();
}
示例7: preDispatch
public function preDispatch()
{
parent::preDispatch();
//exit;
if (Zend_Auth::getInstance()->hasIdentity()) {
$authStorage = Zend_Auth::getInstance()->getStorage()->read();
$isAuth = true;
} else {
$authStorage = null;
$isAuth = false;
}
}
示例8: preDispatch
public function preDispatch()
{
$config = Zend_Registry::get('config');
if (trim($config->ambiente->db->host) != "") {
$this->_redirect("auth/login/");
}
parent::preDispatch();
$this->view->hideMenu = true;
if (Zend_Auth::getInstance()->hasIdentity() && $this->getRequest()->getActionName() == "installed") {
$this->_redirect("index");
}
}
示例9: preDispatch
public function preDispatch()
{
parent::preDispatch();
$request = $this->getRequest();
$this->view->module = $request->getModuleName();
$this->view->actionName = $request->getActionName();
$this->view->controllerName = $request->getControllerName();
$this->view->params = $params = $request->getParams();
$this->view->metas($params);
$this->checkACL();
$this->setAppLayout();
}
示例10: preDispatch
/**
* Pre-dispatch routines
* Asignar variables de entorno
*
* @return void
*/
public function preDispatch()
{
parent::preDispatch();
$config = $this->getConfig();
$this->config = $this->getConfig();
$this->log = $this->getLog();
//$this->cache = $this->getCache();
$this->siteUrl = $this->config->app->siteUrl;
$this->view->assign('siteUrl', $config->app->siteUrl);
if (APPLICATION_ENV != 'production') {
$sep = sprintf('[%s]', strtoupper(substr(APPLICATION_ENV, 0, 3)));
$this->view->headTitle()->prepend($sep);
}
}
示例11: preDispatch
public function preDispatch()
{
$auth = Zend_Auth::getInstance();
$this->data_user = $auth->getIdentity();
if (!$auth->hasIdentity()) {
$this->redirect('/login');
} else {
$acl = new Application_Model_Acl_Acl();
if (!$acl->isAllowed()) {
$this->redirect('/error/forbidden');
}
}
$this->view->user = $this->data_user;
parent::preDispatch();
}
示例12: preDispatch
/**
* Pre-dispatch routines
* Asignar variables de entorno
*
* @return void
*/
public function preDispatch()
{
parent::preDispatch();
$this->view->controller = $this->getRequest()->getControllerName();
$this->view->action = $this->getRequest()->getActionName();
$this->view->module = $this->getRequest()->getModuleName();
// $config = $this->getConfig();
// $this->config = $this->getConfig();
//Zend_Debug::dump($this->config);exit;
//$this->log = $this->getLog();
//$this->cache = $this->getCache();
// $this->siteUrl = $this->config['app']['siteUrl'];
// $this->view->assign('siteUrl', $config['app']['siteUrl']);
// $this->view->assign('translator', $this->_translate);
}
示例13: preDispatch
function preDispatch()
{
parent::preDispatch();
$this->view->sessionId = Zend_Session::getId();
$this->oConfig = Zend_Registry::get('config');
$this->oDb = Zend_Registry::get('db');
$this->oSession = new Zend_Session_Namespace(Zend_Controller_Front::getInstance()->getParam('bootstrap')->getOption('applicationName'));
$this->oAcl = Zend_Auth::getInstance();
if (APPLICATION_ENV == 'development') {
$this->_activateFirebug();
}
$this->view->auth = $this->getUser();
$this->view->controller = $this->getRequest()->getControllerName();
$this->view->action = $this->getRequest()->getActionName();
$this->_aUserInfo = $this->getUser();
$this->view->userInfo = $this->_aUserInfo;
}
示例14: preDispatch
public function preDispatch()
{
// этот контроллер недоступен без регистрации
if (!$this->isAuth()) {
$this->_redirect('/auth/login');
return;
}
if (!$this->webacula_acl->hasRole('root_role')) {
throw new Exception($this->view->translate->_('Webacula error. Role mechanism is broken. Check Webacula tables.'));
return;
}
$controller = $this->getRequest()->getControllerName();
if ($this->identity->role_name) {
if (!$this->webacula_acl->isAllowed($this->identity->role_name, $controller)) {
$msg = sprintf($this->view->translate->_('You try to use Webacula menu "%s".'), $controller);
$this->_forward('webacula-access-denied', 'error', null, array('msg' => $msg));
// action, controller
return;
}
}
parent::preDispatch();
}
示例15: preDispatch
public function preDispatch()
{
parent::preDispatch();
$navigation = Site_Service_Menu::getInstance()->getNavigation();
$controller = $this->getRequest()->getControllerName();
$module = $this->getRequest()->getModuleName();
$url = $this->getRequest()->getPathInfo();
$page = $navigation->findOneByUri($url);
$this->view->currentPage = $page;
if ($page) {
$page->setActive(true);
}
if ($page && !empty($page->resource)) {
$resource = $page->resource;
} else {
$resource = Site_Acl::RESOURCE_PUBLIC;
}
// Проверяем, авторизован ли пользователь
$role = Site_Service_Auth::getInstance()->getUser()->getRole();
$acl = Site_Acl::getInstance();
// К этим 2 контроллерам доступ есть всегда
if ($controller != 'error' && $controller != 'auth' && $module == 'default') {
$allowed = $acl->isAllowed($role, $resource);
if (!$allowed) {
$url = $this->getRequest()->getRequestUri();
if (Site_Service_Auth::getInstance()->isLoggedIn()) {
$this->forward('deny', 'error');
} else {
$this->redirect('auth/login?from=' . urlencode($url) . '&warn=1');
}
return;
}
}
// Меню
$this->view->navigation($navigation);
$this->view->navigation()->setAcl($acl)->setRole($role);
// login
$this->view->loggedUser = Site_Service_Auth::getInstance()->getUser();
}