diff options
author | Thomas Lange <code@nerdmind.de> | 2021-06-21 18:33:23 +0200 |
---|---|---|
committer | Thomas Lange <code@nerdmind.de> | 2021-06-21 18:33:23 +0200 |
commit | bb9f45b1153d82359fef052a0a04147d4b794704 (patch) | |
tree | 4fe596364d3397f090b0a94085bd8533a234d051 /core | |
parent | 825b8574adc64286f169186db6556c801af7f1ca (diff) | |
download | blog-bb9f45b1153d82359fef052a0a04147d4b794704.tar.gz blog-bb9f45b1153d82359fef052a0a04147d4b794704.tar.xz blog-bb9f45b1153d82359fef052a0a04147d4b794704.zip |
Add function parseEntityContent
Diffstat (limited to 'core')
-rw-r--r-- | core/functions.php | 32 |
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 { |