コード例 #1
0
ファイル: Controller.php プロジェクト: barricade86/raui
 function init()
 {
     if (!oreInstall::isInstalled() && !(Yii::app()->controller->module && Yii::app()->controller->module->id == 'install')) {
         $this->redirect(array('/install'));
     }
     setLang();
     $modulesToCheck = ConfigurationModel::getModulesList();
     foreach ($modulesToCheck as $module) {
         if (param('module_enabled_' . $module) === null) {
             ConfigurationModel::createValue('module_enabled_' . $module, 0);
             Yii::app()->params['module_enabled_' . $module] = 0;
         }
     }
     unset($modulesToCheck);
     $this->assetsGenPath = Yii::getPathOfAlias('webroot.assets');
     $this->assetsGenUrl = Yii::app()->getBaseUrl(true) . '/assets/';
     Yii::app()->user->setState('menu_active', '');
     $this->pageTitle = tt('siteName', 'seo');
     $this->pageKeywords = tt('siteKeywords', 'seo');
     $this->pageDescription = tt('siteDescription', 'seo');
     Yii::app()->name = $this->pageTitle;
     $this->defaultTheme = Themes::getDefaultTheme();
     if (!$this->defaultTheme) {
         $this->defaultTheme = 'classic';
     }
     Yii::app()->theme = $this->defaultTheme;
     $this->baseUrl = Yii::app()->baseUrl;
     $this->baseThemeUrl = Yii::app()->theme->baseUrl;
     if (Yii::app()->getModule('menumanager')) {
         if (!(Yii::app()->controller->module && Yii::app()->controller->module->id == 'install')) {
             $this->infoPages = Menu::getMenuItems(true, 2);
         }
     }
     $subItems = array();
     if (!Yii::app()->user->isGuest) {
         $subItems = HUser::getMenu();
     }
     $this->aData['userCpanelItems'] = Menu::getMenuItems(true, 1);
     $this->aData['userCpanelItems'][] = array('label' => tt('Reserve apartment', 'common'), 'url' => array('/booking/main/mainform'), 'visible' => Yii::app()->user->checkAccess('backend_access') === false, 'linkOptions' => array('class' => 'fancy'), 'itemOptions' => array('class' => 'depth_zero'));
     $this->aData['userCpanelItems'][] = array('label' => Yii::t('common', 'Control panel'), 'url' => array('/usercpanel/main/index'), 'visible' => Yii::app()->user->checkAccess('backend_access') === false, 'items' => $subItems, 'itemOptions' => array('class' => 'depth_zero'), 'submenuOptions' => array('class' => 'sub_menu_dropdown'));
     if (!Yii::app()->user->isGuest) {
         $user = HUser::getModel();
         $this->aData['userCpanelItems'][] = array('label' => '(' . $user->username . ') ' . tt('Logout', 'common'), 'url' => array('/site/logout'), 'itemOptions' => array('class' => 'depth_zero'));
     }
     $this->aData['topMenuItems'] = $this->infoPages;
     // comparison list
     if (issetModule('comparisonList')) {
         if (!Yii::app()->user->isGuest) {
             $resultCompare = ComparisonList::model()->findAllByAttributes(array('user_id' => Yii::app()->user->id));
         } else {
             $resultCompare = ComparisonList::model()->findAllByAttributes(array('session_id' => Yii::app()->session->sessionId));
         }
         if ($resultCompare) {
             foreach ($resultCompare as $item) {
                 $this->apInComparison[] = $item->apartment_id;
             }
         }
     }
     $this->currentUserIp = Yii::app()->request->getUserHostAddress();
     $this->currentUserIpLong = ip2long($this->currentUserIp);
     $this->datePickerLang = Yii::app()->language;
     if ($this->datePickerLang == 'en') {
         $this->datePickerLang = 'en-GB';
     }
     if (demo()) {
         if (isset($_GET['theme']) && array_key_exists($_GET['theme'], Themes::getColorThemesList())) {
             $theme = $_GET['theme'];
             $cookie = new CHttpCookie('theme', $theme);
             $cookie->expire = time() + 86400;
             Yii::app()->request->cookies['theme'] = $cookie;
         }
     }
     parent::init();
 }