Example #1
0
 /**
  * 
  * @return type
  */
 public static function getBaseFolder()
 {
     $sJbase = JchPlatformUri::base(true);
     return $sJbase == '/' ? $sJbase : $sJbase . '/';
 }
 /**
  * 
  * @return type
  */
 public static function getBaseFolder()
 {
     return JchPlatformUri::base(true) . '/';
 }
Example #3
0
 /**
  * Callback function to correct urls in aggregated css files
  *
  * @param array $aMatches Array of all matches
  * @return string         Correct url of images from aggregated css file
  */
 public function _correctUrlCB($aMatches)
 {
     //JCH_DEBUG ? JchPlatformProfiler::mark('beforeCorrectUrl plgSystem (JCH Optimize)') : null;
     if (preg_match('#^(?:\\(|/(?:/|\\*))#', $aMatches[0])) {
         return $aMatches[0];
     }
     if ($aMatches[0] == '') {
         return ' ';
     }
     $sUriBase = JchPlatformUri::base(TRUE);
     $sImageUrl = $aMatches[1];
     $sCssFileUrl = isset($this->aUrl['url']) ? $this->aUrl['url'] : '/';
     if (preg_match('#^data:#', $sImageUrl)) {
         return $sImageUrl;
     }
     if (!preg_match('#^/|://#', $sImageUrl)) {
         $aCssUrlArray = explode('/', $sCssFileUrl);
         array_pop($aCssUrlArray);
         $sCssRootPath = implode('/', $aCssUrlArray) . '/';
         $sImagePath = $sCssRootPath . $sImageUrl;
         $oImageUri = clone JchPlatformUri::getInstance($sImagePath);
         $sUriPath = preg_replace('#^' . preg_quote($sUriBase, '#') . '/#', '', $oImageUri->getPath());
         $oImageUri->setPath($sUriBase . '/' . $sUriPath);
         $sImageUrl = $oImageUri->toString();
     }
     if (JchOptimizeHelper::isInternal($sCssFileUrl) && JchOptimizeHelper::isInternal($sImageUrl)) {
         $oImageUri = clone JchPlatformUri::getInstance($sImageUrl);
         $aStaticFiles = $this->staticFiles();
         $sStaticFiles = implode('|', $aStaticFiles);
         $aFontFiles = $this->fontFiles();
         $sFontFiles = implode('|', $aFontFiles);
         if (preg_match('#\\.(?>' . $sStaticFiles . ')#', $oImageUri->getPath())) {
             $sImageUrl = JchOptimizeHelper::cookieLessDomain($this->params) . $oImageUri->toString(array('path'));
         } elseif (preg_match('#\\.php#', $oImageUri->getPath())) {
             $sImageUrl = $oImageUri->toString(array('path', 'query', 'fragment'));
         } elseif ($this->params->get('pro_cookielessdomain', '') && preg_match('#\\.(?>' . $sFontFiles . ')#', $oImageUri->getPath())) {
             $oUri = clone JchPlatformUri::getInstance();
             $sImageUrl = '//' . $oUri->toString(array('host', 'port')) . $oImageUri->toString(array('path'));
         } else {
             $sImageUrl = $oImageUri->toString(array('path'));
         }
     }
     //JCH_DEBUG ? JchPlatformProfiler::mark('afterCorrectUrl plgSystem (JCH Optimize)') : null;
     $sImageUrl = preg_match('#(?<!\\\\)[\\s\'"(),]#', $sImageUrl) ? '"' . $sImageUrl . '"' : $sImageUrl;
     return $sImageUrl;
 }
Example #4
0
 /**
  * 
  * @return type
  */
 public static function rewriteBase()
 {
     $sJbase = JchPlatformUri::base(true);
     return $sJbase == '/' ? $sJbase : $sJbase . '/';
 }
