diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php
index 1eba7231f..a11c26044 100755
--- a/app/controllers/indexController.php
+++ b/app/controllers/indexController.php
@@ -38,6 +38,9 @@ class indexController extends ActionController {
} elseif ($this->get['type'] == 'favoris') {
$entries = $entryDAO->listFavorites ($this->mode, $search, $order);
View::prependTitle ('Vos favoris - ');
+ } elseif ($this->get['type'] == 'public') {
+ $entries = $entryDAO->listPublic ($this->mode, $search, $order);
+ View::prependTitle ('Public - ');
} elseif ($this->get != false) {
if ($this->get['type'] == 'c') {
$cat = $catDAO->searchById ($this->get['filter']);
@@ -81,6 +84,10 @@ class indexController extends ActionController {
$this->view->cat_aside = $catDAO->listCategories ();
$this->view->nb_favorites = $entryDAO->countFavorites ();
$this->view->nb_total = $entryDAO->count ();
+
+ if (Request::param ('output', '') == 'rss') {
+ $this->view->_useLayout (false);
+ }
}
}
@@ -157,6 +164,13 @@ class indexController extends ActionController {
if ($get == 'favoris') {
$this->view->get_c = $get;
+ $this->get = array (
+ 'type' => $get,
+ 'filter' => $get
+ );
+ } elseif ($get == 'public') {
+ $this->view->get_c = $get;
+
$this->get = array (
'type' => $get,
'filter' => $get
diff --git a/app/controllers/rssController.php b/app/controllers/rssController.php
deleted file mode 100755
index 1f66f4517..000000000
--- a/app/controllers/rssController.php
+++ /dev/null
@@ -1,35 +0,0 @@
-view->_useLayout (false);
- }
-
- public function publicAction () {
- $entryDAO = new EntryDAO ();
- $entryDAO->_nbItemsPerPage (-1);
-
- $items = $entryDAO->listPublic ('low_to_high');
-
- try {
- $page = Request::param('page', 1);
- $nb = Request::param('nb', 15);
- $this->view->itemPaginator = new Paginator($items);
- $this->view->itemPaginator->_nbItemsPerPage($nb);
- $this->view->itemPaginator->_currentPage($page);
- } catch(CurrentPagePaginationException $e) {
- Error::error(
- 404,
- array('error' => array('La page que vous cherchez n\'existe pas'))
- );
- }
- }
-
- public function getNbNotReadAction() {
- }
-}
diff --git a/app/layout/nav_menu.phtml b/app/layout/nav_menu.phtml
index 90fe4aea1..71a5bd11e 100644
--- a/app/layout/nav_menu.phtml
+++ b/app/layout/nav_menu.phtml
@@ -62,4 +62,23 @@
+
+ 'index',
+ 'a' => 'index',
+ 'params' => array (
+ 'output' => 'rss'
+ )
+ );
+ if ($get != '') {
+ $url['params']['get'] = $get;
+ }
+ if ($search != '') {
+ $url['params']['search'] = $search;
+ }
+ ?>
+
diff --git a/app/models/Entry.php b/app/models/Entry.php
index b9b6d30db..230b457bf 100755
--- a/app/models/Entry.php
+++ b/app/models/Entry.php
@@ -422,7 +422,7 @@ class EntryDAO extends Model_pdo {
$values = array();
if ($search) {
$values[] = '%'.$search.'%';
- $where = ' AND title LIKE ?';
+ $where .= ' AND title LIKE ?';
}
if ($order == 'low_to_high') {
@@ -455,8 +455,17 @@ class EntryDAO extends Model_pdo {
return HelperEntry::daoToEntry ($stm->fetchAll (PDO::FETCH_ASSOC));
}
- public function listPublic ($order = 'high_to_low') {
+ public function listPublic ($mode, $search = false, $order = 'high_to_low') {
$where = ' WHERE is_public=1';
+ if ($mode == 'not_read') {
+ $where .= ' AND is_read=0';
+ }
+
+ $values = array();
+ if ($search) {
+ $values[] = '%'.$search.'%';
+ $where .= ' AND title LIKE ?';
+ }
if ($order == 'low_to_high') {
$order = ' DESC';
@@ -464,10 +473,26 @@ class EntryDAO extends Model_pdo {
$order = '';
}
- $sql = 'SELECT * FROM entry' . $where . ' ORDER BY date' . $order;
-
+ $sql = 'SELECT COUNT(*) AS count FROM entry' . $where;
$stm = $this->bd->prepare ($sql);
- $stm->execute ();
+ $stm->execute ($values);
+ $res = $stm->fetchAll (PDO::FETCH_ASSOC);
+ $this->nbItems = $res[0]['count'];
+
+ if($this->nbItemsPerPage < 0) {
+ $sql = 'SELECT * FROM entry' . $where
+ . ' ORDER BY date' . $order;
+ } else {
+ $deb = ($this->currentPage () - 1) * $this->nbItemsPerPage;
+ $fin = $this->nbItemsPerPage;
+
+ $sql = 'SELECT * FROM entry' . $where
+ . ' ORDER BY date' . $order
+ . ' LIMIT ' . $deb . ', ' . $fin;
+ }
+ $stm = $this->bd->prepare ($sql);
+
+ $stm->execute ($values);
return HelperEntry::daoToEntry ($stm->fetchAll (PDO::FETCH_ASSOC));
}
@@ -481,7 +506,7 @@ class EntryDAO extends Model_pdo {
$values = array ($cat);
if ($search) {
$values[] = '%'.$search.'%';
- $where = ' AND title LIKE ?';
+ $where .= ' AND title LIKE ?';
}
if ($order == 'low_to_high') {
@@ -515,10 +540,10 @@ class EntryDAO extends Model_pdo {
$where .= ' AND is_read=0';
}
- $values = array();
+ $values = array($feed);
if ($search) {
$values[] = '%'.$search.'%';
- $where = ' AND title LIKE ?';
+ $where .= ' AND title LIKE ?';
}
if ($order == 'low_to_high') {
@@ -529,7 +554,6 @@ class EntryDAO extends Model_pdo {
$sql = 'SELECT COUNT(*) AS count FROM entry' . $where;
$stm = $this->bd->prepare ($sql);
- $values = array ($feed);
$stm->execute ($values);
$res = $stm->fetchAll (PDO::FETCH_ASSOC);
$this->nbItems = $res[0]['count'];
@@ -542,8 +566,6 @@ class EntryDAO extends Model_pdo {
$stm = $this->bd->prepare ($sql);
- $values = array ($feed);
-
$stm->execute ($values);
return HelperEntry::daoToEntry ($stm->fetchAll (PDO::FETCH_ASSOC));
diff --git a/app/views/rss/public.phtml b/app/views/helpers/rss.phtml
similarity index 75%
rename from app/views/rss/public.phtml
rename to app/views/helpers/rss.phtml
index 04a035699..b75e6d3bc 100755
--- a/app/views/rss/public.phtml
+++ b/app/views/helpers/rss.phtml
@@ -3,13 +3,12 @@
- Flux public de
- fr
+ Flux RSS de
GMT
-
+
itemPaginator->items ();
+$items = $this->entryPaginator->items ();
foreach ($items as $item) {
?>
-
@@ -20,7 +19,7 @@ foreach ($items as $item) {
notes (false, false));
+ echo $item->content ();
?>]]>
date (true)); ?>
guid (); ?>
diff --git a/app/views/index/index.phtml b/app/views/index/index.phtml
index f9e953858..cd0ff0504 100644
--- a/app/views/index/index.phtml
+++ b/app/views/index/index.phtml
@@ -1,3 +1,10 @@
+renderHelper ('rss');
+ return;
+}
+?>
+
partial ('aside_flux'); ?>
partial ('nav_menu'); ?>
@@ -67,7 +74,7 @@ if (isset ($this->entryPaginator)) {