/** * * @return string */ public static function fileTree() { $root = JchPlatformPaths::rootPath(); $dir = urldecode(JchPlatformUtility::get('dir', '', 'string', 'post')); $dir = JchPlatformUtility::decrypt($dir); $response = ''; if (file_exists($root . $dir)) { $files = scandir($root . $dir); natcasesort($files); if (count($files) > 2) { /* The 2 accounts for . and .. */ $response .= '<ul class="jqueryFileTree" style="display: none; ">'; // All dirs foreach ($files as $file) { if (file_exists($root . $dir . $file) && $file != '.' && $file != '..' && is_dir($root . $dir . $file)) { $response .= '<li class="directory collapsed"><a href="#" rel="' . JchPlatformUtility::encrypt($dir . $file . '/') . '">' . htmlentities($file) . '</a></li>'; } } // All files foreach ($files as $file) { if (file_exists($root . $dir . $file) && $file != '.' && $file != '..' && !is_dir($root . $dir . $file)) { $ext = preg_replace('/^.*\\./', '', $file); $response .= '<li class="file ext_' . $ext . '"><a href="#" rel="' . JchPlatformUtility::encrypt($dir . $file) . '">' . htmlentities($file) . '</a></li>'; } } $response .= '</ul>'; } } return $response; }
/** * */ public static function menuId() { return JchPlatformUtility::get('Itemid'); }
/** * 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; }
/** * * @return string */ public static function fileTree() { $root = rtrim(JchPlatformPaths::rootPath(), '/\\'); $dir = urldecode(JchPlatformUtility::get('dir', '', 'string', 'post')); $view = urldecode(JchPlatformUtility::get('view', '', 'string', 'post')); $initial = urldecode(JchPlatformUtility::get('initial', '0', 'string', 'post')); $dir = JchPlatformUtility::decrypt($dir) . '/'; if ($view != 'tree') { $header = '<div id="files-container-header"><ul class="jqueryFileTree"><li><span><root>' . $dir . '</span></li>'; $header .= '<li class="check-all"><span><input type="checkbox"></span><span><em>Check all</em></span>' . '<span><em>' . JchPlatformUtility::translate('Width') . ' (px)</em></span>' . '<span><em>' . JchPlatformUtility::translate('Height') . ' (px)</em></span></li></ul></div><div class="files-content">'; $display = ''; } else { $display = 'style="display: none;"'; $header = ''; } $response = ''; if (file_exists($root . $dir)) { $files = scandir($root . $dir); // $files = JchPlatformUtility::lsFiles($root . $dir, '\.(?:gif|jpe?g|png)$', FALSE); natcasesort($files); if (count($files) > 2) { /* The 2 accounts for . and .. */ $response .= ''; $response = $header; if ($initial && $view == 'tree') { $response .= '<div class="files-content"><ul class="jqueryFileTree">'; $response .= '<li class="directory expanded"><a href="#" rel=""><root></a>'; } $response .= '<ul class="jqueryFileTree" ' . $display . '>'; foreach ($files as $file) { if (file_exists($root . $dir . $file) && $file != '.' && $file != '..' && is_dir($root . $dir . $file)) { $response .= '<li class="directory collapsed">' . self::item($file, $dir, $view, 'dir') . '</li>'; } } // All files if ($view != 'tree') { foreach ($files as $file) { if (file_exists($root . $dir . $file) && preg_match('#\\.(?:gif|jpe?g|png|GIF|JPE?G|PNG)$#', $file) && !is_dir($root . $dir . $file)) { $ext = preg_replace('/^.*\\./', '', $file); $response .= '<li class="file ext_' . strtolower($ext) . '">' . self::item($file, $dir, $view, 'file') . '</li>'; } } } $response .= '</ul>'; if ($initial && $view == 'tree') { $response .= '</li></ul></div>'; } } } return $response; }