From 8399b9fcda8149558dea980c911a01a16d6e55f7 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Tue, 18 Jun 2024 17:41:49 +0900 Subject: [PATCH 1/7] =?UTF-8?q?Smarty::addPluginsDir=20=E3=81=AF=E9=9D=9E?= =?UTF-8?q?=E6=8E=A8=E5=A5=A8=E3=81=AA=E3=81=AE=E3=81=A7=20registerPlugin?= =?UTF-8?q?=20=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- composer.json | 9 +++++++++ data/class/SC_View.php | 8 +++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 20aa30ebc6..5ff65f5019 100644 --- a/composer.json +++ b/composer.json @@ -52,6 +52,15 @@ "classmap": [ "data/class", "data/class_extends" + ], + "files": [ + "data/smarty_extends/function.from_to.php", + "data/smarty_extends/function.include_php_ex.php", + "data/smarty_extends/modifier.h.php", + "data/smarty_extends/modifier.n2s.php", + "data/smarty_extends/modifier.nl2br_html.php", + "data/smarty_extends/modifier.script_escape.php", + "data/smarty_extends/modifier.u.php" ] } } diff --git a/data/class/SC_View.php b/data/class/SC_View.php index 143fc42ca4..976d780206 100644 --- a/data/class/SC_View.php +++ b/data/class/SC_View.php @@ -54,7 +54,13 @@ public function init() $this->_smarty->registerPlugin('modifier', 'sfMultiply', array('SC_Utils_Ex', 'sfMultiply')); $this->_smarty->registerPlugin('modifier', 'sfRmDupSlash', array('SC_Utils_Ex', 'sfRmDupSlash')); $this->_smarty->registerPlugin('modifier', 'sfCutString', array('SC_Utils_Ex', 'sfCutString')); - $this->_smarty->addPluginsDir(array('plugins', realpath(dirname(__FILE__)) . '/../smarty_extends')); + $this->_smarty->registerPlugin('function', 'from_to', 'smarty_function_from_to'); + $this->_smarty->registerPlugin('function', 'include_php_ex', 'smarty_function_include_php_ex'); + $this->_smarty->registerPlugin('modifier', 'h', 'smarty_modifier_h'); + $this->_smarty->registerPlugin('modifier', 'n2s', 'smarty_modifier_n2s'); + $this->_smarty->registerPlugin('modifier', 'nl2br_html', 'smarty_modifier_nl2br_html'); + $this->_smarty->registerPlugin('modifier', 'script_escape', 'smarty_modifier_script_escape'); + $this->_smarty->registerPlugin('modifier', 'u', 'smarty_modifier_u'); $this->_smarty->registerPlugin('modifier', 'sfMbConvertEncoding', array('SC_Utils_Ex', 'sfMbConvertEncoding')); $this->_smarty->registerPlugin('modifier', 'sfGetEnabled', array('SC_Utils_Ex', 'sfGetEnabled')); $this->_smarty->registerPlugin('modifier', 'sfNoImageMainList', array('SC_Utils_Ex', 'sfNoImageMainList')); From c5cc4d748d2e3018bef0709c6c59c2eeecbea5dd Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Tue, 18 Jun 2024 17:51:33 +0900 Subject: [PATCH 2/7] =?UTF-8?q?mobile=20=E3=83=86=E3=83=B3=E3=83=97?= =?UTF-8?q?=E3=83=AC=E3=83=BC=E3=83=88=E3=81=AF=E5=BB=83=E6=AD=A2=E3=81=95?= =?UTF-8?q?=E3=82=8C=E3=81=9F=E3=81=9F=E3=82=81=E9=9D=9E=E6=8E=A8=E5=A5=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/smarty_extends/block.marquee.php | 1 + data/smarty_extends/modifier.numeric_emoji.php | 1 + 2 files changed, 2 insertions(+) diff --git a/data/smarty_extends/block.marquee.php b/data/smarty_extends/block.marquee.php index 1026b2e0ee..8d8e01259c 100644 --- a/data/smarty_extends/block.marquee.php +++ b/data/smarty_extends/block.marquee.php @@ -2,6 +2,7 @@ /** * marqueeタグで囲む。 * + * @deprecated mobile テンプレートは廃止されたため非推奨 * DoCoMoの携帯端末の場合はmarqueeを使用しない。 * * @return string 出力 diff --git a/data/smarty_extends/modifier.numeric_emoji.php b/data/smarty_extends/modifier.numeric_emoji.php index 2b9e18d911..cea4aec00c 100644 --- a/data/smarty_extends/modifier.numeric_emoji.php +++ b/data/smarty_extends/modifier.numeric_emoji.php @@ -2,6 +2,7 @@ /** * 数値を数字絵文字に変換する。 * + * @deprecated mobile テンプレートは廃止されたため非推奨 * 入力が0~9ではない場合、または、携帯端末からのアクセスではない場合は、 * 入力を [ と ] で囲んだ文字列を返す。 * From 1445b48feafab5c6077d36c7c140473934efcb3c Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Tue, 18 Jun 2024 17:42:13 +0900 Subject: [PATCH 3/7] Add array_key_exists to Smarty modifier --- data/class/SC_View.php | 1 + 1 file changed, 1 insertion(+) diff --git a/data/class/SC_View.php b/data/class/SC_View.php index 976d780206..01f94f7a47 100644 --- a/data/class/SC_View.php +++ b/data/class/SC_View.php @@ -69,6 +69,7 @@ public function init() $this->_smarty->registerPlugin('modifier', 'preg_quote', 'preg_quote'); $this->_smarty->registerPlugin('modifier', 'is_numeric', 'is_numeric'); $this->_smarty->registerPlugin('modifier', 'php_uname', 'php_uname'); + $this->_smarty->registerPlugin('modifier', 'array_key_exists', 'array_key_exists'); // XXX register_function で登録すると if で使用できないのではないか? $this->_smarty->registerPlugin('function','sfIsHTTPS', array('SC_Utils_Ex', 'sfIsHTTPS')); $this->_smarty->registerPlugin('function','sfSetErrorStyle', array('SC_Utils_Ex', 'sfSetErrorStyle')); From 443dd2d701b157cfd3c2669142083d35428a9ec6 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Wed, 19 Jun 2024 16:36:28 +0900 Subject: [PATCH 4/7] Fix deprecated: Using ${var} in strings is deprecated, use {$var} instead --- data/smarty_extends/modifier.script_escape.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/smarty_extends/modifier.script_escape.php b/data/smarty_extends/modifier.script_escape.php index 0e04180830..5ebedb9f48 100644 --- a/data/smarty_extends/modifier.script_escape.php +++ b/data/smarty_extends/modifier.script_escape.php @@ -34,7 +34,7 @@ function smarty_modifier_script_escape($value) $pattern .= "(\"|').*(onerror|onload|".implode("|", $escapeEvents).").*=.*(\"|').*"; // 正規表現をまとめる - $attributesPattern = "/${pattern}/i"; + $attributesPattern = "/{$pattern}/i"; // 置き換える文字列 $convert = '#script tag escaped#'; From f998023f231cdfd2baa9aec12686a16a1d46871c Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Wed, 19 Jun 2024 17:05:54 +0900 Subject: [PATCH 5/7] remove require --- tests/class/modifier/Modifier_ScriptEscapeTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/class/modifier/Modifier_ScriptEscapeTest.php b/tests/class/modifier/Modifier_ScriptEscapeTest.php index 8c92118781..232e5368ae 100644 --- a/tests/class/modifier/Modifier_ScriptEscapeTest.php +++ b/tests/class/modifier/Modifier_ScriptEscapeTest.php @@ -1,5 +1,4 @@ Date: Thu, 20 Jun 2024 13:02:23 +0900 Subject: [PATCH 6/7] Add README.md --- data/smarty_extends/README.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 data/smarty_extends/README.md diff --git a/data/smarty_extends/README.md b/data/smarty_extends/README.md new file mode 100644 index 0000000000..7d2a6dcaf6 --- /dev/null +++ b/data/smarty_extends/README.md @@ -0,0 +1,27 @@ +## このディレクトリのファイルは composer.json の autoload.classmap.files に登録することで利用可能です + +1. autoload.classmap.files に登録します。 + +``` json + "autoload": { + "classmap": [ + "data/class", + "data/class_extends" + ], + "files": [ + "data/smarty_extends/function.from_to.php", + "data/smarty_extends/function.include_php_ex.php", + "data/smarty_extends/modifier.h.php", + "data/smarty_extends/modifier.n2s.php", + "data/smarty_extends/modifier.nl2br_html.php", + "data/smarty_extends/modifier.script_escape.php", + "data/smarty_extends/modifier.u.php" + ] + } +``` + +2. composer dump-autoload コマンドを実行することで autoload の対象となります。 + +``` shell +composer dump-autoload +``` From d1202bd24983ee0e33436abdd8c68a59c64e5995 Mon Sep 17 00:00:00 2001 From: Kentaro Ohkouchi Date: Mon, 29 Jul 2024 17:43:05 +0900 Subject: [PATCH 7/7] =?UTF-8?q?SC=5FView.php=20=E3=81=AB=E8=A8=AD=E5=AE=9A?= =?UTF-8?q?=E3=82=92=E8=BF=BD=E5=8A=A0=E3=81=99=E3=82=8B=E6=97=A8=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E8=A8=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/smarty_extends/README.md | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/data/smarty_extends/README.md b/data/smarty_extends/README.md index 7d2a6dcaf6..0158e57bc7 100644 --- a/data/smarty_extends/README.md +++ b/data/smarty_extends/README.md @@ -1,6 +1,6 @@ ## このディレクトリのファイルは composer.json の autoload.classmap.files に登録することで利用可能です -1. autoload.classmap.files に登録します。 +1. [composer.json](../../composer.json) の autoload.classmap.files に登録します。 ``` json "autoload": { @@ -19,9 +19,27 @@ ] } ``` - -2. composer dump-autoload コマンドを実行することで autoload の対象となります。 - +2. [SC_View.php](../class/SC_View.php) のコンストラクタに modifier を設定します。 +```diff +--- a/data/class/SC_View.php ++++ b/data/class/SC_View.php +@@ -54,7 +54,13 @@ public function init() + $this->_smarty->registerPlugin('modifier', 'sfMultiply', array('SC_Utils_Ex', 'sfMultiply')); + $this->_smarty->registerPlugin('modifier', 'sfRmDupSlash', array('SC_Utils_Ex', 'sfRmDupSlash')); + $this->_smarty->registerPlugin('modifier', 'sfCutString', array('SC_Utils_Ex', 'sfCutString')); +- $this->_smarty->addPluginsDir(array('plugins', realpath(dirname(__FILE__)) . '/../smarty_extends')); ++ $this->_smarty->registerPlugin('function', 'from_to', 'smarty_function_from_to'); ++ $this->_smarty->registerPlugin('function', 'include_php_ex', 'smarty_function_include_php_ex'); ++ $this->_smarty->registerPlugin('modifier', 'h', 'smarty_modifier_h'); ++ $this->_smarty->registerPlugin('modifier', 'n2s', 'smarty_modifier_n2s'); ++ $this->_smarty->registerPlugin('modifier', 'nl2br_html', 'smarty_modifier_nl2br_html'); ++ $this->_smarty->registerPlugin('modifier', 'script_escape', 'smarty_modifier_script_escape'); ++ $this->_smarty->registerPlugin('modifier', 'u', 'smarty_modifier_u'); + $this->_smarty->registerPlugin('modifier', 'sfMbConvertEncoding', array('SC_Utils_Ex', 'sfMbConvertEncoding')); + $this->_smarty->registerPlugin('modifier', 'sfGetEnabled', array('SC_Utils_Ex', 'sfGetEnabled')); + $this->_smarty->registerPlugin('modifier', 'sfNoImageMainList', array('SC_Utils_Ex', 'sfNoImageMainList')); +``` +3. composer dump-autoload コマンドを実行することで autoload の対象となります。 ``` shell composer dump-autoload ```