Пример #1
0
 /**
  * Because of our need to switch URLs in certain cases, we actually make all URLs absolute now
  */
 public function createUrl($route, $params = array(), $ampersand = '&', $schema = '')
 {
     // Get the URL without the host first.
     $url = parent::createUrl($route, $params, $ampersand);
     // Does this system support regular SSL or Common SSL?
     if (Yii::app()->params['ENABLE_SSL'] == false && Yii::app()->hasCommonSSL == false) {
         // For systems with no SSL, function normally
         return $url;
     }
     if (isset($route) && $route !== '') {
         $strController = $this->parseRouteGetController($route);
         $strAction = $this->parseRouteGetAction($route);
         $route = _xls_remove_leading_slash($route);
     } else {
         $strController = null;
     }
     if (Yii::app()->hasCommonSSL === true && Yii::app()->isCommonSSL === false) {
         // When SSL is available on the web store there are certain routes
         // which use CommonsslController to hand over from the HTTP to
         // HTTPS domain. The commonssl routes should be generated on the
         // same domain as this request, since they require access to the
         // user session for the handover.
         if ($route == "cart/checkout") {
             $route = "commonssl/cartcheckout";
             return $this->getUrlManager()->createUrl($route, $params, $ampersand);
         } elseif (in_array($route, $this->_arrNeverSecureRoutes) === false && in_array($strController, $this->_arrCommonSSLControllers) === true) {
             $route = 'commonssl/' . $strController;
             return $this->getUrlManager()->createUrl($route, $params + array('action' => $strAction), $ampersand);
         }
     }
     if (Yii::app()->HasCommonSSL) {
         $strCustomUrl = Yii::app()->params['LIGHTSPEED_HOSTING_CUSTOM_URL'];
         $strLightSpeedUrl = Yii::app()->params['LIGHTSPEED_HOSTING_LIGHTSPEED_URL'];
     } else {
         $strCustomUrl = '';
         $strLightSpeedUrl = '';
     }
     $httpHost = str_replace($strLightSpeedUrl, $strCustomUrl, $this->getRequest()->getHostInfo('http'));
     // For specific routes, we always use HTTP.
     if (in_array($route, $this->_arrNeverSecureRoutes)) {
         // Force a switch to original URL without SSL
         $host = $httpHost;
     } elseif (in_array($route, $this->_arrNeedToSecureRoutes) || in_array($strController, $this->_arrNeedToSecureControllers)) {
         //Force a switch to Common SSL
         $host = str_replace($strCustomUrl, $strLightSpeedUrl, $this->getRequest()->getHostInfo('https'));
     } elseif (in_array($strController, $this->_arrPassthroughControllers)) {
         //For specific controllers, pass these through (this is mostly AJAX)
         //This URL could be on either hostname so just pass through without schema
         return $url;
     } else {
         // Force a switch to original URL without SSL.
         $host = $httpHost;
     }
     Yii::log("URL built as " . $host . $url, 'trace', 'application.' . __CLASS__ . "." . __FUNCTION__);
     return $host . $url;
 }