diff options
author | Thomas Lange <code@nerdmind.de> | 2024-02-05 20:35:01 +0100 |
---|---|---|
committer | Thomas Lange <code@nerdmind.de> | 2024-02-05 20:47:35 +0100 |
commit | bd5fc17c9ba9fa69aadce903e054ec7e7f09749d (patch) | |
tree | 63f11e814702fe5035f26c67b87d9b8160a18a54 /core | |
parent | 00bf20ed68fb8b833967c207bb3689dc96098073 (diff) | |
download | blog-bd5fc17c9ba9fa69aadce903e054ec7e7f09749d.tar.gz blog-bd5fc17c9ba9fa69aadce903e054ec7e7f09749d.tar.xz blog-bd5fc17c9ba9fa69aadce903e054ec7e7f09749d.zip |
The *content tags* are deprecated since July 2021 and have been replaced
by the more powerful *content functions*, but parsing/transforming the
old syntax was still supported until today.
This commit removes the logic to parse/transform the old *content tags*
from the codebase completely. If you are still using the old syntax in
your entities' content, you need to run a converter script.
Please look at the wiki for more information about *content functions*
and how to replace the old *content tags* with the converter script.
Diffstat (limited to 'core')
-rw-r--r-- | core/functions.php | 39 |
1 files changed, 8 insertions, 31 deletions
diff --git a/core/functions.php b/core/functions.php index 6350ff1..2155d96 100644 --- a/core/functions.php +++ b/core/functions.php @@ -98,12 +98,15 @@ function generateUserItemTemplate(User $User): Template { #=============================================================================== function generateItemTemplateData(EntityInterface $Entity): array { $ArgumentParser = new ArgumentParser; + $FunctionParser = new FunctionParser; $MarkdownParser = new MarkdownParser; $attribute = $Entity->getAll(['password']); $attribute = array_change_key_case($attribute, CASE_UPPER); - $text = parseContentTags($Entity->get('body')); + $text = $Entity->get('body'); + $text = $FunctionParser->transform($text); + $arguments = $ArgumentParser->parse($Entity->get('argv') ?? ''); $images = $MarkdownParser->parse($text)['img']['src'] ?? []; @@ -151,39 +154,13 @@ function generateCategoryDataTree(array $category_data, $root = 0): array { } #=============================================================================== -# Parse content tags -#=============================================================================== -function parseContentTags(string $text): string { - $entity_tags = '#\{(POST|PAGE|USER)\[([0-9]+)\]\}#'; - - $text = preg_replace_callback($entity_tags, function($matches) { - $namespace = ucfirst(strtolower($matches[1])); - $Repository = Application::getRepository($namespace); - - if($Entity = $Repository->find($matches[2])) { - return Application::getEntityURL($Entity); - } - - else { - return '{undefined}'; - } - }, $text); - - $base_tag = '#\{BASE\[\"([^"]+)\"\]\}#'; - $file_tag = '#\{FILE\[\"([^"]+)\"\]\}#'; - - $text = preg_replace($base_tag, \Application::getURL('$1'), $text); - $text = preg_replace($file_tag, \Application::getFileURL('$1'), $text); - - $FunctionParser = new FunctionParser; - return $FunctionParser->transform($text); -} - -#=============================================================================== # Parse entity content #=============================================================================== function parseEntityContent(EntityInterface $Entity): string { - $text = parseContentTags($Entity->get('body')); + $text = $Entity->get('body'); + + $FunctionParser = new FunctionParser(); + $text = $FunctionParser->transform($text); if(Application::get('WRAP_EMOTICONS')) { $EmoticonParser = new EmoticonParser; |