mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-09 11:44:10 +09:00
Add 'finalize' option to getCSSFileList() and getJSFileList(), to be used only by the final layout
This commit is contained in:
parent
1c43cbb126
commit
4290f5110c
3 changed files with 34 additions and 24 deletions
|
|
@ -2270,11 +2270,12 @@ class Context
|
||||||
* Returns the list of javascripts that matches the given type.
|
* Returns the list of javascripts that matches the given type.
|
||||||
*
|
*
|
||||||
* @param string $type Added position. (head:<head>..</head>, body:<body>..</body>)
|
* @param string $type Added position. (head:<head>..</head>, body:<body>..</body>)
|
||||||
|
* @param bool $finalize (optional)
|
||||||
* @return array Returns javascript file list. Array contains file, targetie.
|
* @return array Returns javascript file list. Array contains file, targetie.
|
||||||
*/
|
*/
|
||||||
public static function getJsFile($type = 'head')
|
public static function getJsFile($type = 'head', $finalize = false)
|
||||||
{
|
{
|
||||||
return self::$_instance->oFrontEndFileHandler->getJsFileList($type);
|
return self::$_instance->oFrontEndFileHandler->getJsFileList($type, $finalize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2322,11 +2323,12 @@ class Context
|
||||||
/**
|
/**
|
||||||
* Return a list of css files
|
* Return a list of css files
|
||||||
*
|
*
|
||||||
|
* @param bool $finalize (optional)
|
||||||
* @return array Returns css file list. Array contains file, media, targetie.
|
* @return array Returns css file list. Array contains file, media, targetie.
|
||||||
*/
|
*/
|
||||||
public static function getCSSFile()
|
public static function getCSSFile($finalize = false)
|
||||||
{
|
{
|
||||||
return self::$_instance->oFrontEndFileHandler->getCssFileList();
|
return self::$_instance->oFrontEndFileHandler->getCssFileList($finalize);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -359,9 +359,10 @@ class FrontEndFileHandler extends Handler
|
||||||
/**
|
/**
|
||||||
* Get css file list
|
* Get css file list
|
||||||
*
|
*
|
||||||
|
* @param bool $finalize (optional)
|
||||||
* @return array Returns css file list. Array contains file, media, targetie.
|
* @return array Returns css file list. Array contains file, media, targetie.
|
||||||
*/
|
*/
|
||||||
public function getCssFileList()
|
public function getCssFileList($finalize = false)
|
||||||
{
|
{
|
||||||
$map = &$this->cssMap;
|
$map = &$this->cssMap;
|
||||||
$mapIndex = &$this->cssMapIndex;
|
$mapIndex = &$this->cssMapIndex;
|
||||||
|
|
@ -370,25 +371,28 @@ class FrontEndFileHandler extends Handler
|
||||||
$this->_sortMap($map, $mapIndex);
|
$this->_sortMap($map, $mapIndex);
|
||||||
|
|
||||||
// Minify all scripts, and compile LESS/SCSS into CSS.
|
// Minify all scripts, and compile LESS/SCSS into CSS.
|
||||||
foreach ($map as $indexedMap)
|
if ($finalize)
|
||||||
{
|
{
|
||||||
foreach ($indexedMap as $file)
|
foreach ($map as $indexedMap)
|
||||||
{
|
{
|
||||||
$minify_this_file = !$file->isMinified && !$file->isExternalURL && !$file->isCachedScript && (($file->isCommon && $minify !== 'none') || $minify === 'all');
|
foreach ($indexedMap as $file)
|
||||||
if ($file->fileExtension === 'css')
|
|
||||||
{
|
{
|
||||||
$this->proc_CSS_JS($file, $minify_this_file);
|
$minify_this_file = !$file->isMinified && !$file->isExternalURL && !$file->isCachedScript && (($file->isCommon && $minify !== 'none') || $minify === 'all');
|
||||||
}
|
if ($file->fileExtension === 'css')
|
||||||
else
|
{
|
||||||
{
|
$this->proc_CSS_JS($file, $minify_this_file);
|
||||||
$this->proc_LESS_SCSS($file, $minify_this_file);
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->proc_LESS_SCSS($file, $minify_this_file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add all files to the final result.
|
// Add all files to the final result.
|
||||||
$result = array();
|
$result = array();
|
||||||
if ($concat && count($concat_list = $this->_concatMap($map)))
|
if ($concat && $finalize && count($concat_list = $this->_concatMap($map)))
|
||||||
{
|
{
|
||||||
foreach ($concat_list as $concat_fileset)
|
foreach ($concat_list as $concat_fileset)
|
||||||
{
|
{
|
||||||
|
|
@ -443,9 +447,10 @@ class FrontEndFileHandler extends Handler
|
||||||
* Get javascript file list
|
* Get javascript file list
|
||||||
*
|
*
|
||||||
* @param string $type Type of javascript. head, body
|
* @param string $type Type of javascript. head, body
|
||||||
|
* @param bool $finalize (optional)
|
||||||
* @return array Returns javascript file list. Array contains file, targetie.
|
* @return array Returns javascript file list. Array contains file, targetie.
|
||||||
*/
|
*/
|
||||||
public function getJsFileList($type = 'head')
|
public function getJsFileList($type = 'head', $finalize = false)
|
||||||
{
|
{
|
||||||
if($type == 'head')
|
if($type == 'head')
|
||||||
{
|
{
|
||||||
|
|
@ -463,20 +468,23 @@ class FrontEndFileHandler extends Handler
|
||||||
$this->_sortMap($map, $mapIndex);
|
$this->_sortMap($map, $mapIndex);
|
||||||
|
|
||||||
// Minify all scripts.
|
// Minify all scripts.
|
||||||
foreach ($map as $indexedMap)
|
if ($finalize)
|
||||||
{
|
{
|
||||||
foreach ($indexedMap as $file)
|
foreach ($map as $indexedMap)
|
||||||
{
|
{
|
||||||
if (!$file->isMinified && !$file->isExternalURL && !$file->isCachedScript && (($file->isCommon && $minify !== 'none') || $minify === 'all'))
|
foreach ($indexedMap as $file)
|
||||||
{
|
{
|
||||||
$this->proc_CSS_JS($file, true);
|
if (!$file->isMinified && !$file->isExternalURL && !$file->isCachedScript && (($file->isCommon && $minify !== 'none') || $minify === 'all'))
|
||||||
|
{
|
||||||
|
$this->proc_CSS_JS($file, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add all files to the final result.
|
// Add all files to the final result.
|
||||||
$result = array();
|
$result = array();
|
||||||
if ($concat && $type === 'head' && count($concat_list = $this->_concatMap($map)))
|
if ($concat && $finalize && $type === 'head' && count($concat_list = $this->_concatMap($map)))
|
||||||
{
|
{
|
||||||
foreach ($concat_list as $concat_fileset)
|
foreach ($concat_list as $concat_fileset)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -15,14 +15,14 @@
|
||||||
<title>{Context::getBrowserTitle()}</title>
|
<title>{Context::getBrowserTitle()}</title>
|
||||||
|
|
||||||
<!-- CSS -->
|
<!-- CSS -->
|
||||||
<block loop="Context::getCssFile() => $key, $css_file">
|
<block loop="Context::getCssFile(true) => $key, $css_file">
|
||||||
<block cond="$css_file['targetie']"><!--[if {$css_file['targetie']}]><block cond="stripos($css_file['targetie'], 'gt') === 0"><!--></block></block>
|
<block cond="$css_file['targetie']"><!--[if {$css_file['targetie']}]><block cond="stripos($css_file['targetie'], 'gt') === 0"><!--></block></block>
|
||||||
<link rel="stylesheet" href="{$css_file['file']}" media="{$css_file['media']}"|cond="$css_file['media'] != 'all'" />
|
<link rel="stylesheet" href="{$css_file['file']}" media="{$css_file['media']}"|cond="$css_file['media'] != 'all'" />
|
||||||
<block cond="$css_file['targetie']"><block cond="stripos($css_file['targetie'], 'gt') === 0"><!--</block><![endif]-->{"\n"}</block>
|
<block cond="$css_file['targetie']"><block cond="stripos($css_file['targetie'], 'gt') === 0"><!--</block><![endif]-->{"\n"}</block>
|
||||||
</block>
|
</block>
|
||||||
|
|
||||||
<!-- JS -->
|
<!-- JS -->
|
||||||
<block loop="Context::getJsFile() => $key, $js_file">
|
<block loop="Context::getJsFile('head', true) => $key, $js_file">
|
||||||
<block cond="$js_file['targetie']"><!--[if {$js_file['targetie']}]><block cond="stripos($js_file['targetie'], 'gt') === 0"><!--></block></block>
|
<block cond="$js_file['targetie']"><!--[if {$js_file['targetie']}]><block cond="stripos($js_file['targetie'], 'gt') === 0"><!--></block></block>
|
||||||
<script src="{$js_file['file']}"></script>
|
<script src="{$js_file['file']}"></script>
|
||||||
<block cond="$js_file['targetie']"><block cond="stripos($js_file['targetie'], 'gt') === 0"><!--</block><![endif]-->{"\n"}</block>
|
<block cond="$js_file['targetie']"><block cond="stripos($js_file['targetie'], 'gt') === 0"><!--</block><![endif]-->{"\n"}</block>
|
||||||
|
|
@ -70,7 +70,7 @@
|
||||||
<div id="rhymix_debug_button"></div>
|
<div id="rhymix_debug_button"></div>
|
||||||
|
|
||||||
<!-- BODY JS -->
|
<!-- BODY JS -->
|
||||||
<block loop="Context::getJsFile('body') => $key, $js_file">
|
<block loop="Context::getJsFile('body', true) => $key, $js_file">
|
||||||
<block cond="$js_file['targetie']"><!--[if {$js_file['targetie']}]></block>
|
<block cond="$js_file['targetie']"><!--[if {$js_file['targetie']}]></block>
|
||||||
<script src="{$js_file['file']}"></script>
|
<script src="{$js_file['file']}"></script>
|
||||||
<block cond="$js_file['targetie']"><![endif]-->{"\n"}</block>
|
<block cond="$js_file['targetie']"><![endif]-->{"\n"}</block>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue