From 029fa0ff62659f62a319d407bba45fb55a199f24 Mon Sep 17 00:00:00 2001 From: Ryuji AMANO Date: Tue, 10 Dec 2024 09:09:05 +0900 Subject: [PATCH] feat: Allow callable to clickable replacement --- .../modules/legacy/kernel/Legacy_TextFilter.class.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/html/modules/legacy/kernel/Legacy_TextFilter.class.php b/html/modules/legacy/kernel/Legacy_TextFilter.class.php index a4fb657f0..9a8c3981f 100644 --- a/html/modules/legacy/kernel/Legacy_TextFilter.class.php +++ b/html/modules/legacy/kernel/Legacy_TextFilter.class.php @@ -325,7 +325,16 @@ public function makeClickable($text) // $this->mMakeClickablePre->call(new XCube_Ref($this->mClickablePatterns), new XCube_Ref($this->mClickableReplacements)); } - $text = preg_replace($this->mClickablePatterns, $this->mClickableReplacements, $text); + foreach ($this->mClickablePatterns as $arrayIndex => $pattern) { + $replacement = $this->mClickableReplacements[$arrayIndex]; + + if (is_callable($replacement)) { + $text = preg_replace_callback($pattern, $replacement, $text); + }else { + $text = preg_replace($pattern, $replacement, $text); + } + } + return $text; }