/**
  * Returned the URL to the js-File
  *
  * @return string
  */
 private function __getJsUrl()
 {
     return $this->__getHostUrl() . "/mobile_header/" . $this->config->getShopNumber() . ".js";
 }
Ejemplo n.º 2
0
 protected function getJsHeader($mobileRedirectUrl = null)
 {
     $html = $this->loadTemplate($this->jsHeaderTemplatePath);
     if (empty($html)) {
         return '';
     }
     $linkTag = '';
     if ($this->config->getShopIsActive() && !$this->suppressRedirect) {
         $linkTag = $this->loadTemplate($this->linkTagTemplatePath);
     }
     if (!$this->config->getShopNumber()) {
         return '';
     }
     if (empty($mobileRedirectUrl)) {
         $mobileRedirectUrl = $this->getShopUrl();
     }
     $additionalParameters = '';
     $redirectCode = '';
     switch ($this->redirectType) {
         case 'item':
             if (!isset($this->itemNumber) || $this->itemNumber == '') {
                 $redirectCode = 'default';
                 break;
             }
             $redirectCode = 'item';
             $additionalParameters .= '_shopgate.item_number = "' . $this->itemNumber . '";';
             break;
         case 'itempublic':
             if (!isset($this->itemNumberPublic) || $this->itemNumberPublic == '') {
                 $redirectCode = 'default';
                 break;
             }
             $redirectCode = 'item';
             $additionalParameters .= '_shopgate.item_number_public = "' . $this->itemNumberPublic . '";';
             break;
         case 'category':
             if (!isset($this->categoryNumber) || $this->categoryNumber == '') {
                 $redirectCode = 'default';
                 break;
             }
             $redirectCode = 'category';
             $additionalParameters .= '_shopgate.category_number = "' . $this->categoryNumber . '";';
             break;
         case 'cms':
             if (!isset($this->cmsPage) || $this->cmsPage == '') {
                 $redirectCode = 'default';
                 break;
             }
             $redirectCode = 'cms';
             $additionalParameters .= '_shopgate.cms_page = "' . $this->cmsPage . '";';
             break;
         case 'brand':
             if (!isset($this->manufacturerName) || $this->manufacturerName == '') {
                 $redirectCode = 'default';
                 break;
             }
             $redirectCode = 'brand';
             $additionalParameters .= '_shopgate.brand_name = "' . $this->manufacturerName . '";';
             break;
         case 'search':
             if (!isset($this->searchQuery) || $this->searchQuery == '') {
                 $redirectCode = 'default';
                 break;
             }
             $redirectCode = 'search';
             $additionalParameters .= '_shopgate.search_query = "' . $this->searchQuery . '";';
             break;
         case 'start':
             $redirectCode = 'start';
             break;
         default:
             $redirectCode = 'default';
     }
     if ($redirectCode == 'default') {
         $additionalParameters .= '_shopgate.is_default_redirect_disabled = ' . (!$this->enableDefaultRedirect ? 'true' : 'false') . ';';
         $linkTag = '';
     }
     if ($this->suppressRedirect) {
         $additionalParameters .= "\n    " . '_shopgate.redirect_to_webapp = false;';
     }
     switch ($this->config->getServer()) {
         default:
             // fall through to 'live'
         // fall through to 'live'
         case 'live':
             $sslUrl = ShopgateMobileRedirectInterface::SHOPGATE_STATIC_SSL;
             $nonSslUrl = ShopgateMobileRedirectInterface::SHOPGATE_STATIC;
             break;
         case 'sl':
             $sslUrl = ShopgateMobileRedirectInterface::SHOPGATE_SL_STATIC_SSL;
             $nonSslUrl = ShopgateMobileRedirectInterface::SHOPGATE_SL_STATIC;
             break;
         case 'pg':
             $sslUrl = ShopgateMobileRedirectInterface::SHOPGATE_PG_STATIC_SSL;
             $nonSslUrl = ShopgateMobileRedirectInterface::SHOPGATE_PG_STATIC;
             break;
         case 'custom':
             $sslUrl = 'https://shopgatedev-public.s3.amazonaws.com';
             $nonSslUrl = 'http://shopgatedev-public.s3.amazonaws.com';
             break;
     }
     // set parameters
     $html = str_replace('{$link_tag}', $linkTag, $html);
     $html = str_replace('{$mobile_url}', $mobileRedirectUrl, $html);
     $html = str_replace('{$shop_number}', $this->config->getShopNumber(), $html);
     $html = str_replace('{$redirect_code}', $redirectCode, $html);
     $html = str_replace('{$additional_parameters}', $additionalParameters, $html);
     $html = str_replace('{$ssl_url}', $sslUrl, $html);
     $html = str_replace('{$non_ssl_url}', $nonSslUrl, $html);
     return $html;
 }