diff options
| author | 2014-10-20 18:21:10 +0200 | |
|---|---|---|
| committer | 2014-10-20 18:21:10 +0200 | |
| commit | ad92dd7dae35e7205da3172d4ba35ea01da2bc8b (patch) | |
| tree | 395a89f4c4e88bf59d206911b040a3075a296b2c /app/Models/Context.php | |
| parent | df4ddf0e552d9113c9f55d5361212f8279a5c617 (diff) | |
First draft for Context object.
See https://github.com/marienfressinaud/FreshRSS/issues/634
Diffstat (limited to 'app/Models/Context.php')
| -rw-r--r-- | app/Models/Context.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/app/Models/Context.php b/app/Models/Context.php new file mode 100644 index 000000000..d984fece7 --- /dev/null +++ b/app/Models/Context.php @@ -0,0 +1,32 @@ +<?php + +/** + * The context object handles the current configuration file and different + * useful functions associated to the current view state. + */ +class FreshRSS_Context { + public static $conf = null; + public static $state = 0; + + public static function init() { + // Init configuration. + $current_user = Minz_Session::param('currentUser'); + try { + self::$conf = new FreshRSS_Configuration($current_user); + } catch(Minz_Exception $e) { + Minz_Log::error('Cannot load configuration file of user `' . $current_user . '`'); + die($e->getMessage()); + } + + // Init i18n. + Minz_Session::_param('language', self::$conf->language); + Minz_Translate::init(); + + // Get the current state. + self::$state = self::$conf->default_view; + } + + public static function stateEnabled($state) { + return self::$state & $state; + } +} |
