diff options
author | Thomas Lange <code@nerdmind.de> | 2021-07-24 21:53:10 +0200 |
---|---|---|
committer | Thomas Lange <code@nerdmind.de> | 2021-07-24 22:18:07 +0200 |
commit | 3037af3a80246870284e7c1ab52f407a081f5ffd (patch) | |
tree | 01bc9555c881c8fe73e3c0b32400f68dfe675bf9 | |
parent | 434c48cff635317e51286e9bf2f1681feb48bf4b (diff) | |
download | blog-3037af3a80246870284e7c1ab52f407a081f5ffd.tar.gz blog-3037af3a80246870284e7c1ab52f407a081f5ffd.tar.xz blog-3037af3a80246870284e7c1ab52f407a081f5ffd.zip |
Create feed item's GUID manually in template file
Do not rely on the "$POST['GUID']" template parameter anymore and create
the GUID for the feed item manually in the feed item's template file.
The application internal function "generatePseudoGUID" has been removed
and the function "generateItemTemplateData" will not return the "GUID"
part anymore (which was only used by the feed item template anyway).
For backward compatibility, the "$POST['GUID']" template parameter will
still be present in the feed item template, but not in other templates!
-rw-r--r-- | core/functions.php | 11 | ||||
-rw-r--r-- | core/include/feed/main.php | 5 | ||||
-rw-r--r-- | theme/default/html/feed/item.php | 2 |
3 files changed, 5 insertions, 13 deletions
diff --git a/core/functions.php b/core/functions.php index 538849b..bf04ccc 100644 --- a/core/functions.php +++ b/core/functions.php @@ -111,7 +111,6 @@ function generateItemTemplateData(EntityInterface $Entity): array { return [ 'URL' => Application::getEntityURL($Entity), - 'GUID' => generatePseudoGUID($Entity), 'ARGV' => $arguments, 'ATTR' => $attribute, @@ -152,16 +151,6 @@ function generateCategoryDataTree(array $category_data, $root = 0): array { } #=============================================================================== -# Generate pseudo GUID for entity -#=============================================================================== -function generatePseudoGUID(EntityInterface $Entity) { - return sha1(implode('', [ - $Entity->getID(), - $Entity->get('time_insert') - ])); -} - -#=============================================================================== # Parse content tags #=============================================================================== function parseContentTags(string $text): string { diff --git a/core/include/feed/main.php b/core/include/feed/main.php index cbabb2c..9f1e4d4 100644 --- a/core/include/feed/main.php +++ b/core/include/feed/main.php @@ -31,7 +31,10 @@ foreach($posts as $Post) { $ItemTemplate = Template\Factory::build('feed/item_post'); } - $ItemTemplate->set('POST', generateItemTemplateData($Post)); + $post_data = generateItemTemplateData($Post); + $post_data['GUID'] = sha1($Post->getID().$Post->get('time_insert')); + + $ItemTemplate->set('POST', $post_data); $ItemTemplate->set('USER', generateItemTemplateData($User)); $templates[] = $ItemTemplate; diff --git a/theme/default/html/feed/item.php b/theme/default/html/feed/item.php index 0bf23fc..088aa34 100644 --- a/theme/default/html/feed/item.php +++ b/theme/default/html/feed/item.php @@ -12,7 +12,7 @@ $HTML = $POST['BODY']['HTML'](); <item> <title><?=escapeHTML($POST['ATTR']['NAME'])?></title> <link><?=$POST['URL']?></link> - <guid isPermaLink="false"><?=$POST['GUID']?></guid> + <guid isPermaLink="false"><?=sha1($POST['ATTR']['ID'].$POST['ATTR']['TIME_INSERT']);?></guid> <pubDate><?=parseDatetime($POST['ATTR']['TIME_INSERT'], '[RFC2822]')?></pubDate> <dc:creator><?=escapeHTML($USER['ATTR']['FULLNAME'])?></dc:creator> <description><?=escapeHTML(description($HTML, 400))?></description> |