Fix issue #37 : possibilité de sortir un site du flux principal (utile pour les sites qui publient beaucoup)

pull/136/head
Marien Fressinaud 12 years ago
parent 61943f1661
commit e2171de4e6
  1. 4
      app/controllers/configureController.php
  2. 4
      app/controllers/indexController.php
  3. 23
      app/models/Entry.php
  4. 11
      app/models/Feed.php
  5. 15
      app/views/configure/feed.phtml

@ -88,10 +88,12 @@ class configureController extends ActionController {
if (Request::isPost () && $this->view->flux) { if (Request::isPost () && $this->view->flux) {
$cat = Request::param ('category', 0); $cat = Request::param ('category', 0);
$path = Request::param ('path_entries', ''); $path = Request::param ('path_entries', '');
$priority = Request::param ('priority', 0);
$values = array ( $values = array (
'category' => $cat, 'category' => $cat,
'pathEntries' => $path 'pathEntries' => $path,
'priority' => $priority
); );
if ($feedDAO->updateFeed ($id, $values)) { if ($feedDAO->updateFeed ($id, $values)) {

@ -76,9 +76,7 @@ class indexController extends ActionController {
try { try {
$this->view->entryPaginator = $entryDAO->getPaginator ($entries); $this->view->entryPaginator = $entryDAO->getPaginator ($entries);
} catch (CurrentPagePaginationException $e) { } catch (CurrentPagePaginationException $e) { }
}
$this->view->cat_aside = $catDAO->listCategories (); $this->view->cat_aside = $catDAO->listCategories ();
$this->view->nb_favorites = $entryDAO->countFavorites (); $this->view->nb_favorites = $entryDAO->countFavorites ();

@ -272,7 +272,7 @@ class EntryDAO extends Model_pdo {
} }
public function markReadEntries ($read, $dateMax) { public function markReadEntries ($read, $dateMax) {
$sql = 'UPDATE entry SET is_read = ? WHERE date < ?'; $sql = 'UPDATE entry e INNER JOIN feed f ON e.id_feed = f.id SET is_read = ? WHERE date < ? AND priority > 0';
$stm = $this->bd->prepare ($sql); $stm = $this->bd->prepare ($sql);
$values = array ($read, $dateMax); $values = array ($read, $dateMax);
@ -377,19 +377,15 @@ class EntryDAO extends Model_pdo {
} }
public function listEntries ($mode, $search = false, $order = 'high_to_low') { public function listEntries ($mode, $search = false, $order = 'high_to_low') {
$where = ''; $where = ' WHERE priority > 0';
if ($mode == 'not_read') { if ($mode == 'not_read') {
$where = ' WHERE is_read=0'; $where .= ' AND is_read=0';
} }
$values = array(); $values = array();
if ($search) { if ($search) {
$values[] = '%'.$search.'%'; $values[] = '%'.$search.'%';
if ($mode == 'not_read') { $where .= ' AND title LIKE ?';
$where = ' AND title LIKE ?';
} else {
$where = ' WHERE title LIKE ?';
}
} }
if ($order == 'low_to_high') { if ($order == 'low_to_high') {
@ -398,7 +394,7 @@ class EntryDAO extends Model_pdo {
$order = ''; $order = '';
} }
$sql = 'SELECT COUNT(*) AS count FROM entry' . $where; $sql = 'SELECT COUNT(*) AS count FROM entry e INNER JOIN feed f ON e.id_feed = f.id' . $where;
$stm = $this->bd->prepare ($sql); $stm = $this->bd->prepare ($sql);
$stm->execute ($values); $stm->execute ($values);
$res = $stm->fetchAll (PDO::FETCH_ASSOC); $res = $stm->fetchAll (PDO::FETCH_ASSOC);
@ -407,7 +403,8 @@ class EntryDAO extends Model_pdo {
$deb = ($this->currentPage () - 1) * $this->nbItemsPerPage; $deb = ($this->currentPage () - 1) * $this->nbItemsPerPage;
$fin = $this->nbItemsPerPage; $fin = $this->nbItemsPerPage;
$sql = 'SELECT * FROM entry' . $where $sql = 'SELECT * FROM entry e'
. ' INNER JOIN feed f ON e.id_feed = f.id' . $where
. ' ORDER BY date' . $order . ' ORDER BY date' . $order
. ' LIMIT ' . $deb . ', ' . $fin; . ' LIMIT ' . $deb . ', ' . $fin;
$stm = $this->bd->prepare ($sql); $stm = $this->bd->prepare ($sql);
@ -553,7 +550,7 @@ class EntryDAO extends Model_pdo {
} }
public function count () { public function count () {
$sql = 'SELECT COUNT(*) AS count FROM entry'; $sql = 'SELECT COUNT(*) AS count FROM entry e INNER JOIN feed f ON e.id_feed = f.id WHERE priority > 0';
$stm = $this->bd->prepare ($sql); $stm = $this->bd->prepare ($sql);
$stm->execute (); $stm->execute ();
$res = $stm->fetchAll (PDO::FETCH_ASSOC); $res = $stm->fetchAll (PDO::FETCH_ASSOC);
@ -562,11 +559,11 @@ class EntryDAO extends Model_pdo {
} }
public function countNotRead () { public function countNotRead () {
$sql = 'SELECT COUNT(*) AS count FROM entry WHERE is_read=0'; $sql = 'SELECT COUNT(*) AS count FROM entry e INNER JOIN feed f ON e.id_feed = f.id WHERE is_read=0 AND priority > 0';
$stm = $this->bd->prepare ($sql); $stm = $this->bd->prepare ($sql);
$stm->execute (); $stm->execute ();
$res = $stm->fetchAll (PDO::FETCH_ASSOC); $res = $stm->fetchAll (PDO::FETCH_ASSOC);
Log::record ('not read : ' . $res[0]['count'], Log::NOTICE);
return $res[0]['count']; return $res[0]['count'];
} }

@ -9,6 +9,7 @@ class Feed extends Model {
private $website = ''; private $website = '';
private $description = ''; private $description = '';
private $lastUpdate = 0; private $lastUpdate = 0;
private $priority = 10;
private $pathEntries = ''; private $pathEntries = '';
private $httpAuth = ''; private $httpAuth = '';
@ -48,6 +49,9 @@ class Feed extends Model {
public function lastUpdate () { public function lastUpdate () {
return $this->lastUpdate; return $this->lastUpdate;
} }
public function priority () {
return $this->priority;
}
public function pathEntries () { public function pathEntries () {
return $this->pathEntries; return $this->pathEntries;
} }
@ -108,6 +112,12 @@ class Feed extends Model {
public function _lastUpdate ($value) { public function _lastUpdate ($value) {
$this->lastUpdate = $value; $this->lastUpdate = $value;
} }
public function _priority ($value) {
if (!is_int (intval ($value))) {
$value = 10;
}
$this->priority = $value;
}
public function _pathEntries ($value) { public function _pathEntries ($value) {
$this->pathEntries = $value; $this->pathEntries = $value;
} }
@ -382,6 +392,7 @@ class HelperFeed {
$list[$key]->_website ($dao['website']); $list[$key]->_website ($dao['website']);
$list[$key]->_description ($dao['description']); $list[$key]->_description ($dao['description']);
$list[$key]->_lastUpdate ($dao['lastUpdate']); $list[$key]->_lastUpdate ($dao['lastUpdate']);
$list[$key]->_priority ($dao['priority']);
$list[$key]->_pathEntries ($dao['pathEntries']); $list[$key]->_pathEntries ($dao['pathEntries']);
$list[$key]->_httpAuth ($dao['httpAuth']); $list[$key]->_httpAuth ($dao['httpAuth']);

@ -9,28 +9,25 @@
<form method="post" action="<?php echo _url ('configure', 'feed', 'id', $this->flux->id ()); ?>"> <form method="post" action="<?php echo _url ('configure', 'feed', 'id', $this->flux->id ()); ?>">
<legend>Informations</legend> <legend>Informations</legend>
<div class="form-group"> <div class="form-group">
<label class="group-name">URL du site</label> <label class="group-name">URL du site</label>
<div class="group-controls"> <div class="group-controls">
<span class="control"><a target="_blank" href="<?php echo $this->flux->website (); ?>"><?php echo $this->flux->website (); ?></a></span> <span class="control"><a target="_blank" href="<?php echo $this->flux->website (); ?>"><?php echo $this->flux->website (); ?></a></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="group-name">URL du flux</label> <label class="group-name">URL du flux</label>
<div class="group-controls"> <div class="group-controls">
<span class="control"><a target="_blank" href="<?php echo $this->flux->url (); ?>"><?php echo $this->flux->url (); ?></a></span> <span class="control"><a target="_blank" href="<?php echo $this->flux->url (); ?>"><?php echo $this->flux->url (); ?></a></span>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="group-name">Nombre d'articles</label> <label class="group-name">Nombre d'articles</label>
<div class="group-controls"> <div class="group-controls">
<span class="control"><?php echo $this->flux->nbEntries (); ?></span> <span class="control"><?php echo $this->flux->nbEntries (); ?></span>
</div> </div>
</div> </div>
<legend>Catégorie - <a href="<?php echo _url ('configure', 'categorize'); ?>">gestion</a></legend> <legend>Catégorie - <a href="<?php echo _url ('configure', 'categorize'); ?>">gestion</a></legend>
<div class="form-group"> <div class="form-group">
<label class="group-name">Ranger dans une catégorie</label> <label class="group-name">Ranger dans une catégorie</label>
@ -45,6 +42,15 @@
</div> </div>
<legend>Avancé</legend> <legend>Avancé</legend>
<div class="form-group">
<label class="group-name" for="priority">Afficher dans le flux principal</label>
<div class="group-controls">
<label class="checkbox" for="priority">
<input type="checkbox" name="priority" id="priority" value="10"<?php echo $this->flux->priority () > 0 ? ' checked="checked"' : ''; ?> />
Oui
</label>
</div>
</div>
<div class="form-group"> <div class="form-group">
<label class="group-name" for="path_entries">Chemin CSS des articles sur le site d'origine</label> <label class="group-name" for="path_entries">Chemin CSS des articles sur le site d'origine</label>
<div class="group-controls"> <div class="group-controls">
@ -52,7 +58,6 @@
<i class="icon i_help"></i> Permet de récupérer les flux tronqués (attention, demande plus de temps !) <i class="icon i_help"></i> Permet de récupérer les flux tronqués (attention, demande plus de temps !)
</div> </div>
</div> </div>
<!-- <!--
<div class="form-group"> <div class="form-group">
<label class="group-name" for="http_user">Username HTTP</label> <label class="group-name" for="http_user">Username HTTP</label>

Loading…
Cancel
Save