diff --git a/library/Local/Controller/Action/DomainSwitch.php b/library/Local/Controller/Action/DomainSwitch.php index 20d5f4348..e43628b57 100644 --- a/library/Local/Controller/Action/DomainSwitch.php +++ b/library/Local/Controller/Action/DomainSwitch.php @@ -1,188 +1,188 @@ . **/ class Local_Controller_Action_DomainSwitch extends Zend_Controller_Action { /** * Zend_Controller_Request_Abstract object wrapping the request environment * @var Zend_Controller_Request_Http */ protected $_request = null; /** @var object */ protected $_authMember; protected $templateConfigData; protected $defaultConfigName; const METAHEADER_DEFAULT = 'meta_keywords'; const METAHEADER_DEFAULT_TITLE='opendesktop.org'; const METAHEADER_DEFAULT_DESCRIPTION='A community where developers and artists share applications, themes and other content'; const METAHEADER_DEFAULT_KEYWORDS='opendesktop,linux,kde,gnome,themes,apps,desktops,applications,addons,artwork,wallpapers'; public function init() { $this->initDefaultConfigName(); $this->initAuth(); $this->initTemplateData(); $this->initView(); $this->setLayout(); $this->_initResponseHeader(); $this->_initAdminDbLogger(); } protected function initDefaultConfigName() { $config = Zend_Registry::get('config'); $this->defaultConfigName = $config->settings->client->default->name; } protected function initAuth() { $auth = Zend_Auth::getInstance(); // Design issue: getStorage()->read() should return an empty member object for unknown user. This is a workaround for the moment. if ($auth->hasIdentity()) { $this->_authMember = $auth->getStorage()->read(); } else { $tableMember = new Default_Model_Member(); $this->_authMember = $tableMember->createRow(); } } private function initTemplateData() { if (Zend_Registry::isRegistered('store_template')) { $this->templateConfigData = Zend_Registry::get('store_template'); } else { $fileNameConfig = APPLICATION_PATH . '/configs/client' . $this->getDomainPostfix() . '.ini.php'; if (file_exists($fileNameConfig)) { $this->templateConfigData = require APPLICATION_PATH . '/configs/client' . $this->getDomainPostfix() . '.ini.php'; } else { $this->templateConfigData = require APPLICATION_PATH . '/configs/client_' . $this->defaultConfigName . '.ini.php'; } } } /** * @return string */ protected function getDomainPostfix() { return '_' . $this->getNameForStoreClient(); } /** * Returns the name for the client. If no name were found, the name for the standard client will be returned. * * @return string */ public function getNameForStoreClient() { $clientName = 'pling'; // set to default if (Zend_Registry::isRegistered('store_config_name')) { $clientName = Zend_Registry::get('store_config_name'); } return $clientName; } public function initView() { if(!Zend_Registry::isRegistered('headMetaSet')) { $headTitle = $this->templateConfigData['head']['browser_title']; $headDesc = $this->templateConfigData['head']['meta_description']; $headKeywords =$this->templateConfigData['head']['meta_keywords']; //set default site-title $this->view->headTitle($headTitle, Zend_View_Helper_Placeholder_Container_Abstract::SET); if($headTitle==$this::METAHEADER_DEFAULT){ $headTitle=$this::METAHEADER_DEFAULT_TITLE; } if($headDesc==$this::METAHEADER_DEFAULT){ $headDesc=$this::METAHEADER_DEFAULT_DESCRIPTION; } if($headKeywords==$this::METAHEADER_DEFAULT){ $headKeywords=$this::METAHEADER_DEFAULT_KEYWORDS; } $this->view->headMeta() ->appendName('author', $this->templateConfigData['head']['meta_author']) ->appendName('robots', 'all') ->appendName('robots', 'index') ->appendName('robots', 'follow') ->appendName('revisit-after', '3 days') ->appendName('title', $headTitle) ->appendName('description', $headDesc, array('lang' => 'en-US')) ->appendName('keywords', $headKeywords, array('lang' => 'en-US')); Zend_Registry::set('headMetaSet', true); } $this->view->template = $this->templateConfigData; } protected function setLayout() { $layoutName = 'flat_ui_template'; $storeConfig = Zend_Registry::isRegistered('store_config') ? Zend_Registry::get('store_config') : null; if($storeConfig && $storeConfig->layout) { $this->_helper->layout()->setLayout($storeConfig->layout); }else{ $this->_helper->layout()->setLayout($layoutName); } } protected function _initResponseHeader() { $duration = 1800; // in seconds $expires = gmdate("D, d M Y H:i:s", time() + $duration) . " GMT"; $this->getResponse() - ->setHeader('X-FRAME-OPTIONS', 'SAMEORIGIN', true) + ->setHeader('X-FRAME-OPTIONS', 'ALLOWALL', true) // ->setHeader('Last-Modified', $modifiedTime, true) ->setHeader('Expires', $expires, true) ->setHeader('Pragma', 'no-cache', true) ->setHeader('Cache-Control', 'private, no-store, no-cache, must-revalidate, post-check=0, pre-check=0', true) ; } private function _initAdminDbLogger() { if (Zend_Auth::getInstance()->hasIdentity() AND Zend_Auth::getInstance()->getIdentity()->roleName == 'admin') { $profiler = new Zend_Db_Profiler(); $profiler->setEnabled(true); // Attach the profiler to your db adapter Zend_Db_Table::getDefaultAdapter()->setProfiler($profiler); /** @var Zend_Db_Adapter_Abstract $db */ $db = Zend_Registry::get('db'); $db->setProfiler($profiler); Zend_Registry::set('db', $db); } } } \ No newline at end of file