mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-09 11:44:10 +09:00
Remove support for targetie attribute on assets
This commit is contained in:
parent
d34d08438f
commit
9e9adcdb43
8 changed files with 95 additions and 193 deletions
|
|
@ -984,13 +984,16 @@ class Context
|
||||||
* @see arrayConvWalkCallback will replaced array_walk_recursive in >=PHP5
|
* @see arrayConvWalkCallback will replaced array_walk_recursive in >=PHP5
|
||||||
* @return object converted object
|
* @return object converted object
|
||||||
*/
|
*/
|
||||||
public static function doConvertEncoding(&$val, $key = null, $charset)
|
public static function doConvertEncoding(&$val, $key = null, $charset = 'CP949')
|
||||||
{
|
{
|
||||||
if (is_array($val))
|
if (is_array($val))
|
||||||
{
|
{
|
||||||
array_walk($val,'Context::doConvertEncoding',$charset);
|
array_walk($val,'Context::doConvertEncoding', $charset);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$val = iconv($charset, 'UTF-8', $val);
|
||||||
}
|
}
|
||||||
else $val = iconv($charset,'UTF-8',$val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2074,12 +2077,12 @@ class Context
|
||||||
* case js :
|
* case js :
|
||||||
* $args[0]: file name,
|
* $args[0]: file name,
|
||||||
* $args[1]: type (head | body),
|
* $args[1]: type (head | body),
|
||||||
* $args[2]: target IE,
|
* $args[2]: unused,
|
||||||
* $args[3]: index
|
* $args[3]: index
|
||||||
* case css :
|
* case css :
|
||||||
* $args[0]: file name,
|
* $args[0]: file name,
|
||||||
* $args[1]: media,
|
* $args[1]: media,
|
||||||
* $args[2]: target IE,
|
* $args[2]: source type hint,
|
||||||
* $args[3]: index
|
* $args[3]: index
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
@ -2097,13 +2100,13 @@ class Context
|
||||||
* Unload front end file
|
* Unload front end file
|
||||||
*
|
*
|
||||||
* @param string $file File name with path
|
* @param string $file File name with path
|
||||||
* @param string $targetIe Target IE
|
* @param string $unused
|
||||||
* @param string $media Media query
|
* @param string $media Media query
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function unloadFile($file, $targetIe = '', $media = 'all')
|
public static function unloadFile($file, $unused = '', $media = 'all')
|
||||||
{
|
{
|
||||||
self::$_oFrontEndFileHandler->unloadFile($file, $targetIe, $media);
|
self::$_oFrontEndFileHandler->unloadFile($file, '', $media);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2122,15 +2125,15 @@ class Context
|
||||||
*
|
*
|
||||||
* @deprecated
|
* @deprecated
|
||||||
* @param string $file File name with path
|
* @param string $file File name with path
|
||||||
* @param string $optimized optimized (That seems to not use)
|
* @param string $unused1
|
||||||
* @param string $targetie target IE
|
* @param string $unused2
|
||||||
* @param string $index index
|
* @param string $index index
|
||||||
* @param string $type Added position. (head:<head>..</head>, body:<body>..</body>)
|
* @param string $type Added position. (head:<head>..</head>, body:<body>..</body>)
|
||||||
* @param bool $isRuleset Use ruleset
|
* @param bool $isRuleset Use ruleset
|
||||||
* @param string $autoPath If path not readed, set the path automatically.
|
* @param string $autoPath If path not readed, set the path automatically.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function addJsFile($file, $optimized = FALSE, $targetie = '', $index = 0, $type = 'head', $isRuleset = FALSE, $autoPath = null)
|
public static function addJsFile($file, $unused1 = '', $unused2 = '', $index = 0, $type = 'head', $isRuleset = FALSE, $autoPath = null)
|
||||||
{
|
{
|
||||||
if($isRuleset)
|
if($isRuleset)
|
||||||
{
|
{
|
||||||
|
|
@ -2147,7 +2150,7 @@ class Context
|
||||||
$file = $validator->getJsPath();
|
$file = $validator->getJsPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
self::$_oFrontEndFileHandler->loadFile(array($file, $type, $targetie, $index));
|
self::$_oFrontEndFileHandler->loadFile(array($file, $type, '', $index));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2155,13 +2158,11 @@ class Context
|
||||||
*
|
*
|
||||||
* @deprecated
|
* @deprecated
|
||||||
* @param string $file File name with path
|
* @param string $file File name with path
|
||||||
* @param string $optimized optimized (That seems to not use)
|
|
||||||
* @param string $targetie target IE
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function unloadJsFile($file, $optimized = FALSE, $targetie = '')
|
public static function unloadJsFile($file)
|
||||||
{
|
{
|
||||||
self::$_oFrontEndFileHandler->unloadFile($file, $targetie);
|
self::$_oFrontEndFileHandler->unloadFile($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2216,7 +2217,7 @@ class Context
|
||||||
*
|
*
|
||||||
* @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)
|
* @param bool $finalize (optional)
|
||||||
* @return array Returns javascript file list. Array contains file, targetie.
|
* @return array Returns javascript file list.
|
||||||
*/
|
*/
|
||||||
public static function getJsFile($type = 'head', $finalize = false)
|
public static function getJsFile($type = 'head', $finalize = false)
|
||||||
{
|
{
|
||||||
|
|
@ -2228,16 +2229,16 @@ class Context
|
||||||
*
|
*
|
||||||
* @deprecated
|
* @deprecated
|
||||||
* @param string $file File name with path
|
* @param string $file File name with path
|
||||||
* @param string $optimized optimized (That seems to not use)
|
* @param string $unused1
|
||||||
* @param string $media Media query
|
* @param string $media Media query
|
||||||
* @param string $targetie target IE
|
* @param string $unused2
|
||||||
* @param string $index index
|
* @param string $index index
|
||||||
* @return void
|
* @return void
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function addCSSFile($file, $optimized = FALSE, $media = 'all', $targetie = '', $index = 0)
|
public static function addCSSFile($file, $unused1 = '', $media = 'all', $unused2 = '', $index = 0)
|
||||||
{
|
{
|
||||||
self::$_oFrontEndFileHandler->loadFile(array($file, $media, $targetie, $index));
|
self::$_oFrontEndFileHandler->loadFile(array($file, $media, '', $index));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2245,14 +2246,13 @@ class Context
|
||||||
*
|
*
|
||||||
* @deprecated
|
* @deprecated
|
||||||
* @param string $file File name with path
|
* @param string $file File name with path
|
||||||
* @param string $optimized optimized (That seems to not use)
|
* @param string $unused
|
||||||
* @param string $media Media query
|
* @param string $media Media query
|
||||||
* @param string $targetie target IE
|
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function unloadCSSFile($file, $optimized = FALSE, $media = 'all', $targetie = '')
|
public static function unloadCSSFile($file, $unused = '', $media = 'all')
|
||||||
{
|
{
|
||||||
self::$_oFrontEndFileHandler->unloadFile($file, $targetie, $media);
|
self::$_oFrontEndFileHandler->unloadFile($file, '', $media);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2269,7 +2269,7 @@ class Context
|
||||||
* Return a list of css files
|
* Return a list of css files
|
||||||
*
|
*
|
||||||
* @param bool $finalize (optional)
|
* @param bool $finalize (optional)
|
||||||
* @return array Returns css file list. Array contains file, media, targetie.
|
* @return array Returns css file list.
|
||||||
*/
|
*/
|
||||||
public static function getCSSFile($finalize = false)
|
public static function getCSSFile($finalize = false)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -74,12 +74,12 @@ class FrontEndFileHandler extends Handler
|
||||||
* case js
|
* case js
|
||||||
* $args[0]: file name
|
* $args[0]: file name
|
||||||
* $args[1]: type (head | body)
|
* $args[1]: type (head | body)
|
||||||
* $args[2]: target IE
|
* $args[2]: unused (previously targetIe)
|
||||||
* $args[3]: index
|
* $args[3]: index
|
||||||
* case css
|
* case css
|
||||||
* $args[0]: file name
|
* $args[0]: file name
|
||||||
* $args[1]: media
|
* $args[1]: media
|
||||||
* $args[2]: target IE / source type hint
|
* $args[2]: source type hint
|
||||||
* $args[3]: index
|
* $args[3]: index
|
||||||
* $args[4]: vars for LESS and SCSS
|
* $args[4]: vars for LESS and SCSS
|
||||||
* </pre>
|
* </pre>
|
||||||
|
|
@ -228,20 +228,18 @@ class FrontEndFileHandler extends Handler
|
||||||
$file->isMinified = true;
|
$file->isMinified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process targetIe and media attributes
|
// Since Rhymix 2.1, targetIe is always empty
|
||||||
$file->targetIe = $targetIe;
|
$file->targetIe = '';
|
||||||
|
|
||||||
|
// Process media attributes and generate the key
|
||||||
if($file->fileExtension == 'css' || $file->fileExtension == 'less' || $file->fileExtension == 'scss')
|
if($file->fileExtension == 'css' || $file->fileExtension == 'less' || $file->fileExtension == 'scss')
|
||||||
{
|
{
|
||||||
$file->media = $media;
|
$file->media = $media ?: 'all';
|
||||||
if(!$file->media)
|
$file->key = sprintf('%s/%s:%s', $file->filePath, $file->keyName, $file->media);
|
||||||
{
|
|
||||||
$file->media = 'all';
|
|
||||||
}
|
|
||||||
$file->key = sprintf('%s/%s:%s:%s', $file->filePath, $file->keyName, $file->targetIe, $file->media);
|
|
||||||
}
|
}
|
||||||
else if($file->fileExtension == 'js')
|
else if($file->fileExtension == 'js')
|
||||||
{
|
{
|
||||||
$file->key = sprintf('%s/%s:%s', $file->filePath, $file->keyName, $file->targetIe);
|
$file->key = sprintf('%s/%s', $file->filePath, $file->keyName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $file;
|
return $file;
|
||||||
|
|
@ -427,7 +425,7 @@ class FrontEndFileHandler extends Handler
|
||||||
* Get css file list
|
* Get css file list
|
||||||
*
|
*
|
||||||
* @param bool $finalize (optional)
|
* @param bool $finalize (optional)
|
||||||
* @return array Returns css file list. Array contains file, media, targetie.
|
* @return array Returns css file list.
|
||||||
*/
|
*/
|
||||||
public function getCssFileList($finalize = false)
|
public function getCssFileList($finalize = false)
|
||||||
{
|
{
|
||||||
|
|
@ -471,7 +469,7 @@ class FrontEndFileHandler extends Handler
|
||||||
{
|
{
|
||||||
$url .= '?' . date('YmdHis', filemtime($file->fileFullPath));
|
$url .= '?' . date('YmdHis', filemtime($file->fileFullPath));
|
||||||
}
|
}
|
||||||
$result[] = array('file' => $url, 'media' => $file->media, 'targetie' => $file->targetIe);
|
$result[] = array('file' => $url, 'media' => $file->media);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -490,7 +488,7 @@ class FrontEndFileHandler extends Handler
|
||||||
Rhymix\Framework\Storage::write(\RX_BASEDIR . $concat_filename, $concat_content);
|
Rhymix\Framework\Storage::write(\RX_BASEDIR . $concat_filename, $concat_content);
|
||||||
}
|
}
|
||||||
$concat_filename .= '?' . date('YmdHis', filemtime(\RX_BASEDIR . $concat_filename));
|
$concat_filename .= '?' . date('YmdHis', filemtime(\RX_BASEDIR . $concat_filename));
|
||||||
$result[] = array('file' => \RX_BASEURL . $concat_filename, 'media' => 'all', 'targetie' => '');
|
$result[] = array('file' => \RX_BASEURL . $concat_filename, 'media' => 'all');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -505,7 +503,7 @@ class FrontEndFileHandler extends Handler
|
||||||
{
|
{
|
||||||
$url .= '?' . date('YmdHis', filemtime($file->fileFullPath));
|
$url .= '?' . date('YmdHis', filemtime($file->fileFullPath));
|
||||||
}
|
}
|
||||||
$result[] = array('file' => $url, 'media' => $file->media, 'targetie' => $file->targetIe);
|
$result[] = array('file' => $url, 'media' => $file->media);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -529,7 +527,7 @@ class FrontEndFileHandler extends Handler
|
||||||
*
|
*
|
||||||
* @param string $type Type of javascript. head, body
|
* @param string $type Type of javascript. head, body
|
||||||
* @param bool $finalize (optional)
|
* @param bool $finalize (optional)
|
||||||
* @return array Returns javascript file list. Array contains file, targetie.
|
* @return array Returns javascript file list.
|
||||||
*/
|
*/
|
||||||
public function getJsFileList($type = 'head', $finalize = false)
|
public function getJsFileList($type = 'head', $finalize = false)
|
||||||
{
|
{
|
||||||
|
|
@ -577,7 +575,7 @@ class FrontEndFileHandler extends Handler
|
||||||
{
|
{
|
||||||
$url .= '?' . date('YmdHis', filemtime($file->fileFullPath));
|
$url .= '?' . date('YmdHis', filemtime($file->fileFullPath));
|
||||||
}
|
}
|
||||||
$result[] = array('file' => $url, 'targetie' => $file->targetIe);
|
$result[] = array('file' => $url);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -585,7 +583,7 @@ class FrontEndFileHandler extends Handler
|
||||||
$concat_max_timestamp = 0;
|
$concat_max_timestamp = 0;
|
||||||
foreach ($concat_fileset as $file)
|
foreach ($concat_fileset as $file)
|
||||||
{
|
{
|
||||||
$concat_files[] = $file->targetIe ? array($file->fileFullPath, $file->targetIe) : $file->fileFullPath;
|
$concat_files[] = $file->fileFullPath;
|
||||||
$concat_max_timestamp = max($concat_max_timestamp, filemtime($file->fileFullPath));
|
$concat_max_timestamp = max($concat_max_timestamp, filemtime($file->fileFullPath));
|
||||||
}
|
}
|
||||||
$concat_filename = self::$assetdir . '/combined/' . sha1(serialize($concat_files)) . '.js';
|
$concat_filename = self::$assetdir . '/combined/' . sha1(serialize($concat_files)) . '.js';
|
||||||
|
|
@ -594,7 +592,7 @@ class FrontEndFileHandler extends Handler
|
||||||
Rhymix\Framework\Storage::write(\RX_BASEDIR . $concat_filename, Rhymix\Framework\Formatter::concatJS($concat_files, $concat_filename));
|
Rhymix\Framework\Storage::write(\RX_BASEDIR . $concat_filename, Rhymix\Framework\Formatter::concatJS($concat_files, $concat_filename));
|
||||||
}
|
}
|
||||||
$concat_filename .= '?' . date('YmdHis', filemtime(\RX_BASEDIR . $concat_filename));
|
$concat_filename .= '?' . date('YmdHis', filemtime(\RX_BASEDIR . $concat_filename));
|
||||||
$result[] = array('file' => \RX_BASEURL . $concat_filename, 'targetie' => '');
|
$result[] = array('file' => \RX_BASEURL . $concat_filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -609,7 +607,7 @@ class FrontEndFileHandler extends Handler
|
||||||
{
|
{
|
||||||
$url .= '?' . date('YmdHis', filemtime($file->fileFullPath));
|
$url .= '?' . date('YmdHis', filemtime($file->fileFullPath));
|
||||||
}
|
}
|
||||||
$result[] = array('file' => $url, 'targetie' => $file->targetIe);
|
$result[] = array('file' => $url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -642,7 +640,7 @@ class FrontEndFileHandler extends Handler
|
||||||
{
|
{
|
||||||
foreach ($indexedMap as $file)
|
foreach ($indexedMap as $file)
|
||||||
{
|
{
|
||||||
if ($file->isExternalURL || ($file->fileExtension === 'css' && $file->targetIe) || !is_readable($file->fileFullPath))
|
if ($file->isExternalURL || !is_readable($file->fileFullPath))
|
||||||
{
|
{
|
||||||
$concat_key++;
|
$concat_key++;
|
||||||
$concat_list[$concat_key][] = $file;
|
$concat_list[$concat_key][] = $file;
|
||||||
|
|
|
||||||
|
|
@ -913,13 +913,13 @@ class TemplateHandler
|
||||||
case 'js':
|
case 'js':
|
||||||
if($doUnload)
|
if($doUnload)
|
||||||
{
|
{
|
||||||
$result = vsprintf("Context::unloadFile('%s', '%s');", [$attr['target'] ?? '', $attr['targetie'] ?? '']);
|
$result = vsprintf("Context::unloadFile('%s', '');", [$attr['target'] ?? '']);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$metafile = isset($attr['target']) ? $attr['target'] : '';
|
$metafile = isset($attr['target']) ? $attr['target'] : '';
|
||||||
$result = vsprintf("Context::loadFile(['%s', '%s', '%s', '%s']);", [
|
$result = vsprintf("Context::loadFile(['%s', '%s', '%s', '%s']);", [
|
||||||
$attr['target'] ?? '', $attr['type'] ?? '', $attr['targetie'] ?? ($isRemote ? $this->source_type : ''), $attr['index'] ?? '',
|
$attr['target'] ?? '', $attr['type'] ?? '', $isRemote ? $this->source_type : '', $attr['index'] ?? '',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -928,8 +928,8 @@ class TemplateHandler
|
||||||
case 'scss':
|
case 'scss':
|
||||||
if($doUnload)
|
if($doUnload)
|
||||||
{
|
{
|
||||||
$result = vsprintf("Context::unloadFile('%s', '%s', '%s');", [
|
$result = vsprintf("Context::unloadFile('%s', '', '%s');", [
|
||||||
$attr['target'] ?? '', $attr['targetie'] ?? '', $attr['media'] ?? '',
|
$attr['target'] ?? '', $attr['media'] ?? '',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -937,7 +937,7 @@ class TemplateHandler
|
||||||
$metafile = isset($attr['target']) ? $attr['target'] : '';
|
$metafile = isset($attr['target']) ? $attr['target'] : '';
|
||||||
$metavars = isset($attr['vars']) ? ($attr['vars'] ? self::_replaceVar($attr['vars']) : '') : '';
|
$metavars = isset($attr['vars']) ? ($attr['vars'] ? self::_replaceVar($attr['vars']) : '') : '';
|
||||||
$result = vsprintf("Context::loadFile(['%s', '%s', '%s', '%s', %s]);", [
|
$result = vsprintf("Context::loadFile(['%s', '%s', '%s', '%s', %s]);", [
|
||||||
$attr['target'] ?? '', $attr['media'] ?? '', $attr['targetie'] ?? ($isRemote ? $this->source_type : ''), $attr['index'] ?? '',
|
$attr['target'] ?? '', $attr['media'] ?? '', $isRemote ? $this->source_type : '', $attr['index'] ?? '',
|
||||||
isset($attr['vars']) ? ($attr['vars'] ? self::_replaceVar($attr['vars']) : '[]') : '[]',
|
isset($attr['vars']) ? ($attr['vars'] ? self::_replaceVar($attr['vars']) : '[]') : '[]',
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -496,25 +496,15 @@ class Formatter
|
||||||
|
|
||||||
foreach ($source_filename as $filename)
|
foreach ($source_filename as $filename)
|
||||||
{
|
{
|
||||||
// Get the IE condition.
|
// Handle the array format, previously used for the targetIE attribute.
|
||||||
if (is_array($filename) && count($filename) >= 2)
|
if (is_array($filename) && count($filename) >= 1)
|
||||||
{
|
{
|
||||||
list($filename, $targetie) = $filename;
|
$filename = reset($filename);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$targetie = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clean the content.
|
// Clean the content.
|
||||||
$content = utf8_clean(file_get_contents($filename));
|
$content = utf8_clean(file_get_contents($filename));
|
||||||
|
|
||||||
// Wrap the content in an IE condition if there is one.
|
|
||||||
if ($targetie !== null)
|
|
||||||
{
|
|
||||||
$content = 'if (' . self::convertIECondition($targetie) . ') {' . "\n\n" . trim($content) . ";\n\n" . '}';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Append to the result string.
|
// Append to the result string.
|
||||||
$original_filename = starts_with(\RX_BASEDIR, $filename) ? substr($filename, strlen(\RX_BASEDIR)) : $filename;
|
$original_filename = starts_with(\RX_BASEDIR, $filename) ? substr($filename, strlen(\RX_BASEDIR)) : $filename;
|
||||||
$result .= '/* Original file: ' . $original_filename . ' */' . "\n\n" . trim($content) . ";\n\n";
|
$result .= '/* Original file: ' . $original_filename . ' */' . "\n\n" . trim($content) . ";\n\n";
|
||||||
|
|
@ -526,62 +516,12 @@ class Formatter
|
||||||
/**
|
/**
|
||||||
* Convert IE conditional comments to JS conditions.
|
* Convert IE conditional comments to JS conditions.
|
||||||
*
|
*
|
||||||
|
* @deprecated
|
||||||
* @param string $condition
|
* @param string $condition
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function convertIECondition($condition)
|
public static function convertIECondition($condition)
|
||||||
{
|
{
|
||||||
$conversions = array(
|
throw new Exceptions\FeatureDisabled;
|
||||||
'/^true$/i' => 'true',
|
|
||||||
'/^false$/i' => 'false',
|
|
||||||
'/^IE$/i' => 'window.navigator.userAgent.match(/MSIE\s/)',
|
|
||||||
'/^IE\s*(\d+)$/i' => '(/MSIE (\d+)/.exec(window.navigator.userAgent) && /MSIE (\d+)/.exec(window.navigator.userAgent)[1] == %d)',
|
|
||||||
'/^gt IE\s*(\d+)$/i' => '(/MSIE (\d+)/.exec(window.navigator.userAgent) && /MSIE (\d+)/.exec(window.navigator.userAgent)[1] > %d)',
|
|
||||||
'/^gte IE\s*(\d+)$/i' => '(/MSIE (\d+)/.exec(window.navigator.userAgent) && /MSIE (\d+)/.exec(window.navigator.userAgent)[1] >= %d)',
|
|
||||||
'/^lt IE\s*(\d+)$/i' => '(/MSIE (\d+)/.exec(window.navigator.userAgent) && /MSIE (\d+)/.exec(window.navigator.userAgent)[1] < %d)',
|
|
||||||
'/^lte IE\s*(\d+)$/i' => '(/MSIE (\d+)/.exec(window.navigator.userAgent) && /MSIE (\d+)/.exec(window.navigator.userAgent)[1] <= %d)',
|
|
||||||
);
|
|
||||||
|
|
||||||
$result = array();
|
|
||||||
$conditions = preg_split('/([\&\|])/', $condition, -1, \PREG_SPLIT_NO_EMPTY | \PREG_SPLIT_DELIM_CAPTURE);
|
|
||||||
foreach ($conditions as $condition)
|
|
||||||
{
|
|
||||||
$condition = trim(preg_replace('/[\(\)]/', '', $condition));
|
|
||||||
if ($condition === '')
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($condition === '&' || $condition === '|')
|
|
||||||
{
|
|
||||||
$result[] = $condition . $condition;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$negation = $condition[0] === '!';
|
|
||||||
if ($negation)
|
|
||||||
{
|
|
||||||
$condition = trim(substr($condition, 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($conversions as $regexp => $replacement)
|
|
||||||
{
|
|
||||||
if (preg_match($regexp, $condition, $matches))
|
|
||||||
{
|
|
||||||
if (count($matches) > 1)
|
|
||||||
{
|
|
||||||
array_shift($matches);
|
|
||||||
$result[] = ($negation ? '!' : '') . vsprintf($replacement, $matches);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$result[] = ($negation ? '!' : '') . $replacement;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return count($result) ? implode(' ', $result) : 'false';
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,16 +17,12 @@
|
||||||
|
|
||||||
<!-- CSS -->
|
<!-- CSS -->
|
||||||
<block loop="Context::getCssFile(true) => $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>
|
|
||||||
<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>
|
</block>
|
||||||
|
|
||||||
<!-- JS -->
|
<!-- JS -->
|
||||||
<block loop="Context::getJsFile('head', true) => $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>
|
|
||||||
<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>
|
</block>
|
||||||
|
|
||||||
<!-- RSS -->
|
<!-- RSS -->
|
||||||
|
|
|
||||||
|
|
@ -9,10 +9,6 @@
|
||||||
|
|
||||||
/* Original file: tests/_data/formatter/concat.source2.js */
|
/* Original file: tests/_data/formatter/concat.source2.js */
|
||||||
|
|
||||||
if ((/MSIE (\d+)/.exec(window.navigator.userAgent) && /MSIE (\d+)/.exec(window.navigator.userAgent)[1] >= 6) && (/MSIE (\d+)/.exec(window.navigator.userAgent) && /MSIE (\d+)/.exec(window.navigator.userAgent)[1] <= 8)) {
|
|
||||||
|
|
||||||
(function($) {
|
(function($) {
|
||||||
$(".xe").hide();
|
$(".xe").hide();
|
||||||
})(jQuery);;
|
})(jQuery);;
|
||||||
|
|
||||||
};
|
|
||||||
|
|
|
||||||
|
|
@ -40,8 +40,8 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
||||||
$handler->loadFile(array('./common/js/common.js', 'body'));
|
$handler->loadFile(array('./common/js/common.js', 'body'));
|
||||||
$handler->loadFile(array('./common/js/common.js', 'head'));
|
$handler->loadFile(array('./common/js/common.js', 'head'));
|
||||||
$handler->loadFile(array('./common/js/xml_js_filter.js', 'body'));
|
$handler->loadFile(array('./common/js/xml_js_filter.js', 'body'));
|
||||||
$expected[] = array('file' => $this->baseurl . 'common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => null);
|
$expected[] = array('file' => $this->baseurl . 'common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'));
|
||||||
$expected[] = array('file' => $this->baseurl . 'common/js/common.js' . $this->_filemtime('common/js/common.js'), 'targetie' => null);
|
$expected[] = array('file' => $this->baseurl . 'common/js/common.js' . $this->_filemtime('common/js/common.js'));
|
||||||
$this->assertEquals($expected, $handler->getJsFileList());
|
$this->assertEquals($expected, $handler->getJsFileList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -50,7 +50,7 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
||||||
$handler = new FrontEndFileHandler();
|
$handler = new FrontEndFileHandler();
|
||||||
$handler->loadFile(array('./common/js/xml_handler.js', 'body'));
|
$handler->loadFile(array('./common/js/xml_handler.js', 'body'));
|
||||||
$handler->loadFile(array('./common/js/xml_js_filter.js', 'head'));
|
$handler->loadFile(array('./common/js/xml_js_filter.js', 'head'));
|
||||||
$expected[] = array('file' => $this->baseurl . 'common/js/xml_handler.js' . $this->_filemtime('common/js/xml_handler.js'), 'targetie' => null);
|
$expected[] = array('file' => $this->baseurl . 'common/js/xml_handler.js' . $this->_filemtime('common/js/xml_handler.js'));
|
||||||
$this->assertEquals($expected, $handler->getJsFileList('body'));
|
$this->assertEquals($expected, $handler->getJsFileList('body'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,10 +75,10 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
||||||
$handler->loadFile(array('./common/js/common.js', 'head', '', -100000));
|
$handler->loadFile(array('./common/js/common.js', 'head', '', -100000));
|
||||||
$handler->loadFile(array('./common/js/xml_handler.js', 'head', '', -100000));
|
$handler->loadFile(array('./common/js/xml_handler.js', 'head', '', -100000));
|
||||||
$handler->loadFile(array('./common/js/xml_js_filter.js', 'head', '', -100000));
|
$handler->loadFile(array('./common/js/xml_js_filter.js', 'head', '', -100000));
|
||||||
$expected[] = array('file' => $this->baseurl . 'common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => null);
|
$expected[] = array('file' => $this->baseurl . 'common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'));
|
||||||
$expected[] = array('file' => $this->baseurl . 'common/js/common.js' . $this->_filemtime('common/js/common.js'), 'targetie' => null);
|
$expected[] = array('file' => $this->baseurl . 'common/js/common.js' . $this->_filemtime('common/js/common.js'));
|
||||||
$expected[] = array('file' => $this->baseurl . 'common/js/xml_handler.js' . $this->_filemtime('common/js/xml_handler.js'), 'targetie' => null);
|
$expected[] = array('file' => $this->baseurl . 'common/js/xml_handler.js' . $this->_filemtime('common/js/xml_handler.js'));
|
||||||
$expected[] = array('file' => $this->baseurl . 'common/js/xml_js_filter.js' . $this->_filemtime('common/js/xml_js_filter.js'), 'targetie' => null);
|
$expected[] = array('file' => $this->baseurl . 'common/js/xml_js_filter.js' . $this->_filemtime('common/js/xml_js_filter.js'));
|
||||||
$this->assertEquals($expected, $handler->getJsFileList());
|
$this->assertEquals($expected, $handler->getJsFileList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,10 +89,10 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
||||||
$handler->loadFile(array('./common/js/js_app.js', 'head', '', -100000));
|
$handler->loadFile(array('./common/js/js_app.js', 'head', '', -100000));
|
||||||
$handler->loadFile(array('./common/js/common.js', 'head', '', -100000));
|
$handler->loadFile(array('./common/js/common.js', 'head', '', -100000));
|
||||||
$handler->loadFile(array('./common/js/xml_js_filter.js', 'head', '', -100000));
|
$handler->loadFile(array('./common/js/xml_js_filter.js', 'head', '', -100000));
|
||||||
$expected[] = array('file' => $this->baseurl . 'common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => null);
|
$expected[] = array('file' => $this->baseurl . 'common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'));
|
||||||
$expected[] = array('file' => $this->baseurl . 'common/js/common.js' . $this->_filemtime('common/js/common.js'), 'targetie' => null);
|
$expected[] = array('file' => $this->baseurl . 'common/js/common.js' . $this->_filemtime('common/js/common.js'));
|
||||||
$expected[] = array('file' => $this->baseurl . 'common/js/xml_js_filter.js' . $this->_filemtime('common/js/xml_js_filter.js'), 'targetie' => null);
|
$expected[] = array('file' => $this->baseurl . 'common/js/xml_js_filter.js' . $this->_filemtime('common/js/xml_js_filter.js'));
|
||||||
$expected[] = array('file' => $this->baseurl . 'common/js/xml_handler.js' . $this->_filemtime('common/js/xml_handler.js'), 'targetie' => null);
|
$expected[] = array('file' => $this->baseurl . 'common/js/xml_handler.js' . $this->_filemtime('common/js/xml_handler.js'));
|
||||||
$this->assertEquals($expected, $handler->getJsFileList());
|
$this->assertEquals($expected, $handler->getJsFileList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -104,9 +104,9 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
||||||
$handler->loadFile(array('./common/js/xml_handler.js', 'head', '', -100000));
|
$handler->loadFile(array('./common/js/xml_handler.js', 'head', '', -100000));
|
||||||
$handler->loadFile(array('./common/js/xml_js_filter.js', 'head', '', -100000));
|
$handler->loadFile(array('./common/js/xml_js_filter.js', 'head', '', -100000));
|
||||||
$handler->unloadFile('./common/js/js_app.js', '', 'all');
|
$handler->unloadFile('./common/js/js_app.js', '', 'all');
|
||||||
$expected[] = array('file' => $this->baseurl . 'common/js/common.js' . $this->_filemtime('common/js/common.js'), 'targetie' => null);
|
$expected[] = array('file' => $this->baseurl . 'common/js/common.js' . $this->_filemtime('common/js/common.js'));
|
||||||
$expected[] = array('file' => $this->baseurl . 'common/js/xml_handler.js' . $this->_filemtime('common/js/xml_handler.js'), 'targetie' => null);
|
$expected[] = array('file' => $this->baseurl . 'common/js/xml_handler.js' . $this->_filemtime('common/js/xml_handler.js'));
|
||||||
$expected[] = array('file' => $this->baseurl . 'common/js/xml_js_filter.js' . $this->_filemtime('common/js/xml_js_filter.js'), 'targetie' => null);
|
$expected[] = array('file' => $this->baseurl . 'common/js/xml_js_filter.js' . $this->_filemtime('common/js/xml_js_filter.js'));
|
||||||
$this->assertEquals($expected, $handler->getJsFileList());
|
$this->assertEquals($expected, $handler->getJsFileList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -118,10 +118,10 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
||||||
$handler->loadFile(array('//external.host/js/script1.js'));
|
$handler->loadFile(array('//external.host/js/script1.js'));
|
||||||
$handler->loadFile(array('///external.host/js/script2.js'));
|
$handler->loadFile(array('///external.host/js/script2.js'));
|
||||||
|
|
||||||
$expected[] = array('file' => 'http://external.host/js/script.js', 'targetie' => null);
|
$expected[] = array('file' => 'http://external.host/js/script.js');
|
||||||
$expected[] = array('file' => 'https://external.host/js/script.js', 'targetie' => null);
|
$expected[] = array('file' => 'https://external.host/js/script.js');
|
||||||
$expected[] = array('file' => '//external.host/js/script1.js', 'targetie' => null);
|
$expected[] = array('file' => '//external.host/js/script1.js');
|
||||||
$expected[] = array('file' => '//external.host/js/script2.js', 'targetie' => null);
|
$expected[] = array('file' => '//external.host/js/script2.js');
|
||||||
$this->assertEquals($expected, $handler->getJsFileList());
|
$this->assertEquals($expected, $handler->getJsFileList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -131,7 +131,7 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
||||||
$handler->loadFile(array('//external.host/js/script.js'));
|
$handler->loadFile(array('//external.host/js/script.js'));
|
||||||
$handler->loadFile(array('///external.host/js/script.js'));
|
$handler->loadFile(array('///external.host/js/script.js'));
|
||||||
|
|
||||||
$expected[] = array('file' => '//external.host/js/script.js', 'targetie' => null);
|
$expected[] = array('file' => '//external.host/js/script.js');
|
||||||
$this->assertEquals($expected, $handler->getJsFileList());
|
$this->assertEquals($expected, $handler->getJsFileList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -142,9 +142,9 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
||||||
$handler->loadFile(array('https://external.host/css/style2.css'));
|
$handler->loadFile(array('https://external.host/css/style2.css'));
|
||||||
$handler->loadFile(array('https://external.host/css/style3.css?foo=bar&t=123'));
|
$handler->loadFile(array('https://external.host/css/style3.css?foo=bar&t=123'));
|
||||||
|
|
||||||
$expected[] = array('file' => 'http://external.host/css/style1.css', 'media'=>'all', 'targetie' => null);
|
$expected[] = array('file' => 'http://external.host/css/style1.css', 'media'=>'all');
|
||||||
$expected[] = array('file' => 'https://external.host/css/style2.css', 'media'=>'all', 'targetie' => null);
|
$expected[] = array('file' => 'https://external.host/css/style2.css', 'media'=>'all');
|
||||||
$expected[] = array('file' => 'https://external.host/css/style3.css?foo=bar&t=123', 'media'=>'all', 'targetie' => null);
|
$expected[] = array('file' => 'https://external.host/css/style3.css?foo=bar&t=123', 'media'=>'all');
|
||||||
$this->assertEquals($expected, $handler->getCssFileList());
|
$this->assertEquals($expected, $handler->getCssFileList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -155,9 +155,9 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
||||||
$handler->loadFile(array('///external.host/css2/style2.css'));
|
$handler->loadFile(array('///external.host/css2/style2.css'));
|
||||||
$handler->loadFile(array('//external.host/css/style3.css?foo=bar&t=123'));
|
$handler->loadFile(array('//external.host/css/style3.css?foo=bar&t=123'));
|
||||||
|
|
||||||
$expected[] = array('file' => '//external.host/css/style.css', 'media'=>'all', 'targetie' => null);
|
$expected[] = array('file' => '//external.host/css/style.css', 'media'=>'all');
|
||||||
$expected[] = array('file' => '//external.host/css2/style2.css', 'media'=>'all', 'targetie' => null);
|
$expected[] = array('file' => '//external.host/css2/style2.css', 'media'=>'all');
|
||||||
$expected[] = array('file' => '//external.host/css/style3.css?foo=bar&t=123', 'media'=>'all', 'targetie' => null);
|
$expected[] = array('file' => '//external.host/css/style3.css?foo=bar&t=123', 'media'=>'all');
|
||||||
$this->assertEquals($expected, $handler->getCssFileList());
|
$this->assertEquals($expected, $handler->getCssFileList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -177,9 +177,10 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
||||||
$handler->loadFile(array('./common/js/js_app.js', 'head', 'ie6'));
|
$handler->loadFile(array('./common/js/js_app.js', 'head', 'ie6'));
|
||||||
$handler->loadFile(array('./common/js/js_app.js', 'head', 'ie7'));
|
$handler->loadFile(array('./common/js/js_app.js', 'head', 'ie7'));
|
||||||
$handler->loadFile(array('./common/js/js_app.js', 'head', 'ie8'));
|
$handler->loadFile(array('./common/js/js_app.js', 'head', 'ie8'));
|
||||||
$expected[] = array('file' => $this->baseurl . 'common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => 'ie6');
|
|
||||||
$expected[] = array('file' => $this->baseurl . 'common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => 'ie7');
|
// All targetie attributes should be ignored since Rhymix 2.1
|
||||||
$expected[] = array('file' => $this->baseurl . 'common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'), 'targetie' => 'ie8');
|
// Since the 3 loadFile() are otherwise the same, only 1 will remain.
|
||||||
|
$expected[] = array('file' => $this->baseurl . 'common/js/js_app.js' . $this->_filemtime('common/js/js_app.js'));
|
||||||
$this->assertEquals($expected, $handler->getJsFileList());
|
$this->assertEquals($expected, $handler->getJsFileList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -190,9 +191,9 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
||||||
$handler->loadFile(array('./common/css/common.css', null, 'ie7'));
|
$handler->loadFile(array('./common/css/common.css', null, 'ie7'));
|
||||||
$handler->loadFile(array('./common/css/common.css', null, 'ie8'));
|
$handler->loadFile(array('./common/css/common.css', null, 'ie8'));
|
||||||
|
|
||||||
$expected[] = array('file' => $this->baseurl . 'common/css/common.css', 'media' => 'all', 'targetie' => 'ie6');
|
// All targetie attributes should be ignored since Rhymix 2.1
|
||||||
$expected[] = array('file' => $this->baseurl . 'common/css/common.css', 'media' => 'all', 'targetie' => 'ie7');
|
// Since the 3 loadFile() are otherwise the same, only 1 will remain.
|
||||||
$expected[] = array('file' => $this->baseurl . 'common/css/common.css', 'media' => 'all', 'targetie' => 'ie8');
|
$expected[] = array('file' => $this->baseurl . 'common/css/common.css', 'media' => 'all');
|
||||||
$this->assertEquals($expected, $handler->getCssFileList());
|
$this->assertEquals($expected, $handler->getCssFileList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -203,9 +204,9 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
||||||
$handler->loadFile(array('./common/css/common.css', 'screen'));
|
$handler->loadFile(array('./common/css/common.css', 'screen'));
|
||||||
$handler->loadFile(array('./common/css/common.css', 'handled'));
|
$handler->loadFile(array('./common/css/common.css', 'handled'));
|
||||||
|
|
||||||
$expected[] = array('file' => $this->baseurl . 'common/css/common.css', 'media'=>'all', 'targetie' => null);
|
$expected[] = array('file' => $this->baseurl . 'common/css/common.css', 'media'=>'all');
|
||||||
$expected[] = array('file' => $this->baseurl . 'common/css/common.css','media'=>'screen', 'targetie' => null);
|
$expected[] = array('file' => $this->baseurl . 'common/css/common.css', 'media'=>'screen');
|
||||||
$expected[] = array('file' => $this->baseurl . 'common/css/common.css', 'media'=>'handled', 'targetie' => null);
|
$expected[] = array('file' => $this->baseurl . 'common/css/common.css', 'media'=>'handled');
|
||||||
$this->assertEquals($expected, $handler->getCssFileList());
|
$this->assertEquals($expected, $handler->getCssFileList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -243,12 +244,12 @@ class FrontEndFileHandlerTest extends \Codeception\TestCase\Test
|
||||||
$handler->loadFile(array('./tests/_data/formatter/concat.target1.css'));
|
$handler->loadFile(array('./tests/_data/formatter/concat.target1.css'));
|
||||||
$handler->loadFile(array('./tests/_data/formatter/concat.target2.css'));
|
$handler->loadFile(array('./tests/_data/formatter/concat.target2.css'));
|
||||||
$result = $handler->getCssFileList(true);
|
$result = $handler->getCssFileList(true);
|
||||||
$this->assertEquals(4, count($result));
|
$this->assertEquals(3, count($result));
|
||||||
$this->assertRegexp('/combined\/[0-9a-f]+\.css\?\d+$/', $result[0]['file']);
|
$this->assertRegexp('/combined\/[0-9a-f]+\.css\?\d+$/', $result[0]['file']);
|
||||||
$this->assertEquals($this->baseurl . 'common/css/bootstrap.css' . $this->_filemtime('common/css/bootstrap.css'), $result[1]['file']);
|
//$this->assertEquals($this->baseurl . 'common/css/bootstrap.css' . $this->_filemtime('common/css/bootstrap.css'), $result[1]['file']);
|
||||||
$this->assertEquals('IE', $result[1]['targetie']);
|
//$this->assertEquals('IE', $result[1]['targetie']);
|
||||||
$this->assertEquals('http://external.host/style.css', $result[2]['file']);
|
$this->assertEquals('http://external.host/style.css', $result[1]['file']);
|
||||||
$this->assertRegexp('/combined\/[0-9a-f]+\.css\?\d+$/', $result[3]['file']);
|
$this->assertRegexp('/combined\/[0-9a-f]+\.css\?\d+$/', $result[2]['file']);
|
||||||
|
|
||||||
FrontEndFileHandler::$concat = 'js';
|
FrontEndFileHandler::$concat = 'js';
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -174,35 +174,6 @@ class FormatterTest extends \Codeception\TestCase\Test
|
||||||
$this->assertEquals(trim(file_get_contents($real_target2)), trim($test_with_targetie));
|
$this->assertEquals(trim(file_get_contents($real_target2)), trim($test_with_targetie));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConvertIECondition()
|
|
||||||
{
|
|
||||||
$this->assertEquals('window.navigator.userAgent.match(/MSIE\s/)', Rhymix\Framework\Formatter::convertIECondition('IE'));
|
|
||||||
$this->assertEquals('!window.navigator.userAgent.match(/MSIE\s/)', Rhymix\Framework\Formatter::convertIECondition('!IE'));
|
|
||||||
$this->assertEquals('!window.navigator.userAgent.match(/MSIE\s/)', Rhymix\Framework\Formatter::convertIECondition('!(IE)'));
|
|
||||||
$this->assertEquals('true && false', Rhymix\Framework\Formatter::convertIECondition('true&false'));
|
|
||||||
$this->assertEquals('false', Rhymix\Framework\Formatter::convertIECondition('gobbledygook'));
|
|
||||||
|
|
||||||
$source = 'gt IE 7';
|
|
||||||
$target = '(/MSIE (\d+)/.exec(window.navigator.userAgent) && /MSIE (\d+)/.exec(window.navigator.userAgent)[1] > 7)';
|
|
||||||
$this->assertEquals($target, Rhymix\Framework\Formatter::convertIECondition($source));
|
|
||||||
|
|
||||||
$source = 'lte IE 8';
|
|
||||||
$target = '(/MSIE (\d+)/.exec(window.navigator.userAgent) && /MSIE (\d+)/.exec(window.navigator.userAgent)[1] <= 8)';
|
|
||||||
$this->assertEquals($target, Rhymix\Framework\Formatter::convertIECondition($source));
|
|
||||||
|
|
||||||
$source = '(gte IE 6) & (lt IE 8)';
|
|
||||||
$target = '(/MSIE (\d+)/.exec(window.navigator.userAgent) && /MSIE (\d+)/.exec(window.navigator.userAgent)[1] >= 6) && (/MSIE (\d+)/.exec(window.navigator.userAgent) && /MSIE (\d+)/.exec(window.navigator.userAgent)[1] < 8)';
|
|
||||||
$this->assertEquals($target, Rhymix\Framework\Formatter::convertIECondition($source));
|
|
||||||
|
|
||||||
$source = '!(gt IE 9)';
|
|
||||||
$target = '!(/MSIE (\d+)/.exec(window.navigator.userAgent) && /MSIE (\d+)/.exec(window.navigator.userAgent)[1] > 9)';
|
|
||||||
$this->assertEquals($target, Rhymix\Framework\Formatter::convertIECondition($source));
|
|
||||||
|
|
||||||
$source = '!lt IE 8|lt IE 6';
|
|
||||||
$target = '!(/MSIE (\d+)/.exec(window.navigator.userAgent) && /MSIE (\d+)/.exec(window.navigator.userAgent)[1] < 8) || (/MSIE (\d+)/.exec(window.navigator.userAgent) && /MSIE (\d+)/.exec(window.navigator.userAgent)[1] < 6)';
|
|
||||||
$this->assertEquals($target, Rhymix\Framework\Formatter::convertIECondition($source));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function _removeSpace($str)
|
protected function _removeSpace($str)
|
||||||
{
|
{
|
||||||
return preg_replace('/\s+/', '', $str);
|
return preg_replace('/\s+/', '', $str);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue