aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2012-10-25 00:12:18 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2012-10-25 00:12:18 +0200
commit6723babdd65d946cdc7e315d7f11fb3ca0e455d3 (patch)
treee45359332c04fc5c935fbedecd1ade50b6430463
parent4924f4c6d6d03d39471de363b8d368c8edad8f3d (diff)
ajouts graphique + ajout suppression vieux articles
-rw-r--r--app/App_FrontController.php3
-rwxr-xr-xapp/controllers/configureController.php5
-rwxr-xr-xapp/controllers/feedController.php4
-rw-r--r--app/layout/aside.phtml7
-rwxr-xr-xapp/models/Category.php22
-rwxr-xr-xapp/models/Entry.php31
-rw-r--r--app/models/Feed.php6
-rwxr-xr-xapp/models/RSSConfiguration.php16
-rw-r--r--app/views/configure/display.phtml3
-rw-r--r--public/theme/base.css14
10 files changed, 91 insertions, 20 deletions
diff --git a/app/App_FrontController.php b/app/App_FrontController.php
index d61927c9e..6a8d1a28d 100644
--- a/app/App_FrontController.php
+++ b/app/App_FrontController.php
@@ -37,5 +37,8 @@ class App_FrontController extends FrontController {
private function loadParamsView () {
View::_param ('conf', Session::param ('conf', new RSSConfiguration ()));
+
+ $entryDAO = new EntryDAO ();
+ View::_param ('nb_not_read', $entryDAO->countNotRead ());
}
}
diff --git a/app/controllers/configureController.php b/app/controllers/configureController.php
index b382b2794..daabfd3bb 100755
--- a/app/controllers/configureController.php
+++ b/app/controllers/configureController.php
@@ -68,17 +68,20 @@ class configureController extends ActionController {
$view = Request::param ('default_view', 'all');
$display = Request::param ('display_posts', 'no');
$sort = Request::param ('sort_order', 'low_to_high');
+ $old = Request::param ('old_entries', 3);
$this->view->conf->_postsPerPage (intval ($nb));
$this->view->conf->_defaultView ($view);
$this->view->conf->_displayPosts ($display);
$this->view->conf->_sortOrder ($sort);
+ $this->view->conf->_oldEntries ($old);
$values = array (
'posts_per_page' => $this->view->conf->postsPerPage (),
'default_view' => $this->view->conf->defaultView (),
'display_posts' => $this->view->conf->displayPosts (),
- 'sort_order' => $this->view->conf->sortOrder ()
+ 'sort_order' => $this->view->conf->sortOrder (),
+ 'old_entries' => $this->view->conf->oldEntries (),
);
$confDAO = new RSSConfigurationDAO ();
diff --git a/app/controllers/feedController.php b/app/controllers/feedController.php
index 6dad1ac08..e728ac3b0 100755
--- a/app/controllers/feedController.php
+++ b/app/controllers/feedController.php
@@ -70,11 +70,11 @@ class feedController extends ActionController {
'id_feed' => $feed->id ()
);
$entryDAO->addEntry ($values);
-
- // TODO gérer suppression des articles trop vieux (à paramétrer)
}
}
+ $entryDAO->cleanOldEntries ($this->view->conf->oldEntries ());
+
Request::forward (array (), true);
}
diff --git a/app/layout/aside.phtml b/app/layout/aside.phtml
index 265a0902b..0b1d3f4f4 100644
--- a/app/layout/aside.phtml
+++ b/app/layout/aside.phtml
@@ -6,12 +6,15 @@
<ul id="menu">
<li <?php echo Request::controllerName () == 'index' ? 'class="active"' : ''; ?>>
- <a href="<?php echo Url::display (array ()); ?>">Flux RSS</a>
+ <a href="<?php echo Url::display (array ()); ?>">
+ Flux RSS <?php if ($this->nb_not_read > 0) { ?><span>(<?php echo $this->nb_not_read; ?> non lu<?php echo $this->nb_not_read > 1 ? 's' : ''; ?>)</span><?php } ?>
+ </a>
+
<?php if (isset ($this->cat_aside)) { ?>
<ul id="flux_menu">
<li><a href="<?php echo Url::display (array ('params' => array ('get' => 'favoris'))); ?>">Favoris</a></li>
<?php foreach ($this->cat_aside as $cat) { ?>
- <li><a href="<?php echo Url::display (array ('params' => array ('get' => $cat->id ()))); ?>"><?php echo $cat->name (); ?></a></li>
+ <li><a href="<?php echo Url::display (array ('params' => array ('get' => $cat->id ()))); ?>"><?php echo $cat->name (); ?> <span><?php echo $cat->nbFlux (); ?> flux</span></a></li>
<?php } ?>
</ul>
<?php } ?>
diff --git a/app/models/Category.php b/app/models/Category.php
index e0b8f564d..1713f615c 100755
--- a/app/models/Category.php
+++ b/app/models/Category.php
@@ -23,6 +23,10 @@ class Category extends Model {
public function color () {
return $this->color;
}
+ public function nbFlux () {
+ $catDAO = new CategoryDAO ();
+ return $catDAO->countFlux ($this->id ());
+ }
public function _id ($value) {
$this->id = $value;
@@ -76,7 +80,7 @@ class CategoryDAO extends Model_pdo {
public function deleteCategory ($id) {
$sql = 'DELETE FROM category WHERE id=?';
- $stm = $this->bd->prepare ($sql);
+ $stm = $this->bd->prepare ($sql);
$values = array ($id);
@@ -106,20 +110,30 @@ class CategoryDAO extends Model_pdo {
public function listCategories () {
$sql = 'SELECT * FROM category';
- $stm = $this->bd->prepare ($sql);
+ $stm = $this->bd->prepare ($sql);
$stm->execute ();
return HelperCategory::daoToCategory ($stm->fetchAll (PDO::FETCH_ASSOC));
}
public function count () {
- $sql = 'SELECT COUNT (*) AS count FROM category';
- $stm = $this->bd->prepare ($sql);
+ $sql = 'SELECT COUNT(*) AS count FROM category';
+ $stm = $this->bd->prepare ($sql);
$stm->execute ();
$res = $stm->fetchAll (PDO::FETCH_ASSOC);
return $res[0]['count'];
}
+
+ public function countFlux ($id) {
+ $sql = 'SELECT COUNT(*) AS count FROM feed WHERE category=?';
+ $stm = $this->bd->prepare ($sql);
+ $values = array ($id);
+ $stm->execute ($values);
+ $res = $stm->fetchAll (PDO::FETCH_ASSOC);
+
+ return $res[0]['count'];
+ }
}
class HelperCategory {
diff --git a/app/models/Entry.php b/app/models/Entry.php
index 437aa8050..6fcc821f4 100755
--- a/app/models/Entry.php
+++ b/app/models/Entry.php
@@ -161,6 +161,22 @@ class EntryDAO extends Model_pdo {
}
}
+ public function cleanOldEntries ($nb_month) {
+ $date = 60 * 60 * 24 * 30 * $nb_month;
+ $sql = 'DELETE FROM entry WHERE date <= ? AND is_favorite = 0';
+ $stm = $this->bd->prepare ($sql);
+
+ $values = array (
+ time () - $date
+ );
+
+ if ($stm && $stm->execute ($values)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
public function searchById ($id) {
$sql = 'SELECT * FROM entry WHERE id=?';
$stm = $this->bd->prepare ($sql);
@@ -191,7 +207,7 @@ class EntryDAO extends Model_pdo {
}
$sql = 'SELECT * FROM entry' . $where . ' ORDER BY date' . $order;
- $stm = $this->bd->prepare ($sql);
+ $stm = $this->bd->prepare ($sql);
$stm->execute ();
return HelperEntry::daoToEntry ($stm->fetchAll (PDO::FETCH_ASSOC));
@@ -241,13 +257,22 @@ class EntryDAO extends Model_pdo {
}
public function count () {
- $sql = 'SELECT COUNT (*) AS count FROM entry';
- $stm = $this->bd->prepare ($sql);
+ $sql = 'SELECT COUNT(*) AS count FROM entry';
+ $stm = $this->bd->prepare ($sql);
$stm->execute ();
$res = $stm->fetchAll (PDO::FETCH_ASSOC);
return $res[0]['count'];
}
+
+ public function countNotRead () {
+ $sql = 'SELECT COUNT(*) AS count FROM entry WHERE is_read=0';
+ $stm = $this->bd->prepare ($sql);
+ $stm->execute ();
+ $res = $stm->fetchAll (PDO::FETCH_ASSOC);
+
+ return $res[0]['count'];
+ }
}
class HelperEntry {
diff --git a/app/models/Feed.php b/app/models/Feed.php
index 8a3f826bd..cf1b3e06a 100644
--- a/app/models/Feed.php
+++ b/app/models/Feed.php
@@ -161,7 +161,7 @@ class FeedDAO extends Model_pdo {
public function listFeeds () {
$sql = 'SELECT * FROM feed';
- $stm = $this->bd->prepare ($sql);
+ $stm = $this->bd->prepare ($sql);
$stm->execute ();
return HelperFeed::daoToFeed ($stm->fetchAll (PDO::FETCH_ASSOC));
@@ -179,8 +179,8 @@ class FeedDAO extends Model_pdo {
}
public function count () {
- $sql = 'SELECT COUNT (*) AS count FROM feed';
- $stm = $this->bd->prepare ($sql);
+ $sql = 'SELECT COUNT(*) AS count FROM feed';
+ $stm = $this->bd->prepare ($sql);
$stm->execute ();
$res = $stm->fetchAll (PDO::FETCH_ASSOC);
diff --git a/app/models/RSSConfiguration.php b/app/models/RSSConfiguration.php
index da5028da3..8ee1717b3 100755
--- a/app/models/RSSConfiguration.php
+++ b/app/models/RSSConfiguration.php
@@ -5,6 +5,7 @@ class RSSConfiguration extends Model {
private $default_view;
private $display_posts;
private $sort_order;
+ private $old_entries;
public function __construct () {
$confDAO = new RSSConfigurationDAO ();
@@ -12,6 +13,7 @@ class RSSConfiguration extends Model {
$this->_defaultView ($confDAO->default_view);
$this->_displayPosts ($confDAO->display_posts);
$this->_sortOrder ($confDAO->sort_order);
+ $this->_oldEntries ($confDAO->old_entries);
}
public function postsPerPage () {
@@ -26,6 +28,9 @@ class RSSConfiguration extends Model {
public function sortOrder () {
return $this->sort_order;
}
+ public function oldEntries () {
+ return $this->old_entries;
+ }
public function _postsPerPage ($value) {
if (is_int ($value)) {
@@ -55,6 +60,13 @@ class RSSConfiguration extends Model {
$this->sort_order = 'low_to_high';
}
}
+ public function _oldEntries ($value) {
+ if (is_int (intval ($value))) {
+ $this->old_entries = $value;
+ } else {
+ $this->old_entries = 3;
+ }
+ }
}
class RSSConfigurationDAO extends Model_array {
@@ -62,6 +74,7 @@ class RSSConfigurationDAO extends Model_array {
public $default_view = 'all';
public $display_posts = 'no';
public $sort_order = 'low_to_high';
+ public $old_entries = 3;
public function __construct () {
parent::__construct (PUBLIC_PATH . '/data/db/Configuration.array.php');
@@ -78,6 +91,9 @@ class RSSConfigurationDAO extends Model_array {
if (isset ($this->array['sort_order'])) {
$this->sort_order = $this->array['sort_order'];
}
+ if (isset ($this->array['old_entries'])) {
+ $this->old_entries = $this->array['old_entries'];
+ }
}
public function save ($values) {
diff --git a/app/views/configure/display.phtml b/app/views/configure/display.phtml
index a5bb085c4..77c36ccca 100644
--- a/app/views/configure/display.phtml
+++ b/app/views/configure/display.phtml
@@ -4,6 +4,9 @@
<label for="posts_per_page">Nombre d'articles par page</label>
<input type="number" id="posts_per_page" name="posts_per_page" value="<?php echo $this->conf->postsPerPage (); ?>" />
+ <label for="old_entries">Supprimer les articles au bout de (mois)</label>
+ <input type="number" id="old_entries" name="old_entries" value="<?php echo $this->conf->oldEntries (); ?>" />
+
<label>Vue par défaut</label>
<div class="radio_group">
<input type="radio" name="default_view" id="radio_all" value="all"<?php echo $this->conf->defaultView () == 'all' ? ' checked="checked"' : ''; ?> />
diff --git a/public/theme/base.css b/public/theme/base.css
index 0e26a9166..58720a038 100644
--- a/public/theme/base.css
+++ b/public/theme/base.css
@@ -115,23 +115,27 @@ form {
overflow: hidden;
line-height: 50px;
}
- .aside li a, .aside li span {
+ .aside li > a, .aside li > span {
display: block;
width: 230px;
padding: 0 10px;
}
- .aside li a:hover, .aside li span:hover {
+ .aside li > a:hover, .aside li > span:hover {
text-decoration: none;
background: #f0f0f0;
}
- .aside li.disable span {
+ .aside li.disable > span {
background: #fff;
}
- .aside li.active a {
+ .aside li > a span {
+ font-size: 90%;
+ float: right;
+ }
+ .aside li.active > a {
background: #0062BE;
color: #fff;
}
- .aside li h2 {
+ .aside li > h2 {
height: 50px;
padding: 0;
text-align: center;