Files
FreshRSS/app/views/helpers/export/articles.phtml
Alexis Degrugillier 72884813e1 Add hook enums (#8036)
- add an enum to handle hook types (enum are available since PHP 8.1)
- change hook calls from string value to enum value
2025-09-30 22:59:41 +02:00

48 lines
1.1 KiB
PHTML

<?php
declare(strict_types=1);
/** @var FreshRSS_View $this */
$username = Minz_User::name() ?? Minz_User::INTERNAL_USER;
$options = JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
$articles = [
'id' => 'user/' . str_replace('/', '', $username) . '/state/org.freshrss/' . $this->type,
'title' => $this->list_title,
'author' => $username,
'items' => [],
];
echo rtrim(json_encode($articles, $options) ?: '', " ]}\n\r\t"), "\n";
$first = true;
if (empty($this->entryIdsTagNames)) {
$this->entryIdsTagNames = [];
}
foreach ($this->entries as $entry) {
if (!$this->internal_rendering) {
/** @var FreshRSS_Entry|null $entry */
$entry = Minz_ExtensionManager::callHook(Minz_HookType::EntryBeforeDisplay, $entry);
}
if ($entry === null) {
continue;
}
$feed = $this->feed ?? FreshRSS_Category::findFeed($this->categories, $entry->feedId());
$entry->_feed($feed);
$article = $entry->toGReader('freshrss', $this->entryIdsTagNames['e_' . $entry->id()] ?? []);
$line = json_encode($article, $options);
if ($line != '') {
if ($first) {
$first = false;
} else {
echo ",\n";
}
echo $line;
}
}
echo "\n]}\n";