/** * * @param type $oObj * @param type $iItemid * @param type $sCss * @return type */ public function getAdminLinks($oObj, $iItemid, $sCss = '') { if (empty($this->links)) { $hash = $iItemid . $this->params->get('pro_searchBody', 0) . $this->params->get('pro_cookielessdomain', 0); $sId = md5('getAdminLinks' . JCH_VERSION . serialize($hash)); $aFunction = array($this, 'generateAdminLinks'); $aArgs = array($oObj, $sCss); $iLifeTime = (int) $this->params->get('lifetime', '30') * 24 * 60 * 60; $this->links = JchPlatformCache::getCallbackCache($sId, $iLifeTime, $aFunction, $aArgs); } return $this->links; }
/** * * @param type $oObj * @param type $iItemid * @param type $sCss * @return type */ public function getAdminLinks($oObj, $iItemid, $sCss = '') { JCH_DEBUG ? JchPlatformProfiler::mark('beforeGetAdminLinks plgSystem (JCH Optimize)') : null; if (!defined('JCH_VERSION')) { define('JCH_VERSION', '4.2.0'); } $sId = md5('getAdminLinks' . JCH_VERSION . serialize($iItemid . $this->params->get('pro_searchBody'))); $aFunction = array($this, 'generateAdminLinks'); $aArgs = array($oObj, $sCss); $iLifeTime = (int) $this->params->get('lifetime', '30') * 24 * 60 * 60; $aLinks = JchPlatformCache::getCallbackCache($sId, $iLifeTime, $aFunction, $aArgs); JCH_DEBUG ? JchPlatformProfiler::mark('afterGetAdminLinks plgSystem (JCH Optimize)') : null; return $aLinks; }
/** * Create and cache aggregated file if it doesn't exists. * * @param array $aFunction Name of function used to aggregate files * @param array $aArgs Arguments used by function above * @param string $sId Generated id to identify cached file * @return boolean True on success */ public function loadCache($aFunction, $aArgs, $sId) { $iLifeTime = (int) $this->params->get('cache_lifetime', '1') * 24 * 60 * 60; $bCached = JchPlatformCache::getCallbackCache($sId, $iLifeTime, $aFunction, $aArgs); return $bCached; }
/** * Aggregate contents of CSS and JS files * * @param array $aUrlArray Array of links of files * @param string $sType CSS or js * @return string Aggregarted contents * @throws Exception */ public function combineFiles($aUrlArray, $sType, $oCssParser) { $sContents = ''; $sLifetime = (int) $this->params->get('lifetime', '30') * 24 * 60 * 60; $this->bAsync = FALSE; $this->sAsyncUrl = ''; $oFileRetriever = JchOptimizeFileRetriever::getInstance(); foreach ($aUrlArray as $aUrl) { $sUrl = $this->prepareFileUrl($aUrl, $sType); JCH_DEBUG ? JchPlatformProfiler::start('CombineFile - ' . $sUrl) : null; if ($sType == 'js') { $sJsContents = $this->handleAsyncUrls($aUrl); if ($sJsContents === FALSE) { continue; } $sContents .= $sJsContents; unset($sJsContents); } if (isset($aUrl['id']) && $aUrl['id'] != '') { $function = array($this, 'cacheContent'); $args = array($aUrl, $sType, $oFileRetriever, $oCssParser, TRUE); $sCachedContent = JchPlatformCache::getCallbackCache($aUrl['id'], $sLifetime, $function, $args); $this->{$sType} .= $sCachedContent; if (!isset($aUrl['url']) && $this->sAsyncUrl != '' && $sType == 'js') { $this->sAsyncUrl = ''; } if ($this->sAsyncUrl == '') { $sContents .= $this->addCommentedUrl($sType, $aUrl) . '[[JCH_' . $aUrl['id'] . ']]' . $this->sLnEnd . 'DELIMITER'; } } else { $sContent = $this->cacheContent($aUrl, $sType, $oFileRetriever, $oCssParser, FALSE); $sContents .= $this->addCommentedUrl($sType, $aUrl) . $sContent . '|"LINE_END"|'; } JCH_DEBUG ? JchPlatformProfiler::stop('CombineFile - ' . $sUrl, TRUE) : null; } if ($this->bAsync) { $sContents = $this->getLoadScript() . $sContents; if ($this->sAsyncUrl != '') { $sContents .= $this->addCommentedUrl('js', $this->sAsyncUrl) . 'loadScript("' . $this->sAsyncUrl . '", function(){}); DELIMITER'; $this->sAsyncUrl = ''; } } return $sContents; }
/** * Aggregate contents of CSS and JS files * * @param array $aUrlArray Array of links of files * @param string $sType CSS or js * @return string Aggregarted contents * @throws Exception */ public function combineFiles($aUrlArray, $sType, $oCssParser) { global $_PROFILER; JCH_DEBUG ? JchPlatformProfiler::mark('beforeCombineFiles - ' . $sType . ' plgSystem (JCH Optimize)') : null; $sContents = ''; $sLifetime = (int) $this->params->get('lifetime', '30') * 24 * 60 * 60; $this->bAsync = FALSE; $this->sAsyncUrl = ''; $this->{$sType} = ''; $oFileRetriever = JchOptimizeFileRetriever::getInstance(); foreach ($aUrlArray as $aUrl) { if ($sType == 'js') { $sJsContents = $this->handleAsyncUrls($aUrl); if ($sJsContents === FALSE) { continue; } $sContents .= $sJsContents; unset($sJsContents); } if (isset($aUrl['id']) && $aUrl['id'] != '') { $function = array($this, 'cacheContent'); $args = array($aUrl, $sType, $oFileRetriever, $oCssParser); $sCachedContent = JchPlatformCache::getCallbackCache($aUrl['id'], $sLifetime, $function, $args); $this->{$sType} .= $sCachedContent; if (!isset($aUrl['url']) && $this->sAsyncUrl != '' && $sType == 'js') { $this->sAsyncUrl = ''; } if ($this->sAsyncUrl == '') { $sContents .= $this->addCommentedUrl($sType, $aUrl) . '[[JCH_' . $aUrl['id'] . ']]' . 'DELIMITER'; } } else { $sContent = $this->cacheContent($aUrl, $sType, $oFileRetriever, $oCssParser); $sContents .= $this->addCommentedUrl($sType, $aUrl) . $sContent . 'DELIMITER'; } } if ($this->bAsync) { $sContents = $this->getLoadScript() . $sContents; if ($this->sAsyncUrl != '') { $sContents .= $this->addCommentedUrl('js', $this->sAsyncUrl) . 'loadScript("' . $this->sAsyncUrl . '", function(){}); DELIMITER'; $this->sAsyncUrl = ''; } } JCH_DEBUG ? JchPlatformProfiler::mark('afterCombineFiles - ' . $sType . ' plgSystem (JCH Optimize)') : null; return $sContents; }
/** * Create and cache aggregated file if it doesn't exists, file will have * lifetime set in global configurations. * * @param array $aFunction Name of function used to aggregate files * @param array $aArgs Arguments used by function above * @param string $sId Generated id to identify cached file * @return boolean True on success */ public function loadCache($aFunction, $aArgs, $sId) { JCH_DEBUG ? JchPlatformProfiler::mark('beforeLoadCache plgSystem (JCH Optimize)') : null; $iLifeTime = (int) $this->params->get('lifetime', '30') * 24 * 60 * 60; $bCached = JchPlatformCache::getCallbackCache($sId, $iLifeTime, $aFunction, $aArgs); JCH_DEBUG ? JchPlatformProfiler::mark('afterLoadCache plgSystem (JCH Optimize)') : null; return $bCached; }