From 4850ffe592888b1f5760e4666f263b2bd9338905 Mon Sep 17 00:00:00 2001 From: Cyssoo Date: Fri, 30 Jan 2026 18:13:13 +0100 Subject: [PATCH] Use Tools::str2url for rewrite slugs --- .../admin/AdminEverBlockPageController.php | 4 +++- controllers/front/slotmachine.php | 6 ++++- everblock.php | 24 ++++++++++++++----- models/EverblockPage.php | 4 +++- src/Service/EverblockTools.php | 9 +++++-- 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/controllers/admin/AdminEverBlockPageController.php b/controllers/admin/AdminEverBlockPageController.php index 4af6eeb4..764e6841 100644 --- a/controllers/admin/AdminEverBlockPageController.php +++ b/controllers/admin/AdminEverBlockPageController.php @@ -378,7 +378,9 @@ public function postProcess() if (!$rewrite) { $rewrite = Tools::getValue('name_' . $langId); } - $page->link_rewrite[$langId] = Tools::link_rewrite($rewrite); + $page->link_rewrite[$langId] = method_exists('Tools', 'str2url') + ? Tools::str2url($rewrite) + : Tools::link_rewrite($rewrite); $page->content[$langId] = Tools::getValue('content_' . $langId, false); } diff --git a/controllers/front/slotmachine.php b/controllers/front/slotmachine.php index d4c5f992..c6314de3 100644 --- a/controllers/front/slotmachine.php +++ b/controllers/front/slotmachine.php @@ -579,7 +579,11 @@ private function normalizeSymbols(array $symbols, $idLang) foreach ($symbols as $symbol) { $key = isset($symbol['symbol_key']) && $symbol['symbol_key'] !== '' ? (string) $symbol['symbol_key'] - : Tools::strtolower(Tools::link_rewrite((string) ($symbol['label'] ?? 'symbol'))); + : Tools::strtolower( + method_exists('Tools', 'str2url') + ? Tools::str2url((string) ($symbol['label'] ?? 'symbol')) + : Tools::link_rewrite((string) ($symbol['label'] ?? 'symbol')) + ); $label = ''; if (isset($symbol['label'])) { if (is_array($symbol['label'])) { diff --git a/everblock.php b/everblock.php index 68c44d57..d5099ecc 100644 --- a/everblock.php +++ b/everblock.php @@ -3197,7 +3197,9 @@ protected function postProcess() } Configuration::updateValue( 'EVERBLOCK_PAGES_BASE_URL', - Tools::link_rewrite($pagesBaseUrl) + method_exists('Tools', 'str2url') + ? Tools::str2url($pagesBaseUrl) + : Tools::link_rewrite($pagesBaseUrl) ); $pagesPerPage = (int) Tools::getValue('EVERBLOCK_PAGES_PER_PAGE'); if ($pagesPerPage <= 0) { @@ -3213,7 +3215,9 @@ protected function postProcess() } Configuration::updateValue( 'EVERBLOCK_FAQ_BASE_URL', - Tools::link_rewrite($faqBaseUrl) + method_exists('Tools', 'str2url') + ? Tools::str2url($faqBaseUrl) + : Tools::link_rewrite($faqBaseUrl) ); $faqPerPage = (int) Tools::getValue('EVERBLOCK_FAQ_PER_PAGE'); if ($faqPerPage <= 0) { @@ -6027,7 +6031,9 @@ public function hookBeforeRenderingEverblockGuidedSelector($params) foreach ($states as &$state) { $question = isset($state['question']) ? trim($state['question']) : ''; $state['question'] = $question; - $state['key'] = Tools::link_rewrite($question); + $state['key'] = method_exists('Tools', 'str2url') + ? Tools::str2url($question) + : Tools::link_rewrite($question); $answers = []; $lines = preg_split("/(\r\n|\r|\n)/", $state['answers'] ?? ''); @@ -6041,7 +6047,9 @@ public function hookBeforeRenderingEverblockGuidedSelector($params) $answers[] = [ 'text' => $text, 'link' => $link, - 'value' => Tools::link_rewrite($text), + 'value' => method_exists('Tools', 'str2url') + ? Tools::str2url($text) + : Tools::link_rewrite($text), ]; } $state['answers'] = $answers; @@ -6222,10 +6230,14 @@ public function encrypt($data) public function hookModuleRoutes($params) { $base = Configuration::get('EVERBLOCK_PAGES_BASE_URL') ?: 'guide'; - $base = Tools::link_rewrite($base ? (string) $base : 'guide'); + $base = method_exists('Tools', 'str2url') + ? Tools::str2url($base ? (string) $base : 'guide') + : Tools::link_rewrite($base ? (string) $base : 'guide'); $faqBase = Configuration::get('EVERBLOCK_FAQ_BASE_URL') ?: 'faq'; - $faqBase = Tools::link_rewrite($faqBase ? (string) $faqBase : 'faq'); + $faqBase = method_exists('Tools', 'str2url') + ? Tools::str2url($faqBase ? (string) $faqBase : 'faq') + : Tools::link_rewrite($faqBase ? (string) $faqBase : 'faq'); return [ 'module-everblock-pages' => [ diff --git a/models/EverblockPage.php b/models/EverblockPage.php index fe6129f2..a290e72a 100644 --- a/models/EverblockPage.php +++ b/models/EverblockPage.php @@ -353,7 +353,9 @@ protected function sanitizeLinkRewrite(): void if (!$rewrite) { $rewrite = $name; } - $this->link_rewrite[$langId] = Tools::link_rewrite((string) $rewrite); + $this->link_rewrite[$langId] = method_exists('Tools', 'str2url') + ? Tools::str2url((string) $rewrite) + : Tools::link_rewrite((string) $rewrite); } } diff --git a/src/Service/EverblockTools.php b/src/Service/EverblockTools.php index a26a8c2d..eff42c97 100644 --- a/src/Service/EverblockTools.php +++ b/src/Service/EverblockTools.php @@ -6029,7 +6029,10 @@ private static function importWordpressFeaturedImage(string $imageUrl, int $post $filenameBase = pathinfo($path, PATHINFO_FILENAME); if (!$filenameBase) { - $filenameBase = Tools::link_rewrite($title) ?: 'image'; + $filenameBase = method_exists('Tools', 'str2url') + ? Tools::str2url($title) + : Tools::link_rewrite($title); + $filenameBase = $filenameBase ?: 'image'; } $filenameBase = self::sanitizeFileName($filenameBase); if ($filenameBase === '') { @@ -6080,7 +6083,9 @@ private static function ensureCmsDirectoryExists(): bool private static function sanitizeFileName(string $fileName): string { - $normalized = Tools::link_rewrite($fileName); + $normalized = method_exists('Tools', 'str2url') + ? Tools::str2url($fileName) + : Tools::link_rewrite($fileName); $normalized = preg_replace('/[^a-z0-9\-]+/i', '-', (string) $normalized); $normalized = preg_replace('/-+/', '-', (string) $normalized);