Fix incorrect use of curly braces in legacy classes

This commit is contained in:
Kijin Sung 2020-05-19 20:52:44 +09:00
parent 2cbfd4500c
commit 14ad62e869
4 changed files with 39 additions and 39 deletions

View file

@ -2100,7 +2100,7 @@ class Context
*/ */
public static function normalizeFilePath($file) public static function normalizeFilePath($file)
{ {
if($file{0} != '/' && $file{0} != '.' && strpos($file, '://') === FALSE) if($file[0] != '/' && $file[0] != '.' && strpos($file, '://') === FALSE)
{ {
$file = './' . $file; $file = './' . $file;
} }

View file

@ -92,27 +92,27 @@ class FrontEndFileHandler extends Handler
if(!is_array($args)) if(!is_array($args))
{ {
$args = array($args); $args = array($args);
} }
// Replace obsolete paths with current paths. // Replace obsolete paths with current paths.
$args[0] = preg_replace(array_keys(HTMLDisplayHandler::$replacements), array_values(HTMLDisplayHandler::$replacements), $args[0]); $args[0] = preg_replace(array_keys(HTMLDisplayHandler::$replacements), array_values(HTMLDisplayHandler::$replacements), $args[0]);
$isCommon = preg_match(HTMLDisplayHandler::$reservedCSS, $args[0]) || preg_match(HTMLDisplayHandler::$reservedJS, $args[0]); $isCommon = preg_match(HTMLDisplayHandler::$reservedCSS, $args[0]) || preg_match(HTMLDisplayHandler::$reservedJS, $args[0]);
// Prevent overwriting common scripts. // Prevent overwriting common scripts.
if(intval($args[3]) > -1500000000) if(intval($args[3]) > -1500000000)
{ {
if($isCommon) if($isCommon)
{ {
return; return;
} }
foreach(HTMLDisplayHandler::$blockedScripts as $regexp) foreach(HTMLDisplayHandler::$blockedScripts as $regexp)
{ {
if(preg_match($regexp, $args[0])) if(preg_match($regexp, $args[0]))
{ {
return; return;
} }
} }
} }
$file = $this->getFileInfo($args[0], $args[2], $args[1], $args[4], $isCommon); $file = $this->getFileInfo($args[0], $args[2], $args[1], $args[4], $isCommon);
$file->index = (int)$args[3]; $file->index = (int)$args[3];
@ -170,17 +170,17 @@ class FrontEndFileHandler extends Handler
return $existsInfo[$existsKey]; return $existsInfo[$existsKey];
} }
$pathInfo = pathinfo($fileName); $pathInfo = pathinfo($fileName);
$file = new stdClass(); $file = new stdClass();
$file->fileName = $pathInfo['basename']; $file->fileName = $pathInfo['basename'];
$file->filePath = $this->_getAbsFileUrl($pathInfo['dirname']); $file->filePath = $this->_getAbsFileUrl($pathInfo['dirname']);
$file->fileRealPath = FileHandler::getRealPath($pathInfo['dirname']); $file->fileRealPath = FileHandler::getRealPath($pathInfo['dirname']);
$file->fileFullPath = $file->fileRealPath . '/' . $pathInfo['basename']; $file->fileFullPath = $file->fileRealPath . '/' . $pathInfo['basename'];
$file->fileExtension = strtolower($pathInfo['extension']); $file->fileExtension = strtolower($pathInfo['extension']);
if (($pos = strpos($file->fileExtension, '?')) !== false) if (($pos = strpos($file->fileExtension, '?')) !== false)
{ {
$file->fileExtension = substr($file->fileExtension, 0, $pos); $file->fileExtension = substr($file->fileExtension, 0, $pos);
} }
if (preg_match('/^(.+)\.min$/', $pathInfo['filename'], $matches)) if (preg_match('/^(.+)\.min$/', $pathInfo['filename'], $matches))
{ {
@ -192,10 +192,10 @@ class FrontEndFileHandler extends Handler
$file->fileNameNoExt = $pathInfo['filename']; $file->fileNameNoExt = $pathInfo['filename'];
$file->isMinified = false; $file->isMinified = false;
} }
$file->isExternalURL = preg_match('@^(https?:)?//@i', $file->filePath) ? true : false; $file->isExternalURL = preg_match('@^(https?:)?//@i', $file->filePath) ? true : false;
if ($file->isExternalURL && !$file->fileExtension) if ($file->isExternalURL && !$file->fileExtension)
{ {
$file->fileExtension = preg_match('/[\.\/](css|js)\b/', $fileName, $matches) ? $matches[1] : null; $file->fileExtension = preg_match('/[\.\/](css|js)\b/', $fileName, $matches) ? $matches[1] : null;
} }
$file->isCachedScript = !$file->isExternalURL && strpos($file->filePath, 'files/cache/') !== false; $file->isCachedScript = !$file->isExternalURL && strpos($file->filePath, 'files/cache/') !== false;
$file->isCommon = $isCommon; $file->isCommon = $isCommon;
@ -213,7 +213,7 @@ class FrontEndFileHandler extends Handler
$file->fileFullPath = $file->fileRealPath . '/' . $file->fileNameNoExt . '.' . $file->fileExtension; $file->fileFullPath = $file->fileRealPath . '/' . $file->fileNameNoExt . '.' . $file->fileExtension;
} }
} }
// Do not minify common JS plugins // Do not minify common JS plugins
if (strpos($file->filePath, 'common/js/plugins') !== false) if (strpos($file->filePath, 'common/js/plugins') !== false)
{ {
@ -288,12 +288,12 @@ class FrontEndFileHandler extends Handler
if (!file_exists($file->fileFullPath)) if (!file_exists($file->fileFullPath))
{ {
return; return;
} }
$default_font_config = Context::get('default_font_config') ?: getController('editor')->default_font_config; $default_font_config = Context::get('default_font_config') ?: getController('editor')->default_font_config;
$file->vars['enable_xe_btn_styles'] = (defined('DISABLE_XE_BTN_STYLES') && DISABLE_XE_BTN_STYLES) ? 'false' : 'true'; $file->vars['enable_xe_btn_styles'] = (defined('DISABLE_XE_BTN_STYLES') && DISABLE_XE_BTN_STYLES) ? 'false' : 'true';
$file->vars['enable_xe_msg_styles'] = (defined('DISABLE_XE_MSG_STYLES') && DISABLE_XE_MSG_STYLES) ? 'false' : 'true'; $file->vars['enable_xe_msg_styles'] = (defined('DISABLE_XE_MSG_STYLES') && DISABLE_XE_MSG_STYLES) ? 'false' : 'true';
$file->vars = array_merge($file->vars, $default_font_config); $file->vars = array_merge($file->vars, $default_font_config);
if ($file->fileExtension === 'less') if ($file->fileExtension === 'less')
{ {
$file->vars = array_map(function($str) { $file->vars = array_map(function($str) {
@ -631,7 +631,7 @@ class FrontEndFileHandler extends Handler
*/ */
protected function _normalizeFilePath($path) protected function _normalizeFilePath($path)
{ {
if(strpos($path, '://') === FALSE && $path{0} != '/' && $path{0} != '.') if(strpos($path, '://') === FALSE && $path[0] != '/' && $path[0] != '.')
{ {
$path = './' . $path; $path = './' . $path;
} }

View file

@ -484,7 +484,7 @@ class TemplateHandler
// find closing tag // find closing tag
$close_php = '<?php ' . str_repeat('}', $closing) . ' ?>'; $close_php = '<?php ' . str_repeat('}', $closing) . ' ?>';
// self closing tag // self closing tag
if($node{1} == '!' || substr($node, -2, 1) == '/' || isset($self_closing[$tag])) if($node[1] == '!' || substr($node, -2, 1) == '/' || isset($self_closing[$tag]))
{ {
$nodes[$idx + 1] = $close_php . $nodes[$idx + 1]; $nodes[$idx + 1] = $close_php . $nodes[$idx + 1];
} }
@ -545,7 +545,7 @@ class TemplateHandler
return $m[0]; return $m[0];
} }
if($m[1]{0} == '@') if($m[1][0] == '@')
{ {
$m[1] = self::_replaceVar(substr($m[1], 1)); $m[1] = self::_replaceVar(substr($m[1], 1));
return "<?php {$m[1]} ?>"; return "<?php {$m[1]} ?>";
@ -866,7 +866,7 @@ class TemplateHandler
} }
if($mm[1]) if($mm[1])
{ {
if($mm[1]{0} == 'e') if($mm[1][0] == 'e')
{ {
return '<?php } ?>' . $m[9]; return '<?php } ?>' . $m[9];
} }
@ -931,7 +931,7 @@ class TemplateHandler
$_path = $path; $_path = $path;
$fileDir = strtr(realpath($this->path), '\\', '/'); $fileDir = strtr(realpath($this->path), '\\', '/');
if($path{0} != '/') if($path[0] != '/')
{ {
$path = strtr(realpath($fileDir . '/' . $path), '\\', '/'); $path = strtr(realpath($fileDir . '/' . $path), '\\', '/');
} }

View file

@ -279,7 +279,7 @@ class Validator
foreach($this->_filters as $key => $filter) foreach($this->_filters as $key => $filter)
{ {
$names = array(); $names = array();
if($key{0} == '^') if($key[0] == '^')
{ {
$names = preg_grep('/^' . preg_quote(substr($key, 1)) . '/', $field_names); $names = preg_grep('/^' . preg_quote(substr($key, 1)) . '/', $field_names);
} }