Display an error message listing empty feeds (no read/unread items)

This commit is contained in:
doubleface 2013-07-11 08:24:10 -04:00
parent a89d8c0005
commit bfa5709c07
3 changed files with 31 additions and 0 deletions

View File

@ -344,6 +344,11 @@ Router\get_action('refresh-all', function() {
// Display all feeds
Router\get_action('feeds', function() {
$empty_feeds = Model\get_empty_feeds();
if (count($empty_feeds) > 0) {
$message = t('The following feeds are empty, there may be an error : ') . implode(', ', $empty_feeds);
Session\flash_error($message);
}
Response\html(Template\layout('feeds', array(
'feeds' => Model\get_feeds(),
'nothing_to_read' => Request\int_param('nothing_to_read'),

View File

@ -1,6 +1,8 @@
<?php
return array(
'The following feeds are empty, there may be an error : ' =>
'Les abonnements suivants sont vides, il doit y avoir une erreur :',
'Items per page' => 'Nombre d\'éléments par page',
'Previous page' => 'Page précédente',
'Next page' => 'Page suivante',

View File

@ -247,6 +247,30 @@ function get_feed($feed_id)
->findOne();
}
function get_empty_feeds()
{
$feeds = \PicoTools\singleton('db')
->table('feeds')
->gt('last_checked', 0)
->asc('id')
->listing('id', 'title');
$ids = array_keys($feeds);
// fake DISTINCT
$not_empty_feeds = \PicoTools\singleton('db')
->table('items')
->asc('feed_id')
->listing('feed_id', 'feed_id');
$not_empty_ids = array_keys($not_empty_feeds);
$diff = array_diff($ids, $not_empty_ids);
$return = array();
foreach ($diff as $id) {
$return[$id] = $feeds[$id];
}
return $return;
}
function update_feed_last_checked($feed_id)
{