aboutsummaryrefslogtreecommitdiffstats
path: root/core/functions.php
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2021-06-21 16:22:00 +0200
committerThomas Lange <code@nerdmind.de>2021-06-21 16:22:00 +0200
commit93d7ccc3a1ac46738e29ba3ffd4b9abe92c6b39f (patch)
tree41bf339ae92784b76cc5adeeb68844a428e7a4fb /core/functions.php
parentdb3e19a76a2335c9cf88fb08441b35e0cc3648fc (diff)
downloadblog-93d7ccc3a1ac46738e29ba3ffd4b9abe92c6b39f.tar.gz
blog-93d7ccc3a1ac46738e29ba3ffd4b9abe92c6b39f.tar.xz
blog-93d7ccc3a1ac46738e29ba3ffd4b9abe92c6b39f.zip
Add function generatePseudoGUID
Diffstat (limited to 'core/functions.php')
-rw-r--r--core/functions.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/core/functions.php b/core/functions.php
index 519e5f1..ca13e3d 100644
--- a/core/functions.php
+++ b/core/functions.php
@@ -104,6 +104,28 @@ function generateItemTemplateData(Item $Item): array {
}
#===============================================================================
+# Generate pseudo GUID for entity
+#===============================================================================
+function generatePseudoGUID(Item $Entity) {
+ switch(get_class($Entity)) {
+ case "Page\Item":
+ $attr = Application::get('PAGE.FEED_GUID');
+ break;
+ case "Post\Item":
+ $attr = Application::get('POST.FEED_GUID');
+ break;
+ default:
+ $attr = ['id', 'time_insert'];
+ }
+
+ foreach($attr as $attribute) {
+ $attributes[] = $Entity->attr($attribute);
+ }
+
+ return sha1(implode('', $attributes));
+}
+
+#===============================================================================
# Parser for datetime formatted strings [YYYY-MM-DD HH:II:SS]
#===============================================================================
function parseDatetime($datetime, $format): string {