/** * Gibt mehrere JS Dateien kombiniert und minifiziert zurück * * @global array $REX * @param string $combinedFile - der Name der zu erstellenden Datei * @param array $sourceFiles - ein Array mit allen Quelldateien * @return string - Dateiname inkl. Pfad zur generierten Datei */ public static function getCombinedJSMinFile($combinedFile, $sourceFiles) { global $REX; if (self::checkINIBoolValue($REX['ADDON']['min42']['conf']['minifyJS'])) { return res42min::getCombinedJSMinFile($combinedFile, $sourceFiles); } return res42::getCombinedJSFile($combinedFile, $sourceFiles); }
public static function init() { // called only by seo42 addon global $REX; $cssDir = $REX['ADDON']['seo42']['settings']['css_dir']; $jsDir = $REX['ADDON']['seo42']['settings']['js_dir']; $imagesDir = $REX['ADDON']['seo42']['settings']['images_dir']; $iconsDir = $REX['ADDON']['seo42']['settings']['icons_dir']; self::$cssDir = self::prepareDir($cssDir); self::$jsDir = self::prepareDir($jsDir); self::$imagesDir = self::prepareDir($imagesDir); self::$iconsDir = self::prepareDir($iconsDir); self::$cssPath = self::preparePath($cssDir); self::$jsPath = self::preparePath($jsDir); self::$imagesPath = self::preparePath($imagesDir); self::$iconsPath = self::preparePath($iconsDir); self::$rewriterEnabled = $REX['ADDON']['seo42']['settings']['rewriter']; }
protected static function compileCSS($sourceFileWithPath, $cssFileWithPath, $sourceFileType, $vars) { global $REX; if (!file_exists($sourceFileWithPath)) { return; } // get content of source file $sourceFileContent = file_get_contents($sourceFileWithPath); // strip comments out $sourceFileContent = parent::stripCSSComments($sourceFileContent); // get file path $path = pathinfo($sourceFileWithPath); // compile source file to css try { if ($sourceFileType == 'scss') { // EP for scss string compilation $compiledCSS = rex_register_extension_point('SEO42_COMPILE_SCSS', $sourceFileContent, array('vars' => $vars)); if ($sourceFileContent == $compiledCSS) { // include compiler if (!class_exists('scssc')) { require_once $REX['INCLUDE_PATH'] . '/addons/seo42/classes/class.scssc.inc.php'; } $formatter = new scss_formatter(); $formatter->indentChar = "\t"; $formatter->close = "}" . PHP_EOL; $formatter->assignSeparator = ": "; $scss = new scssc(); $scss->setFormatter($formatter); $compiledCSS = $scss->compile($sourceFileContent); } } else { // EP for less string compilation $compiledCSS = rex_register_extension_point('SEO42_COMPILE_LESS', $sourceFileContent, array('vars' => $vars, 'path' => $path['dirname'])); if ($sourceFileContent == $compiledCSS) { // include compiler if (!class_exists('lessc')) { require_once $REX['INCLUDE_PATH'] . '/addons/seo42/classes/class.lessc.inc.php'; } $formatter = new lessc_formatter_classic(); $formatter->indentChar = "\t"; $formatter->close = "}" . PHP_EOL; $formatter->assignSeparator = ": "; $less = new lessc(); $less->setImportDir($path['dirname']); $less->setFormatter($formatter); $less->setPreserveComments(true); $less->setVariables($vars); $compiledCSS = $less->compile($sourceFileContent); } } } catch (Exception $e) { echo '" />'; // close tag as we are probably in an open link tag in head section of website echo '<p style="margin: 5px;"><code>'; echo '<strong>' . strtoupper($sourceFileType) . ' Compile Error:</strong><br/>'; echo $e->getMessage(); echo '</code></p>'; exit; } /* * min */ $compiledCSS = self::getMinifiedContent($compiledCSS, 'css'); // write css $fileHandle = fopen($cssFileWithPath, 'w'); fwrite($fileHandle, $compiledCSS); fclose($fileHandle); #file_put_contents($cssFileWithPath, $compiledCSS); }
public static function getJSCodeFromFile($file, $simpleMinify = true) { return res42::getJSCodeFromFile($file, $simpleMinify); }