aboutsummaryrefslogtreecommitdiff
path: root/app/FreshRSS.php
diff options
context:
space:
mode:
authorGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-10-20 18:21:10 +0200
committerGravatar Marien Fressinaud <dev@marienfressinaud.fr> 2014-10-20 18:21:10 +0200
commitad92dd7dae35e7205da3172d4ba35ea01da2bc8b (patch)
tree395a89f4c4e88bf59d206911b040a3075a296b2c /app/FreshRSS.php
parentdf4ddf0e552d9113c9f55d5361212f8279a5c617 (diff)
First draft for Context object.
See https://github.com/marienfressinaud/FreshRSS/issues/634
Diffstat (limited to 'app/FreshRSS.php')
-rw-r--r--app/FreshRSS.php40
1 files changed, 20 insertions, 20 deletions
diff --git a/app/FreshRSS.php b/app/FreshRSS.php
index 6b7a813bf..e1399ad78 100644
--- a/app/FreshRSS.php
+++ b/app/FreshRSS.php
@@ -1,50 +1,50 @@
<?php
+
class FreshRSS extends Minz_FrontController {
public function init() {
if (!isset($_SESSION)) {
Minz_Session::init('FreshRSS');
}
+ // Need to be called just after session init because it initializes
+ // current user.
FreshRSS_Auth::init();
- $this->loadConfiguration();
- $this->loadParamsView();
+
if (Minz_Request::isPost() && !is_referer_from_same_domain()) {
- //Basic protection against XSRF attacks
+ // Basic protection against XSRF attacks
FreshRSS_Auth::removeAccess();
+ $http_referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
Minz_Error::error(
403,
- array('error' => array(_t('access_denied') . ' [HTTP_REFERER=' .
- htmlspecialchars(empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER']) . ']'))
+ array('error' => array(
+ _t('access_denied'),
+ ' [HTTP_REFERER=' . htmlspecialchars($http_referer) . ']'
+ ))
);
}
+
+ // Load context and configuration.
+ // TODO: remove $this->view->conf variable which is contained in context
+ FreshRSS_Context::init();
+ Minz_View::_param('conf', FreshRSS_Context::$conf);
+
+ $this->loadParamsView();
$this->loadStylesAndScripts();
$this->loadNotifications();
$this->loadExtensions();
}
- private function loadConfiguration() {
- $current_user = Minz_Session::param('currentUser');
- try {
- $this->conf = new FreshRSS_Configuration($current_user);
- Minz_View::_param('conf', $this->conf);
- } catch(Minz_Exception $e) {
- Minz_Log::error('Cannot load configuration file of user `' . $current_user . '`');
- die($e->getMessage());
- }
- }
-
private function loadParamsView() {
- Minz_Session::_param('language', $this->conf->language);
- Minz_Translate::init();
+ // TODO: outputs should be different actions.
$output = Minz_Request::param('output', '');
if (($output === '') || ($output !== 'normal' && $output !== 'rss' && $output !== 'reader' && $output !== 'global')) {
- $output = $this->conf->view_mode;
+ $output = FreshRSS_Context::$conf->view_mode;
Minz_Request::_param('output', $output);
}
}
private function loadStylesAndScripts() {
- $theme = FreshRSS_Themes::load($this->conf->theme);
+ $theme = FreshRSS_Themes::load(FreshRSS_Context::$conf->theme);
if ($theme) {
foreach($theme['files'] as $file) {
if ($file[0] === '_') {