Skip to content

Commit

Permalink
Fixed a possible bug in the Resouce class
Browse files Browse the repository at this point in the history
  • Loading branch information
mystralkk committed Aug 15, 2019
1 parent 94f94fd commit 1333de8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion public_html/lib-common.php
Expand Up @@ -520,7 +520,7 @@
unset($theme_config, $func);

// Forcibly enable Resource cache if current theme is compatible with Modern Curve theme
if ($_SCRIPTS->getCompatibilityWithMC()) {
if ($_SCRIPTS->isCompatibleWithModernCurveTheme()) {
$_CONF['cache_resource'] = true;
}

Expand Down
19 changes: 10 additions & 9 deletions system/classes/Resource.php
Expand Up @@ -8,7 +8,7 @@
// | |
// | Geeklog class to include javascript, javascript files and css files. |
// +---------------------------------------------------------------------------+
// | Copyright (C) 2000-2018 by the following authors: |
// | Copyright (C) 2000-2019 by the following authors: |
// | |
// | Authors: Tom Homer, tomhomer AT gmail DOT com |
// | Kenji ITO, mystralkk AT gmail DOT com |
Expand All @@ -34,6 +34,7 @@

use JSMin\JSMin;
use MatthiasMullie\Minify;
use Mobile_Detect;

class Resource
{
Expand Down Expand Up @@ -568,7 +569,7 @@ public function setCssFile($name, $file, $constant = true, $attributes = array()

$attributes = $this->checkCssAttributes($attributes);

if ($this->isExternal($file) && array_search($file, array_column($this->localJsFiles[$externalCssFiles], 'file')) == 0) {
if ($this->isExternal($file) && array_search($file, array_column($this->localJsFiles, 'file')) == 0) {
$this->externalCssFiles[] = array(
'file' => $file,
'attributes' => $attributes,
Expand Down Expand Up @@ -615,7 +616,7 @@ public function setCSS($css)
/**
* Make a key for caching based on contents
*
* @param array $contents
* @param string $contents
* @return string
*/
private function makeCacheKey($contents)
Expand Down Expand Up @@ -757,7 +758,7 @@ private function minifyCSS(array $files)
$right = 'right';
}

if ($this->getCompatibilityWithMC()) {
if ($this->isCompatibleWithModernCurveTheme()) {
$search = array('{left}', '{right}', '../images/', './images/');
$replace = array($left, $right, './images/', '../images/');
$contents = str_replace($search, $replace, $contents);
Expand Down Expand Up @@ -851,7 +852,7 @@ private function makeFileServerTag(array $files, $isCss = true)

// Minify JavaScript
$retval = '';
$excludedfiles = '';
$excludedFiles = '';

// *******************************
// Exclude files for advanced editor
Expand All @@ -869,7 +870,7 @@ private function makeFileServerTag(array $files, $isCss = true)

foreach ($temp as $file) {
if (stripos($file['file'], $editorPath) === 0) {
$excludedfiles .= sprintf(self::JS_TAG_TEMPLATE, $this->config['site_url'] . $file['file']) . PHP_EOL;
$excludedFiles .= sprintf(self::JS_TAG_TEMPLATE, $this->config['site_url'] . $file['file']) . PHP_EOL;
} else {
$files[] = $file;
}
Expand Down Expand Up @@ -918,7 +919,7 @@ private function makeFileServerTag(array $files, $isCss = true)
}

// Add excluded files at the end
$retval .= $excludedfiles;
$retval .= $excludedFiles;

return $retval;
}
Expand Down Expand Up @@ -1161,7 +1162,7 @@ public function getHeader()
$lang = array_merge($lang, $this->lang);
}

$detect = new \Mobile_Detect;
$detect = new Mobile_Detect;
$device = array(
'isMobile' => $detect->isMobile(),
'isTablet' => $detect->isTablet(),
Expand Down Expand Up @@ -1245,7 +1246,7 @@ public function getFooter()
*
* @return bool
*/
public function getCompatibilityWithMC()
public function isCompatibleWithModernCurveTheme()
{
return $this->compatibleWithMC;
}
Expand Down

0 comments on commit 1333de8

Please sign in to comment.