From bd5fc17c9ba9fa69aadce903e054ec7e7f09749d Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Mon, 5 Feb 2024 20:35:01 +0100 Subject: Drop support for parsing/transforming content tags 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. --- core/functions.php | 39 ++++++++------------------------------- 1 file changed, 8 insertions(+), 31 deletions(-) (limited to 'core/functions.php') 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'] ?? []; @@ -150,40 +153,14 @@ function generateCategoryDataTree(array $category_data, $root = 0): array { return $tree[$root] ?? []; } -#=============================================================================== -# 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; -- cgit v1.2.3