diff options
| author | 2013-03-12 23:24:52 +0100 | |
|---|---|---|
| committer | 2013-03-12 23:24:52 +0100 | |
| commit | c62ec2a14428b528e20896d4e62fa08891e1399c (patch) | |
| tree | cdf6cbbd2d1b9182d385db36ec0c86b08bcf442e /app/controllers/indexController.php | |
| parent | 8c562972062fbf3d750bd62893de248022850c23 (diff) | |
Grosse mise à jour du design, pas mal de trucs cassés au niveau du panneau de configuration
Diffstat (limited to 'app/controllers/indexController.php')
| -rwxr-xr-x | app/controllers/indexController.php | 77 |
1 files changed, 49 insertions, 28 deletions
diff --git a/app/controllers/indexController.php b/app/controllers/indexController.php index bd5f31b08..916f77c98 100755 --- a/app/controllers/indexController.php +++ b/app/controllers/indexController.php @@ -5,15 +5,16 @@ class indexController extends ActionController { View::appendScript (Url::display ('/scripts/smoothscroll.js')); View::appendScript (Url::display ('/scripts/shortcut.js')); View::appendScript (Url::display (array ('c' => 'javascript', 'a' => 'main'))); - + $entryDAO = new EntryDAO (); + $feedDAO = new FeedDAO (); $catDAO = new CategoryDAO (); - + // pour optimiser $page = Request::param ('page', 1); $entryDAO->_nbItemsPerPage ($this->view->conf->postsPerPage ()); $entryDAO->_currentPage ($page); - + $default_view = $this->view->conf->defaultView (); $mode = Session::param ('mode'); if ($mode == false) { @@ -23,67 +24,87 @@ class indexController extends ActionController { $mode = $default_view; } } - + $get = Request::param ('get'); $order = $this->view->conf->sortOrder (); - + + $error = false; + // Récupère les flux par catégorie, favoris ou tous if ($get == 'favoris') { $entries = $entryDAO->listFavorites ($mode, $order); View::prependTitle ('Vos favoris - '); } elseif ($get != false) { - $entries = $entryDAO->listByCategory ($get, $mode, $order); - $cat = $catDAO->searchById ($get); - - if ($cat) { - View::prependTitle ($cat->name () . ' - '); + $typeGet = $get[0]; + $get = substr ($get, 2); + + if ($typeGet == 'c') { + $entries = $entryDAO->listByCategory ($get, $mode, $order); + $cat = $catDAO->searchById ($get); + + if ($cat) { + View::prependTitle ($cat->name () . ' - '); + } else { + $error = true; + } + } elseif ($typeGet == 'f') { + $entries = $entryDAO->listByFeed ($get, $mode, $order); + $feed = $feedDAO->searchById ($get); + + if ($feed) { + View::prependTitle ($feed->name () . ' - '); + } else { + $error = true; + } } else { - Error::error ( - 404, - array ('error' => array ('La page que vous cherchez n\'existe pas')) - ); + $error = true; } } else { View::prependTitle ('Vos flux RSS - '); } + $this->view->get = $get; $this->view->mode = $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, $order); } - + try { $this->view->entryPaginator = $entryDAO->getPaginator ($entries); } catch (CurrentPagePaginationException $e) { + $error = true; + } + + $this->view->cat_aside = $catDAO->listCategories (); + $this->view->nb_favorites = $entryDAO->countFavorites (); + $this->view->nb_total = $entryDAO->count (); + + if ($error) { Error::error ( 404, array ('error' => array ('La page que vous cherchez n\'existe pas')) ); } - - $this->view->cat_aside = $catDAO->listCategories (); - $this->view->nb_favorites = $entryDAO->countFavorites (); - $this->view->nb_total = $entryDAO->count (); } - + public function changeModeAction () { $mode = Request::param ('mode'); - + if ($mode == 'not_read') { Session::_param ('mode', 'not_read'); } else { Session::_param ('mode', 'all'); } - + Request::forward (array (), true); } - + public function loginAction () { $this->view->_useLayout (false); - + $url = 'https://verifier.login.persona.org/verify'; $assert = Request::param ('assertion'); $params = 'assertion=' . $assert . '&audience=' . @@ -98,7 +119,7 @@ class indexController extends ActionController { curl_setopt_array ($ch, $options); $result = curl_exec ($ch); curl_close ($ch); - + $res = json_decode ($result, true); if ($res['status'] == 'okay' && $res['email'] == $this->view->conf->mailLogin ()) { Session::_param ('mail', $res['email']); @@ -107,10 +128,10 @@ class indexController extends ActionController { $res['status'] = 'failure'; $res['reason'] = 'L\'identifiant est invalide'; } - + $this->view->res = json_encode ($res); } - + public function logoutAction () { $this->view->_useLayout (false); Session::_param ('mail'); |
