aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2021-06-21 18:33:23 +0200
committerThomas Lange <code@nerdmind.de>2021-06-21 18:33:23 +0200
commitbb9f45b1153d82359fef052a0a04147d4b794704 (patch)
tree4fe596364d3397f090b0a94085bd8533a234d051
parent825b8574adc64286f169186db6556c801af7f1ca (diff)
downloadblog-bb9f45b1153d82359fef052a0a04147d4b794704.tar.gz
blog-bb9f45b1153d82359fef052a0a04147d4b794704.tar.xz
blog-bb9f45b1153d82359fef052a0a04147d4b794704.zip
Add function parseEntityContent
-rw-r--r--core/functions.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/core/functions.php b/core/functions.php
index 6babd91..98c99c3 100644
--- a/core/functions.php
+++ b/core/functions.php
@@ -152,6 +152,38 @@ function parseContentTags(string $text): string {
}
#===============================================================================
+# Parse entity content
+#===============================================================================
+function parseEntityContent(Item $Item): string {
+ switch($class = get_class($Item)) {
+ case 'Page\Item':
+ $prefix = 'PAGE';
+ break;
+ case 'Post\Item':
+ $prefix = 'POST';
+ break;
+ case 'User\Item':
+ $prefix = 'USER';
+ break;
+ default:
+ $error = 'Unknown config prefix for <code>%s</code> entities.';
+ throw new Exception(sprintf($error, $class));
+ }
+
+ $Parsedown = new Parsedown();
+ $Parsedown->setUrlsLinked(FALSE);
+
+ $text = parseContentTags($Item->attr('body'));
+
+ if(Application::get("$prefix.EMOTICONS")) {
+ $text = parseUnicodeEmoticons($text);
+ $text = parseEmoticons($text);
+ }
+
+ return $Parsedown->text($text);
+}
+
+#===============================================================================
# Parser for datetime formatted strings [YYYY-MM-DD HH:II:SS]
#===============================================================================
function parseDatetime($datetime, $format): string {