|
@@ -3,25 +3,38 @@
|
|
|
class indexController extends ActionController {
|
|
class indexController extends ActionController {
|
|
|
public function indexAction () {
|
|
public function indexAction () {
|
|
|
$entryDAO = new EntryDAO ();
|
|
$entryDAO = new EntryDAO ();
|
|
|
|
|
+ $catDAO = new CategoryDAO ();
|
|
|
|
|
|
|
|
$mode = Session::param ('mode', $this->view->conf->defaultView ());
|
|
$mode = Session::param ('mode', $this->view->conf->defaultView ());
|
|
|
- if ($mode == 'not_read') {
|
|
|
|
|
- $entries = $entryDAO->listNotReadEntries ();
|
|
|
|
|
- } elseif ($mode == 'all') {
|
|
|
|
|
- $entries = $entryDAO->listEntries ();
|
|
|
|
|
|
|
+ $get = Request::param ('get');
|
|
|
|
|
+
|
|
|
|
|
+ // Récupère les flux par catégorie, favoris ou tous
|
|
|
|
|
+ if ($get == 'favoris') {
|
|
|
|
|
+ $entries = $entryDAO->listFavorites ($mode);
|
|
|
|
|
+ } elseif ($get != false) {
|
|
|
|
|
+ $entries = $entryDAO->listByCategory ($get, $mode);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // Cas où on ne choisie ni catégorie ni les favoris
|
|
|
|
|
+ // ou si la catégorie ne correspond à aucune
|
|
|
|
|
+ if (!isset ($entries)) {
|
|
|
|
|
+ $entries = $entryDAO->listEntries ($mode);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Tri par date
|
|
|
if ($this->view->conf->sortOrder () == 'high_to_low') {
|
|
if ($this->view->conf->sortOrder () == 'high_to_low') {
|
|
|
usort ($entries, 'sortReverseEntriesByDate');
|
|
usort ($entries, 'sortReverseEntriesByDate');
|
|
|
} else {
|
|
} else {
|
|
|
usort ($entries, 'sortEntriesByDate');
|
|
usort ($entries, 'sortEntriesByDate');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //gestion pagination
|
|
|
|
|
|
|
+ // Gestion pagination
|
|
|
$page = Request::param ('page', 1);
|
|
$page = Request::param ('page', 1);
|
|
|
$this->view->entryPaginator = new Paginator ($entries);
|
|
$this->view->entryPaginator = new Paginator ($entries);
|
|
|
$this->view->entryPaginator->_nbItemsPerPage ($this->view->conf->postsPerPage ());
|
|
$this->view->entryPaginator->_nbItemsPerPage ($this->view->conf->postsPerPage ());
|
|
|
$this->view->entryPaginator->_currentPage ($page);
|
|
$this->view->entryPaginator->_currentPage ($page);
|
|
|
|
|
+
|
|
|
|
|
+ $this->view->cat_aside = $catDAO->listCategories ();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function changeModeAction () {
|
|
public function changeModeAction () {
|