Remove support for targetie attribute on assets

This commit is contained in:
Kijin Sung 2022-12-28 00:35:57 +09:00
parent d34d08438f
commit 9e9adcdb43
8 changed files with 95 additions and 193 deletions

View file

@ -984,13 +984,16 @@ class Context
* @see arrayConvWalkCallback will replaced array_walk_recursive in >=PHP5
* @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))
{
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 :
* $args[0]: file name,
* $args[1]: type (head | body),
* $args[2]: target IE,
* $args[2]: unused,
* $args[3]: index
* case css :
* $args[0]: file name,
* $args[1]: media,
* $args[2]: target IE,
* $args[2]: source type hint,
* $args[3]: index
*
*/
@ -2097,13 +2100,13 @@ class Context
* Unload front end file
*
* @param string $file File name with path
* @param string $targetIe Target IE
* @param string $unused
* @param string $media Media query
* @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
* @param string $file File name with path
* @param string $optimized optimized (That seems to not use)
* @param string $targetie target IE
* @param string $unused1
* @param string $unused2
* @param string $index index
* @param string $type Added position. (head:<head>..</head>, body:<body>..</body>)
* @param bool $isRuleset Use ruleset
* @param string $autoPath If path not readed, set the path automatically.
* @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)
{
@ -2147,7 +2150,7 @@ class Context
$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
* @param string $file File name with path
* @param string $optimized optimized (That seems to not use)
* @param string $targetie target IE
* @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 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)
{
@ -2228,16 +2229,16 @@ class Context
*
* @deprecated
* @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 $targetie target IE
* @param string $unused2
* @param string $index index
* @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
* @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 $targetie target IE
* @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
*
* @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)
{

View file

@ -74,12 +74,12 @@ class FrontEndFileHandler extends Handler
* case js
* $args[0]: file name
* $args[1]: type (head | body)
* $args[2]: target IE
* $args[2]: unused (previously targetIe)
* $args[3]: index
* case css
* $args[0]: file name
* $args[1]: media
* $args[2]: target IE / source type hint
* $args[2]: source type hint
* $args[3]: index
* $args[4]: vars for LESS and SCSS
* </pre>
@ -228,20 +228,18 @@ class FrontEndFileHandler extends Handler
$file->isMinified = true;
}
// Process targetIe and media attributes
$file->targetIe = $targetIe;
// Since Rhymix 2.1, targetIe is always empty
$file->targetIe = '';
// Process media attributes and generate the key
if($file->fileExtension == 'css' || $file->fileExtension == 'less' || $file->fileExtension == 'scss')
{
$file->media = $media;
if(!$file->media)
{
$file->media = 'all';
}
$file->key = sprintf('%s/%s:%s:%s', $file->filePath, $file->keyName, $file->targetIe, $file->media);
$file->media = $media ?: 'all';
$file->key = sprintf('%s/%s:%s', $file->filePath, $file->keyName, $file->media);
}
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;
@ -427,7 +425,7 @@ class FrontEndFileHandler extends Handler
* 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.
*/
public function getCssFileList($finalize = false)
{
@ -471,7 +469,7 @@ class FrontEndFileHandler extends Handler
{
$url .= '?' . date('YmdHis', filemtime($file->fileFullPath));
}
$result[] = array('file' => $url, 'media' => $file->media, 'targetie' => $file->targetIe);
$result[] = array('file' => $url, 'media' => $file->media);
}
else
{
@ -490,7 +488,7 @@ class FrontEndFileHandler extends Handler
Rhymix\Framework\Storage::write(\RX_BASEDIR . $concat_filename, $concat_content);
}
$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));
}
$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 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)
{
@ -577,7 +575,7 @@ class FrontEndFileHandler extends Handler
{
$url .= '?' . date('YmdHis', filemtime($file->fileFullPath));
}
$result[] = array('file' => $url, 'targetie' => $file->targetIe);
$result[] = array('file' => $url);
}
else
{
@ -585,7 +583,7 @@ class FrontEndFileHandler extends Handler
$concat_max_timestamp = 0;
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_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));
}
$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));
}
$result[] = array('file' => $url, 'targetie' => $file->targetIe);
$result[] = array('file' => $url);
}
}
}
@ -642,7 +640,7 @@ class FrontEndFileHandler extends Handler
{
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_list[$concat_key][] = $file;

View file

@ -913,13 +913,13 @@ class TemplateHandler
case 'js':
if($doUnload)
{
$result = vsprintf("Context::unloadFile('%s', '%s');", [$attr['target'] ?? '', $attr['targetie'] ?? '']);
$result = vsprintf("Context::unloadFile('%s', '');", [$attr['target'] ?? '']);
}
else
{
$metafile = isset($attr['target']) ? $attr['target'] : '';
$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;
@ -928,8 +928,8 @@ class TemplateHandler
case 'scss':
if($doUnload)
{
$result = vsprintf("Context::unloadFile('%s', '%s', '%s');", [
$attr['target'] ?? '', $attr['targetie'] ?? '', $attr['media'] ?? '',
$result = vsprintf("Context::unloadFile('%s', '', '%s');", [
$attr['target'] ?? '', $attr['media'] ?? '',
]);
}
else
@ -937,7 +937,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'] ?? ($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']) : '[]') : '[]',
]);
}