/** * */ public function getAdminObject($oParser) { JCH_DEBUG ? JchPlatformProfiler::start('GetAdminObject') : null; try { $oAdmin = new JchOptimizeAdmin($this->params); $oAdmin->getAdminLinks($oParser, JchPlatformUtility::menuId()); } catch (Exception $ex) { JchOptimizeLogger::log($ex->getMessage(), $this->params); } JCH_DEBUG ? JchPlatformProfiler::stop('GetAdminObject', TRUE) : null; }
/** * * @return string */ protected function getInput() { //JCH_DEBUG ? JchPlatformProfiler::mark('beforeGetInput - ' . $this->type) : null; $aButtons = $this->getButtons(); $sField = JchOptimizeAdmin::generateIcons($aButtons); // JCH_DEBUG ? JchPlatformProfiler::mark('beforeGetInput - ' . $this->type) : null; return $sField; }
/** * * @param type $aUrl * @param type $sType * @return type */ public function prepareFileUrl($aUrl, $sType) { $sUrl = isset($aUrl['url']) ? JchOptimizeAdmin::prepareFileValues($aUrl['url'], '', 40) : ($sType == 'css' ? 'Style' : 'Script') . ' Declaration'; return $sUrl; }
/** * Get aggregated and possibly minified content from js and css files * * @param array $aUrlArray Array of urls of css or js files for aggregation * @param string $sType css or js * @return string Aggregated (and possibly minified) contents of files */ public function getContents($aUrlArray, $sType, $oParser) { $oCssParser = new JchOptimizeCssParser($this->params, $this->bBackend); $sCriticalCss = ''; $aSpriteCss = array(); $aFontFace = array(); $aContentsArray = array(); foreach ($aUrlArray as $index => $aUrlInnerArray) { $sContents = $this->combineFiles($aUrlInnerArray, $sType, $oCssParser); $sContents = $this->prepareContents($sContents); $aContentsArray[$index] = $sContents; } if ($sType == 'css') { if ($this->params->get('csg_enable', 0)) { try { $oSpriteGenerator = new JchOptimizeSpriteGenerator($this->params); $aSpriteCss = $oSpriteGenerator->getSprite($this->{$sType}); } catch (Exception $ex) { JchOptimizeLogger::log($ex->getMessage(), $this->params); $aSpriteCss = array(); } } if ($this->params->get('pro_optimizeCssDelivery', '0')) { if (!empty($aSpriteCss)) { $this->{$sType} = str_replace($aSpriteCss['needles'], $aSpriteCss['replacements'], $this->{$sType}); } $oParser->params->set('pro_InlineScripts', '0'); $oParser->params->set('pro_InlineStyles', '0'); $sHtml = $oParser->cleanHtml(); $aCssContents = $oCssParser->optimizeCssDelivery($this->{$sType}, $sHtml); $sCriticalCss .= $oCssParser->sortImports($aCssContents['criticalcss']); $sCriticalCss = $sCriticalCss; $aFontFace = preg_split('#}\\K[^@]*+#', $aCssContents['font-face'], -1, PREG_SPLIT_NO_EMPTY); } } try { $oAdmin = new JchOptimizeAdmin($this->params); $oAdmin->getAdminLinks($oParser, JchPlatformUtility::get('Itemid'), $this->css); } catch (Exception $ex) { JchOptimizeLogger($ex->getMessage(), $this->params); } $aContents = array('filemtime' => JchPlatformUtility::unixCurrentDate(), 'file' => $aContentsArray, 'criticalcss' => $sCriticalCss, 'spritecss' => $aSpriteCss, 'font-face' => $aFontFace); return $aContents; }