mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-07-16 18:12:53 -04:00
* Generate new articles notification string in PHP Closes #6470 Changes proposed in this pull request: - Generate notifications string in PHP - Use plurals support * New articles notification: switch to plural forms * README status * fix paramInt invocation * i18n * make fix-all * Apply suggestion from @Frenzie --------- Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
29 lines
943 B
PHTML
29 lines
943 B
PHTML
<?php
|
|
declare(strict_types=1);
|
|
/** @var FreshRSS_ViewJavascript $this */
|
|
|
|
$result = [
|
|
'feeds' => [],
|
|
'tags' => [],
|
|
];
|
|
$nbUnreadFeeds = 0;
|
|
foreach ($this->categories as $cat) {
|
|
foreach ($cat->feeds() as $feed) {
|
|
if ($feed->priority() > FreshRSS_Feed::PRIORITY_HIDDEN) {
|
|
$feedUnread = $feed->nbNotRead();
|
|
$result['feeds'][$feed->id()] = $feedUnread;
|
|
$nbUnreadFeeds += $feedUnread;
|
|
}
|
|
}
|
|
}
|
|
foreach ($this->tags as $tag) {
|
|
$result['tags'][$tag->id()] = $tag->nbUnread();
|
|
}
|
|
$nbUnreadBefore = max(0, Minz_Request::paramInt('previous_unread') ?: 0);
|
|
$nbNew = max(0, $nbUnreadFeeds - $nbUnreadBefore);
|
|
$result['notifBody'] = trim(
|
|
(Minz_Translate::plural('gen.js.feedback.body_new_articles', $nbNew) ?? _t('gen.js.feedback.body_new_articles', $nbNew)) . ' ' .
|
|
(Minz_Translate::plural('gen.js.feedback.body_unread_articles', $nbUnreadFeeds) ?? _t('gen.js.feedback.body_unread_articles', $nbUnreadFeeds))
|
|
);
|
|
echo json_encode($result);
|