diff options
| author | 2014-10-22 13:52:20 +0200 | |
|---|---|---|
| committer | 2014-10-22 13:52:20 +0200 | |
| commit | f1f9b2f5ff60f6dca05fad831b766ea7d63ff3a3 (patch) | |
| tree | 9f764ec6b7be91554e1ae20323a55c1f1d2be992 /app | |
| parent | b446a510ebacddd1437d907e795c83b3d05a9b98 (diff) | |
Entries are loaded again! It's working :)
See https://github.com/marienfressinaud/FreshRSS/issues/634
Diffstat (limited to 'app')
| -rwxr-xr-x | app/Controllers/indexController.php | 58 | ||||
| -rw-r--r-- | app/Models/Context.php | 17 | ||||
| -rw-r--r-- | app/layout/layout.phtml | 4 | ||||
| -rw-r--r-- | 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 @@ <?php $this->renderHelper('javascript_vars'); ?> //]]></script> <?php - if (!empty($this->nextId)) { + if (FreshRSS_Context::$next_id !== '') { $params = Minz_Request::params(); - $params['next'] = $this->nextId; + $params['next'] = FreshRSS_Context::$next_id; $params['ajax'] = 1; ?> <link id="prefetch" rel="next prefetch" href="<?php echo Minz_Url::display(array('c' => Minz_Request::controllerName(), 'a' => Minz_Request::actionName(), 'params' => $params)); ?>" /> 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)) { <div id="stream" class="normal<?php echo $hidePosts ? ' hide_posts' : ''; ?>"><?php ?><div id="new-article"> - <a href="<?php echo Minz_Url::display($this->url); ?>"><?php echo _t('new_article'); ?></a> + <a href="<?php echo Minz_Url::display(Minz_Request::currentRequest()); ?>"><?php echo _t('new_article'); ?></a> </div><?php foreach ($this->entries as $item) { if ($display_today && $item->isDay(FreshRSS_Days::TODAY, $today)) { ?><div class="day" id="day_today"><?php echo _t('today'); ?><span class="date"> — <?php echo timestamptodate(time(), false); ?></span><?php - ?><span class="name"><?php echo $this->currentName; ?></span><?php + ?><span class="name"><?php echo FreshRSS_Context::$name; ?></span><?php ?></div><?php $display_today = false; } @@ -47,14 +47,14 @@ if (!empty($this->entries)) { ?><div class="day" id="day_yesterday"><?php echo _t('yesterday'); ?><span class="date"> — <?php echo timestamptodate(time() - 86400, false); ?></span><?php - ?><span class="name"><?php echo $this->currentName; ?></span><?php + ?><span class="name"><?php echo FreshRSS_Context::$name; ?></span><?php ?></div><?php $display_yesterday = false; } if ($display_others && $item->isDay(FreshRSS_Days::BEFORE_YESTERDAY, $today)) { ?><div class="day" id="day_before_yesterday"><?php echo _t('before_yesterday'); - ?><span class="name"><?php echo $this->currentName; ?></span><?php + ?><span class="name"><?php echo FreshRSS_Context::$name; ?></span><?php ?></div><?php $display_others = false; } |
