Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion controllers/admin/AdminEverBlockPageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
6 changes: 5 additions & 1 deletion controllers/front/slotmachine.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand Down
24 changes: 18 additions & 6 deletions everblock.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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'] ?? '');
Expand All @@ -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;
Expand Down Expand Up @@ -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' => [
Expand Down
4 changes: 3 additions & 1 deletion models/EverblockPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
9 changes: 7 additions & 2 deletions src/Service/EverblockTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 === '') {
Expand Down Expand Up @@ -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);

Expand Down
Loading