aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2024-02-05 20:35:01 +0100
committerThomas Lange <code@nerdmind.de>2024-02-05 20:47:35 +0100
commitbd5fc17c9ba9fa69aadce903e054ec7e7f09749d (patch)
tree63f11e814702fe5035f26c67b87d9b8160a18a54 /core
parent00bf20ed68fb8b833967c207bb3689dc96098073 (diff)
downloadblog-bd5fc17c9ba9fa69aadce903e054ec7e7f09749d.tar.gz
blog-bd5fc17c9ba9fa69aadce903e054ec7e7f09749d.tar.xz
blog-bd5fc17c9ba9fa69aadce903e054ec7e7f09749d.zip
Drop support for parsing/transforming content tagsHEADmaster
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.php39
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;