Context.php 820 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /**
  3. * The context object handles the current configuration file and different
  4. * useful functions associated to the current view state.
  5. */
  6. class FreshRSS_Context {
  7. public static $conf = null;
  8. public static $state = 0;
  9. public static function init() {
  10. // Init configuration.
  11. $current_user = Minz_Session::param('currentUser');
  12. try {
  13. self::$conf = new FreshRSS_Configuration($current_user);
  14. } catch(Minz_Exception $e) {
  15. Minz_Log::error('Cannot load configuration file of user `' . $current_user . '`');
  16. die($e->getMessage());
  17. }
  18. // Init i18n.
  19. Minz_Session::_param('language', self::$conf->language);
  20. Minz_Translate::init();
  21. // Get the current state.
  22. self::$state = self::$conf->default_view;
  23. }
  24. public static function stateEnabled($state) {
  25. return self::$state & $state;
  26. }
  27. }