summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-05-12 19:21:39 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2013-05-12 19:21:39 +0200
commit9e219cbf5014c8f4f52f3ca6722f7a20cdcc13dd (patch)
tree61ca24126a92471febcf945b439fc335978fcb2b
parentbf4552072418268470f81ba3883009da675800e4 (diff)
Fix issue #70 : lorsqu'on rencontre un problème avec un flux, on l'indique à l'utilisateur (couleur rouge)
-rwxr-xr-xapp/controllers/feedController.php3
-rw-r--r--app/i18n/en.php1
-rw-r--r--app/i18n/fr.php1
-rw-r--r--app/layout/aside_feed.phtml2
-rw-r--r--app/layout/aside_flux.phtml2
-rw-r--r--app/models/Feed.php30
-rw-r--r--app/views/configure/feed.phtml4
-rw-r--r--public/theme/freshrss.css3
-rw-r--r--public/theme/global.css7
9 files changed, 49 insertions, 4 deletions
diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php
index 77f1787d0..a41d7a33f 100755
--- a/app/controllers/feedController.php
+++ b/app/controllers/feedController.php
@@ -159,8 +159,7 @@ class feedController extends ActionController {
$feedDAO->updateLastUpdate ($feed->id ());
} catch (FeedException $e) {
Log::record ($e->getMessage (), Log::ERROR);
- // TODO si on a une erreur ici, il faut mettre
- // le flux à jour en BDD (error = 1) (issue #70)
+ $feedDAO->isInError ($feed->id ());
}
// On arrête à 10 flux pour ne pas surcharger le serveur
diff --git a/app/i18n/en.php b/app/i18n/en.php
index c832a519f..3c3a1fbcc 100644
--- a/app/i18n/en.php
+++ b/app/i18n/en.php
@@ -114,6 +114,7 @@ return array (
'or' => 'or',
'informations' => 'Informations',
+ 'feed_in_error' => 'This feed has encountered a problem. Please verify that it is always reachable.',
'website_url' => 'Website URL',
'feed_url' => 'Feed URL',
'number_articles' => 'Number of articles',
diff --git a/app/i18n/fr.php b/app/i18n/fr.php
index 165b183eb..d270c9b96 100644
--- a/app/i18n/fr.php
+++ b/app/i18n/fr.php
@@ -114,6 +114,7 @@ return array (
'or' => 'ou',
'informations' => 'Informations',
+ 'feed_in_error' => 'Ce flux a rencontré un problème. Veuillez vérifier qu\'il est toujours accessible.',
'website_url' => 'URL du site',
'feed_url' => 'URL du flux',
'number_articles' => 'Nombre d\'articles',
diff --git a/app/layout/aside_feed.phtml b/app/layout/aside_feed.phtml
index 158f012d0..4c56d12fc 100644
--- a/app/layout/aside_feed.phtml
+++ b/app/layout/aside_feed.phtml
@@ -43,7 +43,7 @@
<?php if (!empty ($this->feeds)) { ?>
<?php foreach ($this->feeds as $feed) { ?>
- <li class="item<?php echo ($this->flux && $this->flux->id () == $feed->id ()) ? ' active' : ''; ?>">
+ <li class="item<?php echo ($this->flux && $this->flux->id () == $feed->id ()) ? ' active' : ''; ?><?php echo $feed->inError () ? ' error' : ''; ?>">
<a href="<?php echo _url ('configure', 'feed', 'id', $feed->id ()); ?>">
<img class="favicon" src="<?php echo $feed->favicon (); ?>" alt="" />
<?php echo $feed->name (); ?>
diff --git a/app/layout/aside_flux.phtml b/app/layout/aside_flux.phtml
index d1fe6b759..449ffaff4 100644
--- a/app/layout/aside_flux.phtml
+++ b/app/layout/aside_flux.phtml
@@ -62,7 +62,7 @@
<ul class="feeds<?php echo $c_active ? ' active' : ''; ?>">
<?php foreach ($feeds as $feed) { ?>
<?php $f_active = false; if ($this->get_f == $feed->id ()) { $f_active = true; } ?>
- <li class="item<?php echo $f_active ? ' active' : ''; ?>">
+ <li class="item<?php echo $f_active ? ' active' : ''; ?><?php echo $feed->inError () ? ' error' : ''; ?>">
<div class="dropdown">
<div id="dropdown-<?php echo $feed->id(); ?>" class="dropdown-target"></div>
<a class="dropdown-toggle" href="#dropdown-<?php echo $feed->id(); ?>"><i class="icon i_configure"></i></a>
diff --git a/app/models/Feed.php b/app/models/Feed.php
index 51c409b69..0fc9640bc 100644
--- a/app/models/Feed.php
+++ b/app/models/Feed.php
@@ -12,6 +12,7 @@ class Feed extends Model {
private $priority = 10;
private $pathEntries = '';
private $httpAuth = '';
+ private $error = false;
public function __construct ($url) {
$this->_url ($url);
@@ -69,6 +70,9 @@ class Feed extends Model {
);
}
}
+ public function inError () {
+ return $this->error;
+ }
public function nbEntries () {
$feedDAO = new FeedDAO ();
return $feedDAO->countEntries ($this->id ());
@@ -138,6 +142,14 @@ class Feed extends Model {
public function _httpAuth ($value) {
$this->httpAuth = $value;
}
+ public function _error ($value) {
+ if ($value) {
+ $value = true;
+ } else {
+ $value = false;
+ }
+ $this->error = $value;
+ }
public function load () {
if (!is_null ($this->url)) {
@@ -306,6 +318,23 @@ class FeedDAO extends Model_pdo {
}
}
+ public function isInError ($id) {
+ $sql = 'UPDATE feed SET error=1 WHERE id=?';
+ $stm = $this->bd->prepare ($sql);
+
+ $values = array (
+ $id
+ );
+
+ if ($stm && $stm->execute ($values)) {
+ return true;
+ } else {
+ $info = $stm->errorInfo();
+ Log::record ('SQL error : ' . $info[2], Log::ERROR);
+ return false;
+ }
+ }
+
public function changeCategory ($idOldCat, $idNewCat) {
$catDAO = new CategoryDAO ();
$newCat = $catDAO->searchById ($idNewCat);
@@ -470,6 +499,7 @@ class HelperFeed {
$list[$key]->_priority ($dao['priority']);
$list[$key]->_pathEntries ($dao['pathEntries']);
$list[$key]->_httpAuth (base64_decode ($dao['httpAuth']));
+ $list[$key]->_error ($dao['error']);
if (isset ($dao['id'])) {
$list[$key]->_id ($dao['id']);
diff --git a/app/views/configure/feed.phtml b/app/views/configure/feed.phtml
index 33483f72d..ad9c86d9e 100644
--- a/app/views/configure/feed.phtml
+++ b/app/views/configure/feed.phtml
@@ -7,6 +7,10 @@
<h1><?php echo $this->flux->name (); ?></h1>
<?php echo $this->flux->description (); ?>
+ <?php if ($this->flux->inError ()) { ?>
+ <p class="alert alert-error"><span class="alert-head"><?php echo Translate::t ('damn'); ?></span> <?php echo Translate::t ('feed_in_error'); ?></p>
+ <?php } ?>
+
<form method="post" action="<?php echo _url ('configure', 'feed', 'id', $this->flux->id ()); ?>">
<legend><?php echo Translate::t ('informations'); ?></legend>
<div class="form-group">
diff --git a/public/theme/freshrss.css b/public/theme/freshrss.css
index 3ab7177d5..d7370cb8a 100644
--- a/public/theme/freshrss.css
+++ b/public/theme/freshrss.css
@@ -114,6 +114,9 @@
line-height: 35px;
float: right;
}
+ .categories .feeds .item.error .feed {
+ color: #BD362F;
+ }
.categories .feeds .item .feed {
display: inline-block;
margin: 0;
diff --git a/public/theme/global.css b/public/theme/global.css
index 99b335585..258d84baf 100644
--- a/public/theme/global.css
+++ b/public/theme/global.css
@@ -261,6 +261,13 @@ input, select, textarea {
.nav.nav-list a:hover {
text-decoration: none;
}
+ .nav.nav-list .item.error a {
+ color: #BD362F;
+ }
+ .nav.nav-list .item.active.error a {
+ color: #fff;
+ background: #BD362F;
+ }
.nav.nav-list .nav-header {
padding: 0 10px;