From f1f9b2f5ff60f6dca05fad831b766ea7d63ff3a3 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 22 Oct 2014 13:52:20 +0200 Subject: Entries are loaded again! It's working :) See https://github.com/marienfressinaud/FreshRSS/issues/634 --- app/Controllers/indexController.php | 58 ++++++++++++++++++++++++++----------- app/Models/Context.php | 17 ++++++++--- app/layout/layout.phtml | 4 +-- app/views/index/normal.phtml | 8 ++--- 4 files changed, 60 insertions(+), 27 deletions(-) diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php index be85aa68d..d711997be 100755 --- a/app/Controllers/indexController.php +++ b/app/Controllers/indexController.php @@ -14,23 +14,6 @@ class FreshRSS_index_Controller extends Minz_ActionController { 'c' => 'index', 'a' => $prefered_output )); - - return; - - try { - $entries = $entryDAO->listWhere($getType, $getId, $this->view->state, $order, $nb + 1, $first, $filter); - - if (count($entries) > $nb) { - // We have more elements for pagination - $last_entry = array_pop($entries); - FreshRSS_Context::$next_id = $last_entry->id(); - } - - $this->view->entries = $entries; - } catch (FreshRSS_EntriesGetter_Exception $e) { - Minz_Log::notice($e->getMessage()); - Minz_Error::error(404); - } } /** @@ -48,6 +31,21 @@ class FreshRSS_index_Controller extends Minz_ActionController { Minz_Error::error(404); } + try { + $entries = $this->listByContext(); + + if (count($entries) > FreshRSS_Context::$number) { + // We have more elements for pagination + $last_entry = array_pop($entries); + FreshRSS_Context::$next_id = $last_entry->id(); + } + + $this->view->entries = $entries; + } catch (FreshRSS_EntriesGetter_Exception $e) { + Minz_Log::notice($e->getMessage()); + Minz_Error::error(404); + } + $this->view->categories = FreshRSS_Context::$categories; $title = FreshRSS_Context::$name; @@ -100,6 +98,13 @@ class FreshRSS_index_Controller extends Minz_ActionController { Minz_Error::error(404); } + try { + $this->view->entries = $this->listByContext(); + } catch (FreshRSS_EntriesGetter_Exception $e) { + Minz_Log::notice($e->getMessage()); + Minz_Error::error(404); + } + // No layout for RSS output. $this->view->rss_title = FreshRSS_Context::$name . ' | ' . Minz_View::title(); $this->view->_useLayout(false); @@ -130,6 +135,25 @@ class FreshRSS_index_Controller extends Minz_ActionController { FreshRSS_Context::$first_id = Minz_Request::param('next', ''); } + private function listByContext() { + $entryDAO = FreshRSS_Factory::createEntryDao(); + + $get = FreshRSS_Context::currentGet(true); + if (count($get) > 1) { + $type = $get[0]; + $id = $get[1]; + } else { + $type = $get; + $id = ''; + } + + return $entryDAO->listWhere( + $type, $id, FreshRSS_Context::$state, FreshRSS_Context::$order, + FreshRSS_Context::$number + 1, FreshRSS_Context::$first_id, + FreshRSS_Context::$search + ); + } + /** * This action displays the about page of FreshRSS. */ diff --git a/app/Models/Context.php b/app/Models/Context.php index 31ac60207..54fb1e64a 100644 --- a/app/Models/Context.php +++ b/app/Models/Context.php @@ -28,7 +28,8 @@ class FreshRSS_Context { public static $order = 'DESC'; public static $number = 0; public static $search = ''; - public static $first_id = 0; + public static $first_id = ''; + public static $next_id = ''; public static function init() { // Init configuration. @@ -127,15 +128,23 @@ class FreshRSS_Context { } } - public static function currentGet() { + public static function currentGet($array = false) { if (self::$current_get['all']) { return 'a'; } elseif (self::$current_get['starred']) { return 's'; } elseif (self::$current_get['feed']) { - return 'f_' . self::$current_get['feed']; + if ($array) { + return array('f', self::$current_get['feed']); + } else { + return 'f_' . self::$current_get['feed']; + } } elseif (self::$current_get['category']) { - return 'c_' . self::$current_get['category']; + if ($array) { + return array('c', self::$current_get['category']); + } else { + return 'c_' . self::$current_get['category']; + } } } diff --git a/app/layout/layout.phtml b/app/layout/layout.phtml index a8c70ec64..2b38df4a1 100644 --- a/app/layout/layout.phtml +++ b/app/layout/layout.phtml @@ -10,9 +10,9 @@ renderHelper('javascript_vars'); ?> //]]> nextId)) { + if (FreshRSS_Context::$next_id !== '') { $params = Minz_Request::params(); - $params['next'] = $this->nextId; + $params['next'] = FreshRSS_Context::$next_id; $params['ajax'] = 1; ?> diff --git a/app/views/index/normal.phtml b/app/views/index/normal.phtml index c39dba0a9..36adef2f2 100644 --- a/app/views/index/normal.phtml +++ b/app/views/index/normal.phtml @@ -32,14 +32,14 @@ if (!empty($this->entries)) {
- +
entries as $item) { if ($display_today && $item->isDay(FreshRSS_Days::TODAY, $today)) { ?>
currentName; ?>
entries)) { ?>
currentName; ?>
isDay(FreshRSS_Days::BEFORE_YESTERDAY, $today)) { ?>
currentName; ?>