diff --git a/classes/frontendfile/FrontEndFileHandler.class.php b/classes/frontendfile/FrontEndFileHandler.class.php
index 670579a9f..a0446b704 100644
--- a/classes/frontendfile/FrontEndFileHandler.class.php
+++ b/classes/frontendfile/FrontEndFileHandler.class.php
@@ -79,7 +79,7 @@ class FrontEndFileHandler extends Handler
* case css
* $args[0]: file name
* $args[1]: media
- * $args[2]: target IE
+ * $args[2]: target IE / source type hint
* $args[3]: index
* $args[4]: vars for LESS and SCSS
*
@@ -114,6 +114,16 @@ class FrontEndFileHandler extends Handler
}
}
+ if (preg_match('/IE/i', $args[2]))
+ {
+ $source_hint = '';
+ }
+ else
+ {
+ $source_hint = $args[2];
+ $args[2] = '';
+ }
+
$file = $this->getFileInfo($args[0], $args[2] ?? '', $args[1] ?? 'all', $args[4] ?? [], $isCommon);
$file->index = (int)($args[3] ?? 0);
@@ -128,7 +138,7 @@ class FrontEndFileHandler extends Handler
$map = &$this->cssMap;
$mapIndex = &$this->cssMapIndex;
- $this->_arrangeCssIndex($file->fileRealPath, $file);
+ $this->_arrangeCssIndex($file->fileRealPath, $file, $source_hint);
}
else if($file->fileExtension == 'js')
{
@@ -701,24 +711,32 @@ class FrontEndFileHandler extends Handler
*
* @param string $dirname
* @param object $file
+ * @param string $hint
* @return void
*/
- protected function _arrangeCssIndex($dirname, $file)
+ protected function _arrangeCssIndex($dirname, $file, $hint = '')
{
if ($file->index < -100000)
{
return;
}
- $dirname = substr($dirname, strlen(\RX_BASEDIR));
- if (strncmp($dirname, self::$assetdir . '/', strlen(self::$assetdir) + 1) === 0)
+ if ($hint)
{
- $dirname = substr($dirname, strlen(self::$assetdir) + 1);
+ $tmp = $hint;
+ }
+ else
+ {
+ $dirname = substr($dirname, strlen(\RX_BASEDIR));
+ if (strncmp($dirname, self::$assetdir . '/', strlen(self::$assetdir) + 1) === 0)
+ {
+ $dirname = substr($dirname, strlen(self::$assetdir) + 1);
+ }
+ $tmp = array_first(explode('/', strtr($dirname, '\\.', '//')));
}
- $tmp = array_first(explode('/', strtr($dirname, '\\.', '//')));
if ($tmp)
{
- $cssSortList = array('common' => -100000, 'layouts' => -90000, 'modules' => -80000, 'widgets' => -70000, 'addons' => -60000);
+ $cssSortList = array('common' => -100000, 'layouts' => -90000, 'm.layouts' => -90000, 'modules' => -80000, 'widgets' => -70000, 'addons' => -60000);
$file->index += isset($cssSortList[$tmp]) ? $cssSortList[$tmp] : 0;
}
}
diff --git a/classes/template/TemplateHandler.class.php b/classes/template/TemplateHandler.class.php
index 0d3f5a977..dfd22b89f 100644
--- a/classes/template/TemplateHandler.class.php
+++ b/classes/template/TemplateHandler.class.php
@@ -16,6 +16,7 @@ class TemplateHandler
private $file = NULL; ///< target file (fullpath)
private $web_path = NULL; ///< tpl file web path
private $compiled_file = NULL; ///< tpl file web path
+ private $source_type = NULL;
private $config = NULL;
private $skipTags = NULL;
private $handler_mtime = 0;
@@ -75,9 +76,9 @@ class TemplateHandler
$this->filename = null;
$this->file = null;
$this->compiled_file = null;
+ $this->source_type = null;
$this->config = new stdClass;
$this->skipTags = null;
- $this->compiled_file = null;
self::$rootTpl = null;
}
@@ -121,6 +122,7 @@ class TemplateHandler
// set compiled file name
$converted_path = ltrim(str_replace(array('\\', '..'), array('/', 'dotdot'), $tpl_file), '/');
$this->compiled_file = \RX_BASEDIR . 'files/cache/template/' . $converted_path . '.php';
+ $this->source_type = preg_match('!^((?:m\.)?[a-z]+)/!', $tpl_path, $matches) ? $matches[1] : null;
}
/**
@@ -874,7 +876,7 @@ class TemplateHandler
{
$metafile = isset($attr['target']) ? $attr['target'] : '';
$result = vsprintf("Context::loadFile(['%s', '%s', '%s', '%s']);", [
- $attr['target'] ?? '', $attr['type'] ?? '', $attr['targetie'] ?? '', $attr['index'] ?? '',
+ $attr['target'] ?? '', $attr['type'] ?? '', $attr['targetie'] ?? ($isRemote ? $this->source_type : ''), $attr['index'] ?? '',
]);
}
break;
@@ -892,7 +894,7 @@ class TemplateHandler
$metafile = isset($attr['target']) ? $attr['target'] : '';
$metavars = isset($attr['vars']) ? ($attr['vars'] ? self::_replaceVar($attr['vars']) : '') : '';
$result = vsprintf("Context::loadFile(['%s', '%s', '%s', '%s', %s]);", [
- $attr['target'] ?? '', $attr['media'] ?? '', $attr['targetie'] ?? '', $attr['index'] ?? '',
+ $attr['target'] ?? '', $attr['media'] ?? '', $attr['targetie'] ?? ($isRemote ? $this->source_type : ''), $attr['index'] ?? '',
isset($attr['vars']) ? ($attr['vars'] ? self::_replaceVar($attr['vars']) : '[]') : '[]',
]);
}
diff --git a/tests/unit/classes/TemplateHandlerTest.php b/tests/unit/classes/TemplateHandlerTest.php
index 0dc5e4b95..bdc7a3a57 100644
--- a/tests/unit/classes/TemplateHandlerTest.php
+++ b/tests/unit/classes/TemplateHandlerTest.php
@@ -175,7 +175,7 @@ class TemplateHandlerTest extends \Codeception\TestCase\Test
// issue 103
array(
'',
- '?>'
+ '?>'
),
// issue 135
array(
@@ -499,7 +499,7 @@ class TemplateHandlerTest extends \Codeception\TestCase\Test
$result = $tmpl->compileDirect(__DIR__ . '/template', 'sample.html');
$result = trim($result);
- $this->assertEquals($result, $this->prefix.PHP_EOL.'if($__Context->has_blog){ ?>Taggon\'s blog'.PHP_EOL.'');
+ $this->assertEquals($result, $this->prefix.PHP_EOL.'if($__Context->has_blog){ ?>Taggon\'s blog'.PHP_EOL.'');
}
}