Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Geeklog-Core/geeklog
Browse files Browse the repository at this point in the history
  • Loading branch information
eSilverStrike committed Nov 21, 2017
2 parents a79fb30 + d88d9d5 commit c4619ac
Showing 1 changed file with 33 additions and 28 deletions.
61 changes: 33 additions & 28 deletions system/classes/Resource.php
Expand Up @@ -669,16 +669,26 @@ private function getLatestModifiedTime(array $absolutePaths)
}

/**
* Minify CSS for Modern Curve theme
* Minify CSS
*
* @param array $files
* @return string
* @note Currently, this method does NOT minify CSS code
*/
private function minifyCSSForModernCurve(array $files)
private function minifyCSS(array $files)
{
global $LANG_DIRECTION;

if ($this->debug) {
$retval = '';

foreach ($files as $file) {
$retval .= $this->buildLinkTag($this->config['site_url'] . $file['file'], array()) . PHP_EOL;
}

return $retval;
}

$contents = '';
$relativePaths = array();

Expand All @@ -692,6 +702,8 @@ private function minifyCSSForModernCurve(array $files)
}
}

$theme = strtolower($this->config['theme']);

// Replace {left} and {right} place-holders
if (isset($LANG_DIRECTION) && ($LANG_DIRECTION === 'rtl')) {
$dir = 'rtl';
Expand All @@ -702,12 +714,27 @@ private function minifyCSSForModernCurve(array $files)
$left = 'left';
$right = 'right';
}
$contents = str_replace(array('{left}', '{right}'), array($left, $right), $contents);

if ($theme === 'modern_curve') {
$contents = str_replace(array('{left}', '{right}'), array($left, $right), $contents);
}

// Rewrite image paths
$contents = str_ireplace(' url("./images/', ' url("layout/modern_curve/images/', $contents);
$contents = str_ireplace(" url('./images/", " url('layout/modern_curve/images/", $contents);
$contents = str_ireplace(" url('jquery_ui/images/", " url('layout/modern_curve/jquery_ui/images/", $contents);
$contents = str_ireplace(' url("./images/', ' url("layout/' . $theme . '/images/', $contents);
$contents = str_ireplace(" url('./images/", " url('layout/' . $theme . '/images/", $contents);
$contents = str_ireplace(' url("../images/', ' url("layout/' . $theme . '/images/', $contents);
$contents = str_ireplace(" url('../images/", " url('layout/' . $theme . '/images/", $contents);
$contents = str_ireplace(" url('jquery_ui/images/", " url('layout/' . $theme . '/jquery_ui/images/", $contents);
$contents = str_ireplace('url("../fonts/', 'url("vendor/uikit/fonts/', $contents);

// Unify lien ends
$contents = str_replace(array("\r\n", "\r"), "\n", $contents);

// strip comments
$contents = preg_replace("@/\*[^!].*?\*/@sm", '', $contents);

// strip indentation
$contents = preg_replace("@\s*\n+\s*@sm", "\n", $contents);

$key = $this->makeCacheKey($relativePaths) . $dir;
$data = array(
Expand All @@ -722,28 +749,6 @@ private function minifyCSSForModernCurve(array $files)
return $retval;
}

/**
* Minify CSS
*
* @param array $files
* @return string
* @note Currently, this method does NOT minify CSS code
*/
private function minifyCSS(array $files)
{
if (strcasecmp($this->config['theme'],'modern_curve') === 0) {
return $this->minifyCSSForModernCurve($files);
}

$retval = '';

foreach ($files as $file) {
$retval .= $this->buildLinkTag($this->config['site_url'] . $file['file'], array()) . PHP_EOL;
}

return $retval;
}

/**
* Minify file contents
*
Expand Down

0 comments on commit c4619ac

Please sign in to comment.