Example #5
0
 /**
  * Callback function to correct urls in aggregated css files
  *
  * @param array $aMatches Array of all matches
  * @return string         Correct url of images from aggregated css file
  */
 public function _correctUrlCB($aMatches, $aUrl)
 {
     if (!isset($aMatches[1]) || $aMatches[1] == '' || preg_match('#^(?:\\(|/(?:/|\\*))#', $aMatches[0])) {
         return $aMatches[0];
     }
     $sUriBase = JchPlatformUri::base(TRUE);
     $sImageUrl = $aMatches[1];
     $sCssFileUrl = isset($aUrl['url']) ? $aUrl['url'] : '/';
     if (!preg_match('#^data:#', $sImageUrl)) {
         if (!preg_match('#^/|://#', $sImageUrl)) {
             $aCssUrlArray = explode('/', $sCssFileUrl);
             array_pop($aCssUrlArray);
             $sCssRootPath = implode('/', $aCssUrlArray) . '/';
             $sImagePath = $sCssRootPath . $sImageUrl;
             $oImageUri = clone JchPlatformUri::getInstance($sImagePath);
             if (JchOptimizeHelper::isInternal($sCssFileUrl)) {
                 $sUriPath = preg_replace('#^' . preg_quote($sUriBase, '#') . '/#', '', $oImageUri->getPath());
                 $oImageUri->setPath($sUriBase . '/' . $sUriPath);
                 $sImageUrl = $oImageUri->toString();
             } else {
                 $oImageUri->setPath($oImageUri->getPath());
                 $sImageUrl = ($oImageUri->toString(array('scheme')) ? '' : '//') . $oImageUri->toString();
             }
         }
         if (JchOptimizeHelper::isInternal($sCssFileUrl) && JchOptimizeHelper::isInternal($sImageUrl)) {
             $oImageUri = clone JchPlatformUri::getInstance($sImageUrl);
             $aStaticFiles = $this->params->get('pro_staticfiles', array('css', 'js', 'jpe?g', 'gif', 'png', 'ico', 'bmp', 'pdf'));
             $sStaticFiles = implode('|', $aStaticFiles);
             $aFontFiles = $this->fontFiles();
             $sFontFiles = implode('|', $aFontFiles);
             if (preg_match('#\\.(?>' . $sStaticFiles . ')#', $oImageUri->getPath())) {
                 $sImageUrl = JchOptimizeHelper::cookieLessDomain($this->params, $oImageUri->toString(array('path')));
             } elseif (preg_match('#\\.php#', $oImageUri->getPath())) {
                 $sImageUrl = $oImageUri->toString(array('path', 'query', 'fragment'));
             } elseif ($this->params->get('pro_cookielessdomain_enable', '0') && preg_match('#\\.(?>' . $sFontFiles . ')#', $oImageUri->getPath())) {
                 $oUri = clone JchPlatformUri::getInstance();
                 $sImageUrl = '//' . $oUri->toString(array('host', 'port')) . $oImageUri->toString(array('path'));
             } else {
                 $sImageUrl = $oImageUri->toString(array('path'));
             }
         }
     }
     $sImageUrl = preg_match('#(?<!\\\\)[\\s\'"(),]#', $sImageUrl) ? '"' . $sImageUrl . '"' : $sImageUrl;
     return $sImageUrl;
 }
Example #6
0
 /**
  * 
  * @param type $sUrl
  * @param type $sCurFile
  */
 public static function toRootRelative($sUrl, $sCurFile = '')
 {
     if (self::isPathRelative($sUrl)) {
         $sUrl = (empty($sCurFile) ? '' : dirname($sCurFile) . '/') . $sUrl;
     }
     $sUrl = JchPlatformUri::getInstance($sUrl)->toString(array('path', 'query', 'fragment'));
     if (self::isPathRelative($sUrl)) {
         $sUrl = rtrim(JchPlatformUri::base(TRUE), '\\/') . '/' . $sUrl;
     }
     return $sUrl;
 }