/**
  * Load anything we need globally, such as items we're going to use in our main.php template.
  * If you create init() in any other controller, you need to run parent::init() too or this
  * will be skipped. If you run your own init() and don't call this, you must call Controller::initParams(); 
  * or nothing will work.
  */
 public function init()
 {
     self::initParams();
     if (isset($_GET['nosni'])) {
         Yii::app()->user->setFlash('warning', Yii::t('global', 'NOTE: Your older operating system does not support certain security features this site uses. You have been redirected to {link} for your session which will ensure your information is properly protected.', array('{link}' => "<b>" . Yii::app()->params['LIGHTSPEED_HOSTING_LIGHTSPEED_URL'] . "</b>")));
     }
     $filename = Yii::getPathOfAlias('webroot.themes') . DIRECTORY_SEPARATOR . DEFAULT_THEME;
     if (!file_exists($filename) && _xls_get_conf('LIGHTSPEED_MT', 0) == '0') {
         if (!downloadTheme(DEFAULT_THEME)) {
             die("missing " . DEFAULT_THEME);
         } else {
             $this->redirect(Yii::app()->createUrl("site/index"));
         }
     }
     if (!Yii::app()->theme) {
         if (_xls_get_conf('THEME')) {
             //We can't find our theme for some reason, switch back to default
             _xls_set_conf('THEME', DEFAULT_THEME);
             _xls_set_conf('CHILD_THEME', 'light');
             Yii::log("Couldn't find our theme, switched back to " . DEFAULT_THEME . " for emergency", 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
             $this->redirect(Yii::app()->createUrl('site/index'));
         } else {
             die("you have no theme set");
         }
     }
     if (isset($_GET['theme']) && isset($_GET['themekey'])) {
         $strTheme = CHtml::encode($_GET['theme']);
         $strThemeKey = CHtml::encode($_GET['themekey']);
         if ($this->verifyPreviewThemeKey($strTheme, $strThemeKey)) {
             Yii::app()->theme = $strTheme;
             $this->registerPreviewThemeScript($strTheme, $strThemeKey);
         } else {
             Yii::log("Invalid theme preview link for" . $strTheme . ". Navigate to Admin Panel to generate a new link.", 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
         }
     }
     $strViewset = Yii::app()->theme->info->viewset;
     if (!empty($strViewset)) {
         Yii::app()->setViewPath(Yii::getPathOfAlias('application') . "/views-" . $strViewset);
     }
 }
Exemplo n.º 2
0
 /**
  * Load anything we need globally, such as items we're going to use in our main.php template.
  * If you create init() in any other controller, you need to run parent::init() too or this
  * will be skipped. If you run your own init() and don't call this, you must call Controller::initParams();
  * or nothing will work.
  */
 public function init()
 {
     self::initParams();
     if (isset($_GET['nosni'])) {
         Yii::app()->user->setFlash('warning', Yii::t('global', 'NOTE: Your older operating system does not support certain security features this site uses. You have been redirected to {link} for your session which will ensure your information is properly protected.', array('{link}' => "<b>" . Yii::app()->params['LIGHTSPEED_HOSTING_LIGHTSPEED_URL'] . "</b>")));
     }
     $filename = Yii::getPathOfAlias('webroot.themes') . DIRECTORY_SEPARATOR . DEFAULT_THEME;
     if (!file_exists($filename) && _xls_get_conf('LIGHTSPEED_MT', 0) == '0') {
         if (!downloadTheme(DEFAULT_THEME)) {
             die("missing " . DEFAULT_THEME);
         } else {
             $this->redirect(Yii::app()->createUrl("site/index"));
         }
     }
     if (!Yii::app()->theme) {
         if (_xls_get_conf('THEME')) {
             //We can't find our theme for some reason, switch back to default
             _xls_set_conf('THEME', DEFAULT_THEME);
             _xls_set_conf('CHILD_THEME', 'light');
             Yii::log("Couldn't find our theme, switched back to " . DEFAULT_THEME . " for emergency", 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
             $this->redirect(Yii::app()->createUrl('site/index'));
         } else {
             die("you have no theme set");
         }
     }
     if (isset($_GET['theme']) && isset($_GET['themekey'])) {
         $strTheme = CHtml::encode($_GET['theme']);
         $strThemeKey = CHtml::encode($_GET['themekey']);
         if ($this->verifyPreviewThemeKey($strTheme, $strThemeKey)) {
             Yii::app()->theme = $strTheme;
             $this->registerPreviewThemeScript($strTheme, $strThemeKey);
         } else {
             Yii::log("Invalid theme preview link for" . $strTheme . ". Navigate to Admin Panel to generate a new link.", 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
         }
     }
     $this->buildBootstrap();
     if (_xls_facebook_login()) {
         $this->setFacebookComponent();
     }
     if (Yii::app()->params['STORE_OFFLINE'] != '0' || Yii::app()->params['INSTALLED'] != '1') {
         if (isset($_GET['offline'])) {
             Yii::app()->session['STORE_OFFLINE'] = _xls_number_only($_GET['offline']);
         }
         //If uninstalled on a new Multitenant store, direct to license acceptance to get going
         if (Yii::app()->params['INSTALLED'] != '1' && Yii::app()->params['LIGHTSPEED_MT'] == '1') {
             $url = Yii::app()->createUrl("admin/license");
             $url = str_replace("https:", "http:", $url);
             $this->redirect($url, true);
         }
         if (Yii::app()->session['STORE_OFFLINE'] != Yii::app()->params['STORE_OFFLINE'] || Yii::app()->params['INSTALLED'] != '1') {
             $this->render('/site/offline');
             Yii::app()->end();
         }
     }
     $this->logoutUrl = $this->createUrl("site/logout");
     $strViewset = Yii::app()->theme->info->viewset;
     if (!empty($strViewset)) {
         Yii::app()->setViewPath(Yii::getPathOfAlias('application') . "/views-" . $strViewset);
     }
     $strLayoutFile = Yii::app()->theme->config->layoutFile;
     if (empty($strLayoutFile)) {
         $strLayoutFile = "column2";
         //This is for backwards compatibility only
     }
     if (Yii::app()->theme && file_exists('webroot.themes.' . Yii::app()->theme->name . '.layouts.' . $strLayoutFile)) {
         $this->layout = 'webroot.themes.' . Yii::app()->theme->name . '.layouts.' . $strLayoutFile;
     } else {
         $this->layout = $strLayoutFile;
     }
     //Set defaults
     $this->getUserLanguage();
     $this->pageTitle = Yii::app()->name . " : " . Yii::app()->params['STORE_TAGLINE'];
     $this->pageCanonicalUrl = $this->getCanonicalUrl();
     $this->pageDescription = Yii::app()->params['STORE_TAGLINE'];
     $this->pageImageUrl = '';
     $pageHeaderImage = Yii::app()->params['HEADER_IMAGE'];
     if (substr($pageHeaderImage, 0, 4) != "http") {
         if (substr($pageHeaderImage, 0, 2) != "//") {
             $this->pageAbsoluteHeaderImage = Yii::app()->createAbsoluteUrl($pageHeaderImage, array(), Yii::app()->params['ENABLE_SSL'] ? 'https' : 'http');
             // we prefix with baseUrl to handle instances where Web Store is installed in a sub folder
             $this->pageHeaderImage = Yii::app()->baseUrl . $pageHeaderImage;
         } else {
             $this->pageAbsoluteHeaderImage = Yii::app()->params['ENABLE_SSL'] ? 'https:' . $pageHeaderImage : 'http:' . $pageHeaderImage;
             $this->pageHeaderImage = $pageHeaderImage;
         }
     } else {
         $this->pageAbsoluteHeaderImage = $pageHeaderImage;
         $this->pageHeaderImage = $pageHeaderImage;
     }
     Yii::app()->shoppingcart->updateMissingProducts();
     Yii::app()->shoppingcart->revalidatePromoCode();
     //Run other functions to create some data we always need
     $this->buildGoogle();
     $this->buildSidebars();
     if (_xls_get_conf('SHOW_SHARING', 0)) {
         $this->buildSharing();
     }
     $this->buildAccessWarning();
     $this->gridProductsPerRow = _xls_get_conf('PRODUCTS_PER_ROW', 3);
     Yii::app()->clientScript->registerMetaTag("Lightspeed Web Store " . XLSWS_VERSION, 'generator', null, array(), 'generator');
 }
Exemplo n.º 3
0
 /**
  * Download default theme.
  *
  * If we don't find the theme already, download it here
  *
  * @return void
  */
 protected function downloadTheme()
 {
     //Hosting already places the file
     if (isset($_POST['hosted']) && $_POST['hosted'] == '1') {
         return;
     }
     //And download brooklyn as a default
     $filename = Yii::getPathOfAlias('webroot.themes') . DIRECTORY_SEPARATOR . DEFAULT_THEME;
     if (!file_exists($filename)) {
         downloadTheme(DEFAULT_THEME);
     }
 }