aboutsummaryrefslogtreecommitdiff
path: root/app/Models/Context.php
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-10-21 16:46:36 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-10-21 16:55:19 +0200
commit80cffa6de51771cd80995fb1c4f1e04ee868eb45 (patch)
tree5199c6512140b804e2c456d263d40816ab79a6eb /app/Models/Context.php
parent8a7bab3a55442f85553ab1d897084e89c10f7e05 (diff)
Views are in dedicated actions + improve Context
- Seperate normal, global and rss outputs in dedicated actions (NOT WORKING YET!) - Rewrite aside_flux and nav_menu to use Context object - Improve Context object See https://github.com/marienfressinaud/FreshRSS/issues/634
Diffstat (limited to 'app/Models/Context.php')
-rw-r--r--app/Models/Context.php65
1 files changed, 63 insertions, 2 deletions
diff --git a/app/Models/Context.php b/app/Models/Context.php
index d984fece7..b85179652 100644
--- a/app/Models/Context.php
+++ b/app/Models/Context.php
@@ -6,7 +6,22 @@
*/
class FreshRSS_Context {
public static $conf = null;
+
+ public static $total_unread = 0;
+ public static $total_starred = array(
+ 'all' => 0,
+ 'read' => 0,
+ 'unread' => 0,
+ );
+
public static $state = 0;
+ public static $current_get = array(
+ 'all' => false,
+ 'starred' => false,
+ 'feed' => false,
+ 'category' => false,
+ );
+ public static $order = 'DESC';
public static function init() {
// Init configuration.
@@ -23,10 +38,56 @@ class FreshRSS_Context {
Minz_Translate::init();
// Get the current state.
- self::$state = self::$conf->default_view;
+ // self::$state = self::$conf->default_view;
}
- public static function stateEnabled($state) {
+ public static function isStateEnabled($state) {
return self::$state & $state;
}
+
+ public static function getRevertState($state) {
+ if (self::$state & $state) {
+ return self::$state & ~$state;
+ } else {
+ return self::$state | $state;
+ }
+ }
+
+ public static function currentGet() {
+ 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'];
+ } elseif (self::$current_get['category']) {
+ return 'c_' . self::$current_get['category'];
+ }
+ }
+
+ public static function isCurrentGet($get) {
+ $type = $get[0];
+ $id = substr($get, 2);
+
+ switch($type) {
+ case 'a':
+ return self::$current_get['all'];
+ case 's':
+ return self::$current_get['starred'];
+ case 'f':
+ return self::$current_get['feed'] === $id;
+ case 'c':
+ return self::$current_get['category'] === $id;
+ default:
+ return false;
+ }
+ }
+
+ public static function nextStep() {
+ // TODO: fix this method.
+ return array(
+ 'get' => 'a',
+ 'idMax' => (time() - 1) . '000000'
+ );
+ }
}