Skip to content

Commit

Permalink
Fixed Resource class to support Modern Curve theme
Browse files Browse the repository at this point in the history
  • Loading branch information
mystralkk committed Nov 19, 2017
1 parent a970c2f commit 7239f31
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 3 deletions.
6 changes: 3 additions & 3 deletions public_html/layout/modern_curve/css/navbar/navbar.css
Expand Up @@ -78,7 +78,7 @@ ul.navbar-breadcrumbs li a {
border-top-right-radius: 5px;

border: 1px solid #c5dbec;
background: #dfeffc url(jquery_ui/images/ui-bg_glass_85_dfeffc_1x400.png) 50% 50% repeat-x;
background: #dfeffc url('jquery_ui/images/ui-bg_glass_85_dfeffc_1x400.png') 50% 50% repeat-x;
font-weight: bold;
color: #2e6e9e;

Expand All @@ -98,7 +98,7 @@ ul.navbar-breadcrumbs li a {

#navcontainer ul li a#current {
border: 1px solid #79b7e7;
background: #f5f8f9 url(jquery_ui/images/ui-bg_inset-hard_100_f5f8f9_1x100.png) 50% 50% repeat-x;
background: #f5f8f9 url('jquery_ui/images/ui-bg_inset-hard_100_f5f8f9_1x100.png') 50% 50% repeat-x;
font-weight: bold;
padding-bottom: 1px;
margin-bottom: 0;
Expand All @@ -111,7 +111,7 @@ ul.navbar-breadcrumbs li a {

#navcontainer ul li a:hover {
border: 1px solid #79b7e7;
background: #d0e5f5 url(jquery_ui/images/ui-bg_glass_75_d0e5f5_1x400.png) 50% 50% repeat-x;
background: #d0e5f5 url('jquery_ui/images/ui-bg_glass_75_d0e5f5_1x400.png') 50% 50% repeat-x;
font-weight: bold;
color: #1d5987;
}
58 changes: 58 additions & 0 deletions system/classes/Resource.php
Expand Up @@ -668,6 +668,60 @@ private function getLatestModifiedTime(array $absolutePaths)
return $retval;
}

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

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

// Concatenate all CSS files
foreach ($files as $file) {
$chunk = @file_get_contents($this->config['path_html'] . $file['file']);

if ($chunk !== false) {
$relativePaths[] = $file['file'];
$contents .= $chunk . PHP_EOL;
}
}

// Replace {left} and {right} place-holders
if (isset($LANG_DIRECTION) && ($LANG_DIRECTION === 'rtl')) {
$dir = 'rtl';
$left = 'right';
$right = 'left';
} else {
$dir = 'ltr';
$left = 'left';
$right = 'right';
}
$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);

$key = $this->makeCacheKey($relativePaths) . $dir;
$data = array(
'createdAt' => microtime(true),
'data' => $contents,
'paths' => $relativePaths,
'type' => 'c',
);
Cache::set($key, $data);
$retval = $this->buildLinkTag($this->config['site_url'] . '/r.php?k=' . $key, array());

return $retval;
}

/**
* Minify CSS
*
Expand All @@ -677,6 +731,10 @@ private function getLatestModifiedTime(array $absolutePaths)
*/
private function minifyCSS(array $files)
{
if (strcasecmp($this->config['theme'],'modern_curve') === 0) {
return $this->minifyCSSForModernCurve($files);
}

$retval = '';

foreach ($files as $file) {
Expand Down

0 comments on commit 7239f31

Please sign in to comment.