/** * standard page controller * * @return void * * @author Roland Lehmann <*****@*****.**>, * Sebastian Diel <*****@*****.**> * @since 15.11.2014 */ public function init() { if (array_key_exists('HTTP_USER_AGENT', $_SERVER)) { if (SilvercartConfig::isUserAgentBlacklisted($_SERVER['HTTP_USER_AGENT'])) { exit; } } if (array_key_exists($this->ID, self::$instanceMemorizer)) { parent::init(); return true; } SilvercartTools::initSession(); $controller = Controller::curr(); if ($this != $controller && method_exists($controller, 'getRegisteredCustomHtmlForms')) { $registeredCustomHtmlForms = $controller->getRegisteredCustomHtmlForms(); } if ($controller == $this || $controller->forceLoadOfWidgets) { $this->loadWidgetControllers(); } $this->loadJSRequirements(); // We have to check if we are in a customised controller (that's the // case for all Security pages). If so, we use the registered forms of // the outermost controller. if (empty($registeredCustomHtmlForms)) { $this->registerCustomHtmlForm('SilvercartQuickSearchForm', new SilvercartQuickSearchForm($this)); $this->registerCustomHtmlForm('SilvercartQuickLoginForm', new SilvercartQuickLoginForm($this)); if ($this->getTranslations()) { $this->registerCustomHtmlForm('SilvercartChangeLanguageForm', new SilvercartChangeLanguageForm($this)); } } else { $this->setRegisteredCustomHtmlForms($registeredCustomHtmlForms); } $allParams = Controller::curr()->getRequest()->allParams(); if (Controller::curr() instanceof Security && array_key_exists('Action', $allParams) && strtolower($allParams['Action']) == 'lostpassword' && Member::currentUserID() > 0 && SilvercartCustomer::currentUser() instanceof Member) { SilvercartCustomer::currentUser()->logOut(); } if (Member::currentUserID() > 0 && !SilvercartCustomer::currentUser() instanceof Member) { Session::set('loggedInAs', 0); Session::save(); } // check the SilverCart configuration if (!SilvercartTools::isIsolatedEnvironment()) { SilvercartConfig::Check(); } // Delete checkout session data if user is not in the checkout process. if ($this->class != 'SilvercartCheckoutStep' && $this->class != 'SilvercartCheckoutStep_Controller' && $this->class != 'ErrorPage_Controller' && $this->class != 'Security' && $this->class != 'SilvercartFrontPage_Controller' && !$this->class instanceof SilvercartCheckoutStep_Controller && !$this->class instanceof Security && !is_subclass_of($this->class, 'SilvercartCheckoutStep_Controller')) { SilvercartCheckoutStep::deleteSessionStepData(); } // Decorator can use this method to add custom forms and other stuff $this->extend('updateInit'); SilvercartPlugin::call($this, 'init', array($this)); self::$instanceMemorizer[$this->ID] = true; parent::init(); }