diff --git a/app/Controllers/indexController.php b/app/Controllers/indexController.php
index d711997be..f9af2d0bb 100755
--- a/app/Controllers/indexController.php
+++ b/app/Controllers/indexController.php
@@ -5,10 +5,10 @@
*/
class FreshRSS_index_Controller extends Minz_ActionController {
+ /**
+ * This action only redirect on the default view mode (normal or global)
+ */
public function indexAction() {
- // TODO: update the context with information from request.
- // TODO: then, in dedicated action, get corresponding entries
-
$prefered_output = FreshRSS_Context::$conf->view_mode;
Minz_Request::forward(array(
'c' => 'index',
@@ -27,12 +27,12 @@ class FreshRSS_index_Controller extends Minz_ActionController {
try {
$this->updateContext();
- } catch (Minz_Exception $e) {
+ } catch (FreshRSS_Context_Exception $e) {
Minz_Error::error(404);
}
try {
- $entries = $this->listByContext();
+ $entries = $this->listEntriesByContext();
if (count($entries) > FreshRSS_Context::$number) {
// We have more elements for pagination
@@ -48,6 +48,7 @@ class FreshRSS_index_Controller extends Minz_ActionController {
$this->view->categories = FreshRSS_Context::$categories;
+ $this->view->rss_title = FreshRSS_Context::$name . ' | ' . Minz_View::title();
$title = FreshRSS_Context::$name;
if (FreshRSS_Context::$get_unread > 0) {
$title = '(' . FreshRSS_Context::$get_unread . ') · ' . $title;
@@ -68,12 +69,13 @@ class FreshRSS_index_Controller extends Minz_ActionController {
try {
$this->updateContext();
- } catch (Minz_Exception $e) {
+ } catch (FreshRSS_Context_Exception $e) {
Minz_Error::error(404);
}
$this->view->categories = FreshRSS_Context::$categories;
+ $this->view->rss_title = FreshRSS_Context::$name . ' | ' . Minz_View::title();
Minz_View::prependTitle(_t('gen.title.global_view') . ' · ');
}
@@ -94,12 +96,12 @@ class FreshRSS_index_Controller extends Minz_ActionController {
try {
$this->updateContext();
- } catch (Minz_Exception $e) {
+ } catch (FreshRSS_Context_Exception $e) {
Minz_Error::error(404);
}
try {
- $this->view->entries = $this->listByContext();
+ $this->view->entries = $this->listEntriesByContext();
} catch (FreshRSS_EntriesGetter_Exception $e) {
Minz_Log::notice($e->getMessage());
Minz_Error::error(404);
@@ -113,15 +115,25 @@ class FreshRSS_index_Controller extends Minz_ActionController {
/**
* This action updates the Context object by using request parameters.
+ *
+ * Parameters are:
+ * - state (default: conf->default_view)
+ * - search (default: empty string)
+ * - order (default: conf->sort_order)
+ * - nb (default: conf->posts_per_page)
+ * - next (default: empty string)
*/
private function updateContext() {
FreshRSS_Context::_get(Minz_Request::param('get', 'a'));
- FreshRSS_Context::$state |= Minz_Request::param(
+ // TODO: change default_view by default_state.
+ FreshRSS_Context::$state = Minz_Request::param(
'state', FreshRSS_Context::$conf->default_view
);
- if (FreshRSS_Context::$state & FreshRSS_Entry::STATE_NOT_READ &&
- FreshRSS_Context::$get_unread <= 0) {
+ $state_forced_by_user = Minz_Request::param('state', false) !== false;
+ if (FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_NOT_READ) &&
+ FreshRSS_Context::$get_unread <= 0 &&
+ !$state_forced_by_user) {
FreshRSS_Context::$state |= FreshRSS_Entry::STATE_READ;
}
@@ -135,7 +147,10 @@ class FreshRSS_index_Controller extends Minz_ActionController {
FreshRSS_Context::$first_id = Minz_Request::param('next', '');
}
- private function listByContext() {
+ /**
+ * This method returns a list of entries based on the Context object.
+ */
+ private function listEntriesByContext() {
$entryDAO = FreshRSS_Factory::createEntryDao();
$get = FreshRSS_Context::currentGet(true);
diff --git a/app/Exceptions/ContextException.php b/app/Exceptions/ContextException.php
new file mode 100644
index 000000000..357751b7c
--- /dev/null
+++ b/app/Exceptions/ContextException.php
@@ -0,0 +1,10 @@
+ 0,
);
- public static $state = 0;
+ public static $get_unread = 0;
public static $current_get = array(
'all' => false,
'starred' => false,
'feed' => false,
'category' => false,
);
- public static $get_unread = 0;
+
+ public static $state = 0;
public static $order = 'DESC';
public static $number = 0;
public static $search = '';
@@ -48,8 +49,6 @@ class FreshRSS_Context {
$catDAO = new FreshRSS_CategoryDAO();
$entryDAO = FreshRSS_Factory::createEntryDao();
- // Get the current state.
- // self::$state = self::$conf->default_view;
self::$categories = $catDAO->listCategories();
// Update number of read / unread variables.
@@ -97,8 +96,7 @@ class FreshRSS_Context {
$feed = $feedDAO->searchById($id);
if (!$feed) {
- // TODO: raise an exception
- return false;
+ throw new FreshRSS_Context_Exception('Invalid feed: ' . $id);
}
}
@@ -112,8 +110,7 @@ class FreshRSS_Context {
$cat = $catDAO->searchById($id);
if (!$cat) {
- // TODO: raise an exception
- return false;
+ throw new FreshRSS_Context_Exception('Invalid category: ' . $id);
}
} else {
$cat = self::$categories[$id];
@@ -123,8 +120,7 @@ class FreshRSS_Context {
self::$get_unread = $cat->nbNotRead();
break;
default:
- // TODO: raise an exception!
- return false;
+ throw new FreshRSS_Context_Exception('Invalid getter: ' . $get);
}
}
diff --git a/app/layout/layout.phtml b/app/layout/layout.phtml
index 2b38df4a1..1827d6c26 100644
--- a/app/layout/layout.phtml
+++ b/app/layout/layout.phtml
@@ -10,21 +10,22 @@
renderHelper('javascript_vars'); ?>
//]]>
-
+
url)) {
- $rss_url = $this->url;
- $rss_url['params']['output'] = 'rss';
+ if (isset($this->rss_title)) {
+ $url_rss = $url_base;
+ $url_rss['a'] = 'rss';
?>
-
+