Example #1
0
 /**
  * Creates an absolute URL out of really any input path, removes '../' parts for the targetPath
  *
  * @param string $targetPath can be "../../typo3/contrib/myfile.js" or "/myfile.js"
  * @return string something like "/mysite/typo3/sysext/backend.js"
  */
 public static function getAbsoluteWebPath($targetPath)
 {
     if (self::isAbsolutePath($targetPath)) {
         if (StringUtility::beginsWith($targetPath, PATH_site)) {
             $targetPath = GeneralUtility::getIndpEnv('TYPO3_SITE_PATH') . self::stripPathSitePrefix($targetPath);
         }
     } elseif (strpos($targetPath, '://') !== FALSE) {
         return $targetPath;
     } else {
         // Make an absolute path out of it
         $targetPath = GeneralUtility::resolveBackPath(dirname(PATH_thisScript) . '/' . $targetPath);
         $targetPath = self::stripPathSitePrefix($targetPath);
         $targetPath = GeneralUtility::getIndpEnv('TYPO3_SITE_PATH') . $targetPath;
     }
     return $targetPath;
 }
Example #2
0
 /**
  * Creates an absolute URL out of really any input path, removes '../' parts for the targetPath
  *
  * @param string $targetPath can be "../typo3conf/ext/myext/myfile.js" or "/myfile.js"
  * @return string something like "/mysite/typo3conf/ext/myext/myfile.js"
  */
 public static function getAbsoluteWebPath($targetPath)
 {
     if (self::isAbsolutePath($targetPath)) {
         if (strpos($targetPath, PATH_site) === 0) {
             $targetPath = self::stripPathSitePrefix($targetPath);
             if (!(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI)) {
                 $targetPath = GeneralUtility::getIndpEnv('TYPO3_SITE_PATH') . $targetPath;
             }
         }
     } elseif (strpos($targetPath, '://') !== false) {
         return $targetPath;
     } else {
         // Make an absolute path out of it
         $targetPath = GeneralUtility::resolveBackPath(dirname(PATH_thisScript) . '/' . $targetPath);
         $targetPath = self::stripPathSitePrefix($targetPath);
         if (!(TYPO3_REQUESTTYPE & TYPO3_REQUESTTYPE_CLI)) {
             $targetPath = GeneralUtility::getIndpEnv('TYPO3_SITE_PATH') . $targetPath;
         }
     }
     return $targetPath;
 }