Пример #1
0
 /**
  * Retrieves relative path from root web.
  *
  * @return string
  */
 public function getRelativePath()
 {
     /*
      * Path-to-file rules:
      * 
      *  url: www.foo.com/subpath1/subpath2/subpath3
      * path: subpath1/subpath2/subpath3.html
      * 
      * Except are frontpages with request /home !
      * 
      *  url: www.foo.com/storecode/
      * path: storecode.html
      * 
      *  url www.foo.com/
      * path: DEFAULT_STORE_CODE.html
      * 
      * DEFAULT_STORE_CODE is store code of default storeview.
      * 
      * Url makes by unsecure base url, store code and request.
      * Store code is used even when set not to use the store code in the url.
      * 
      */
     /* path is empty */
     $path = '';
     /* get information about model */
     $storeCode = $this->mturbomodel->getStoreCode();
     $baseUrl = $this->mturbomodel->getBaseUrl();
     $request = $this->mturbomodel->getRequestPath();
     /* trim request suffix */
     $requestArray = explode('.', $request);
     $request = $requestArray[0];
     if ($request == self::FRONTPAGE) {
         /* if frontpage then path is storecode.html */
         $path = $storeCode;
     } else {
         /* make url without http:// or https:// */
         $completeUrl = $baseUrl . $storeCode . DS . $request;
         $completeUrl = str_replace('https://', '', $completeUrl);
         $completeUrl = str_replace('http://', '', $completeUrl);
         /* explode to array, array[0] is host */
         $urlArray = explode(DS, $completeUrl);
         /* remove host */
         array_shift($urlArray);
         /* make back to path */
         $path = implode(DS, $urlArray);
     }
     /* fix endslash */
     if (mb_substr($path, -1) == DS) {
         $path = mb_substr($path, 0, mb_strlen($path) - 1);
     }
     /* add extension */
     $path .= self::EXT;
     return $path;
 }