|
|
@@ -1,258 +1,171 @@
|
|
|
<?php
|
|
|
|
|
|
-class FreshRSS_Configuration extends Minz_Model {
|
|
|
- private $available_languages = array (
|
|
|
+class FreshRSS_Configuration extends Minz_ModelArray {
|
|
|
+ private $data = array(
|
|
|
+ 'language' => 'en',
|
|
|
+ 'old_entries' => 3,
|
|
|
+ 'keep_history_default' => 0,
|
|
|
+ 'mail_login' => '',
|
|
|
+ 'token' => '',
|
|
|
+ 'posts_per_page' => 20,
|
|
|
+ 'view_mode' => 'normal',
|
|
|
+ 'default_view' => 'not_read',
|
|
|
+ 'auto_load_more' => true,
|
|
|
+ 'display_posts' => false,
|
|
|
+ 'onread_jump_next' => true,
|
|
|
+ 'lazyload' => true,
|
|
|
+ 'sort_order' => 'DESC',
|
|
|
+ 'anon_access' => false,
|
|
|
+ 'mark_when' => array(
|
|
|
+ 'article' => true,
|
|
|
+ 'site' => true,
|
|
|
+ 'scroll' => false,
|
|
|
+ 'reception' => false,
|
|
|
+ ),
|
|
|
+ 'theme' => 'default',
|
|
|
+ 'shortcuts' => array(
|
|
|
+ 'mark_read' => 'r',
|
|
|
+ 'mark_favorite' => 'f',
|
|
|
+ 'go_website' => 'space',
|
|
|
+ 'next_entry' => 'j',
|
|
|
+ 'prev_entry' => 'k',
|
|
|
+ 'collapse_entry' => 'c',
|
|
|
+ 'load_more' => 'm',
|
|
|
+ ),
|
|
|
+ 'topline_read' => true,
|
|
|
+ 'topline_favorite' => true,
|
|
|
+ 'topline_date' => true,
|
|
|
+ 'topline_link' => true,
|
|
|
+ 'bottomline_read' => true,
|
|
|
+ 'bottomline_favorite' => true,
|
|
|
+ 'bottomline_sharing' => true,
|
|
|
+ 'bottomline_tags' => true,
|
|
|
+ 'bottomline_date' => true,
|
|
|
+ 'bottomline_link' => true,
|
|
|
+ 'sharing' => array(
|
|
|
+ 'shaarli' => '',
|
|
|
+ 'poche' => '',
|
|
|
+ 'diaspora' => '',
|
|
|
+ 'twitter' => true,
|
|
|
+ 'g+' => true,
|
|
|
+ 'facebook' => true,
|
|
|
+ 'email' => true,
|
|
|
+ 'print' => true,
|
|
|
+ ),
|
|
|
+ );
|
|
|
+
|
|
|
+ private $available_languages = array(
|
|
|
'en' => 'English',
|
|
|
'fr' => 'Français',
|
|
|
);
|
|
|
- private $language;
|
|
|
- private $posts_per_page;
|
|
|
- private $view_mode;
|
|
|
- private $default_view;
|
|
|
- private $display_posts;
|
|
|
- private $onread_jump_next;
|
|
|
- private $lazyload;
|
|
|
- private $sort_order;
|
|
|
- private $old_entries;
|
|
|
- private $keep_history_default;
|
|
|
- private $shortcuts = array ();
|
|
|
- private $mail_login = '';
|
|
|
- private $mark_when = array ();
|
|
|
- private $sharing = array ();
|
|
|
- private $theme;
|
|
|
- private $token;
|
|
|
- private $auto_load_more;
|
|
|
- private $topline_read;
|
|
|
- private $topline_favorite;
|
|
|
- private $topline_date;
|
|
|
- private $topline_link;
|
|
|
- private $bottomline_read;
|
|
|
- private $bottomline_favorite;
|
|
|
- private $bottomline_sharing;
|
|
|
- private $bottomline_tags;
|
|
|
- private $bottomline_date;
|
|
|
- private $bottomline_link;
|
|
|
|
|
|
- public function __construct () {
|
|
|
- $confDAO = new FreshRSS_ConfigurationDAO ();
|
|
|
- $this->_language ($confDAO->language);
|
|
|
- $this->_postsPerPage ($confDAO->posts_per_page);
|
|
|
- $this->_viewMode ($confDAO->view_mode);
|
|
|
- $this->_defaultView ($confDAO->default_view);
|
|
|
- $this->_displayPosts ($confDAO->display_posts);
|
|
|
- $this->_onread_jump_next ($confDAO->onread_jump_next);
|
|
|
- $this->_lazyload ($confDAO->lazyload);
|
|
|
- $this->_sortOrder ($confDAO->sort_order);
|
|
|
- $this->_oldEntries ($confDAO->old_entries);
|
|
|
- $this->_keepHistoryDefault($confDAO->keep_history_default);
|
|
|
- $this->_shortcuts ($confDAO->shortcuts);
|
|
|
- $this->_mailLogin ($confDAO->mail_login);
|
|
|
- $this->_markWhen ($confDAO->mark_when);
|
|
|
- $this->_sharing ($confDAO->sharing);
|
|
|
- $this->_theme ($confDAO->theme);
|
|
|
- FreshRSS_Themes::setThemeId ($confDAO->theme);
|
|
|
- $this->_token ($confDAO->token);
|
|
|
- $this->_autoLoadMore ($confDAO->auto_load_more);
|
|
|
- $this->_topline_read ($confDAO->topline_read);
|
|
|
- $this->_topline_favorite ($confDAO->topline_favorite);
|
|
|
- $this->_topline_date ($confDAO->topline_date);
|
|
|
- $this->_topline_link ($confDAO->topline_link);
|
|
|
- $this->_bottomline_read ($confDAO->bottomline_read);
|
|
|
- $this->_bottomline_favorite ($confDAO->bottomline_favorite);
|
|
|
- $this->_bottomline_sharing ($confDAO->bottomline_sharing);
|
|
|
- $this->_bottomline_tags ($confDAO->bottomline_tags);
|
|
|
- $this->_bottomline_date ($confDAO->bottomline_date);
|
|
|
- $this->_bottomline_link ($confDAO->bottomline_link);
|
|
|
- }
|
|
|
+ public function __construct ($filename = '') {
|
|
|
+ if (empty($filename)) {
|
|
|
+ $filename = DATA_PATH . '/' . Minz_Configuration::currentUser () . '_user.php';
|
|
|
+ }
|
|
|
+ parent::__construct($filename);
|
|
|
+ $data = parent::loadArray();
|
|
|
|
|
|
- public function availableLanguages () {
|
|
|
- return $this->available_languages;
|
|
|
- }
|
|
|
- public function language () {
|
|
|
- return $this->language;
|
|
|
- }
|
|
|
- public function postsPerPage () {
|
|
|
- return $this->posts_per_page;
|
|
|
- }
|
|
|
- public function viewMode () {
|
|
|
- return $this->view_mode;
|
|
|
- }
|
|
|
- public function defaultView () {
|
|
|
- return $this->default_view;
|
|
|
- }
|
|
|
- public function displayPosts () {
|
|
|
- return $this->display_posts;
|
|
|
- }
|
|
|
- public function onread_jump_next () {
|
|
|
- return $this->onread_jump_next;
|
|
|
- }
|
|
|
- public function lazyload () {
|
|
|
- return $this->lazyload;
|
|
|
- }
|
|
|
- public function sortOrder () {
|
|
|
- return $this->sort_order;
|
|
|
- }
|
|
|
- public function oldEntries () {
|
|
|
- return $this->old_entries;
|
|
|
- }
|
|
|
- public function keepHistoryDefault() {
|
|
|
- return $this->keep_history_default;
|
|
|
- }
|
|
|
- public function shortcuts () {
|
|
|
- return $this->shortcuts;
|
|
|
- }
|
|
|
- public function mailLogin () {
|
|
|
- return $this->mail_login;
|
|
|
- }
|
|
|
- public function markWhen () {
|
|
|
- return $this->mark_when;
|
|
|
- }
|
|
|
- public function markWhenArticle () {
|
|
|
- return $this->mark_when['article'];
|
|
|
- }
|
|
|
- public function markWhenSite () {
|
|
|
- return $this->mark_when['site'];
|
|
|
+ foreach ($data as $key => $value) {
|
|
|
+ if (isset($this->data[$key])) {
|
|
|
+ $function = '_' . $key;
|
|
|
+ $this->$function($value);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- public function markWhenScroll () {
|
|
|
- return $this->mark_when['scroll'];
|
|
|
+
|
|
|
+ public function save() {
|
|
|
+ invalidateHttpCache();
|
|
|
+ return parent::writeArray($this->data);
|
|
|
}
|
|
|
- public function markUponReception () {
|
|
|
- return $this->mark_when['reception'];
|
|
|
+
|
|
|
+ public function __get($name) {
|
|
|
+ if (array_key_exists($name, $this->data)) {
|
|
|
+ return $this->data[$name];
|
|
|
+ } else {
|
|
|
+ $trace = debug_backtrace();
|
|
|
+ trigger_error('Undefined FreshRSS_Configuration->' . $name . 'in ' . $trace[0]['file'] . ' line ' . $trace[0]['line'], E_USER_NOTICE); //TODO: Use Minz exceptions
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|
|
|
- public function sharing ($key = false) {
|
|
|
+
|
|
|
+ public function sharing($key = false) {
|
|
|
if ($key === false) {
|
|
|
- return $this->sharing;
|
|
|
- } elseif (isset ($this->sharing[$key])) {
|
|
|
- return $this->sharing[$key];
|
|
|
+ return $this->data['sharing'];
|
|
|
+ }
|
|
|
+ if (isset($this->data['sharing'][$key])) {
|
|
|
+ return $this->data['sharing'][$key];
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
- public function theme () {
|
|
|
- return $this->theme;
|
|
|
- }
|
|
|
- public function token () {
|
|
|
- return $this->token;
|
|
|
- }
|
|
|
- public function autoLoadMore () {
|
|
|
- return $this->auto_load_more;
|
|
|
- }
|
|
|
- public function toplineRead () {
|
|
|
- return $this->topline_read;
|
|
|
- }
|
|
|
- public function toplineFavorite () {
|
|
|
- return $this->topline_favorite;
|
|
|
- }
|
|
|
- public function toplineDate () {
|
|
|
- return $this->topline_date;
|
|
|
- }
|
|
|
- public function toplineLink () {
|
|
|
- return $this->topline_link;
|
|
|
- }
|
|
|
- public function bottomlineRead () {
|
|
|
- return $this->bottomline_read;
|
|
|
- }
|
|
|
- public function bottomlineFavorite () {
|
|
|
- return $this->bottomline_favorite;
|
|
|
- }
|
|
|
- public function bottomlineSharing () {
|
|
|
- return $this->bottomline_sharing;
|
|
|
- }
|
|
|
- public function bottomlineTags () {
|
|
|
- return $this->bottomline_tags;
|
|
|
- }
|
|
|
- public function bottomlineDate () {
|
|
|
- return $this->bottomline_date;
|
|
|
- }
|
|
|
- public function bottomlineLink () {
|
|
|
- return $this->bottomline_link;
|
|
|
+
|
|
|
+ public function availableLanguages() {
|
|
|
+ return $this->available_languages;
|
|
|
}
|
|
|
|
|
|
- public function _language ($value) {
|
|
|
- if (!isset ($this->available_languages[$value])) {
|
|
|
+ public function _language($value) {
|
|
|
+ if (!isset($this->available_languages[$value])) {
|
|
|
$value = 'en';
|
|
|
}
|
|
|
- $this->language = $value;
|
|
|
+ $this->data['language'] = $value;
|
|
|
}
|
|
|
- public function _postsPerPage ($value) {
|
|
|
+ public function _posts_per_page ($value) {
|
|
|
$value = intval($value);
|
|
|
- $this->posts_per_page = $value > 0 ? $value : 10;
|
|
|
+ $this->data['posts_per_page'] = $value > 0 ? $value : 10;
|
|
|
}
|
|
|
- public function _viewMode ($value) {
|
|
|
- if ($value == 'global' || $value == 'reader') {
|
|
|
- $this->view_mode = $value;
|
|
|
+ public function _view_mode ($value) {
|
|
|
+ if ($value === 'global' || $value === 'reader') {
|
|
|
+ $this->data['view_mode'] = $value;
|
|
|
} else {
|
|
|
- $this->view_mode = 'normal';
|
|
|
+ $this->data['view_mode'] = 'normal';
|
|
|
}
|
|
|
}
|
|
|
- public function _defaultView ($value) {
|
|
|
- if ($value == 'not_read') {
|
|
|
- $this->default_view = 'not_read';
|
|
|
- } else {
|
|
|
- $this->default_view = 'all';
|
|
|
- }
|
|
|
+ public function _default_view ($value) {
|
|
|
+ $this->data['default_view'] = $value === 'all' ? 'all' : 'not_read';
|
|
|
}
|
|
|
- public function _displayPosts ($value) {
|
|
|
- if ($value == 'yes') {
|
|
|
- $this->display_posts = 'yes';
|
|
|
- } else {
|
|
|
- $this->display_posts = 'no';
|
|
|
- }
|
|
|
+ public function _display_posts ($value) {
|
|
|
+ $this->data['display_posts'] = ((bool)$value) && $value !== 'no';
|
|
|
}
|
|
|
public function _onread_jump_next ($value) {
|
|
|
- if ($value == 'no') {
|
|
|
- $this->onread_jump_next = 'no';
|
|
|
- } else {
|
|
|
- $this->onread_jump_next = 'yes';
|
|
|
- }
|
|
|
+ $this->data['onread_jump_next'] = ((bool)$value) && $value !== 'no';
|
|
|
}
|
|
|
public function _lazyload ($value) {
|
|
|
- if ($value == 'no') {
|
|
|
- $this->lazyload = 'no';
|
|
|
- } else {
|
|
|
- $this->lazyload = 'yes';
|
|
|
- }
|
|
|
+ $this->data['lazyload'] = ((bool)$value) && $value !== 'no';
|
|
|
}
|
|
|
- public function _sortOrder ($value) {
|
|
|
- $this->sort_order = $value === 'ASC' ? 'ASC' : 'DESC';
|
|
|
+ public function _sort_order ($value) {
|
|
|
+ $this->data['sort_order'] = $value === 'ASC' ? 'ASC' : 'DESC';
|
|
|
}
|
|
|
- public function _oldEntries($value) {
|
|
|
+ public function _old_entries($value) {
|
|
|
$value = intval($value);
|
|
|
- $this->old_entries = $value > 0 ? $value : 3;
|
|
|
+ $this->data['old_entries'] = $value > 0 ? $value : 3;
|
|
|
}
|
|
|
- public function _keepHistoryDefault($value) {
|
|
|
+ public function _keep_history_default($value) {
|
|
|
$value = intval($value);
|
|
|
- $this->keep_history_default = $value >= -1 ? $value : 0;
|
|
|
+ $this->data['keep_history_default'] = $value >= -1 ? $value : 0;
|
|
|
}
|
|
|
public function _shortcuts ($values) {
|
|
|
foreach ($values as $key => $value) {
|
|
|
- $this->shortcuts[$key] = $value;
|
|
|
+ if (isset($this->data['shortcuts'][$key])) {
|
|
|
+ $this->data['shortcuts'][$key] = $value;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- public function _mailLogin ($value) {
|
|
|
- if (filter_var ($value, FILTER_VALIDATE_EMAIL)) {
|
|
|
+ public function _mail_login ($value) {
|
|
|
+ if (filter_var($value, FILTER_VALIDATE_EMAIL)) {
|
|
|
$this->mail_login = $value;
|
|
|
- } elseif ($value == false) {
|
|
|
- $this->mail_login = false;
|
|
|
+ } else {
|
|
|
+ $this->mail_login = '';
|
|
|
}
|
|
|
}
|
|
|
- public function _markWhen ($values) {
|
|
|
- if(!isset($values['article'])) {
|
|
|
- $values['article'] = 'yes';
|
|
|
- }
|
|
|
- if(!isset($values['site'])) {
|
|
|
- $values['site'] = 'yes';
|
|
|
- }
|
|
|
- if(!isset($values['scroll'])) {
|
|
|
- $values['scroll'] = 'yes';
|
|
|
- }
|
|
|
- if(!isset($values['reception'])) {
|
|
|
- $values['reception'] = 'no';
|
|
|
+ public function _anon_access ($value) {
|
|
|
+ $this->data['anon_access'] = ((bool)$value) && $value !== 'no';
|
|
|
+ }
|
|
|
+ public function _mark_when ($values) {
|
|
|
+ foreach ($values as $key => $value) {
|
|
|
+ if (isset($this->data['mark_when'][$key])) {
|
|
|
+ $this->data['mark_when'][$key] = ((bool)$value) && $value !== 'no';
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
- $this->mark_when['article'] = $values['article'];
|
|
|
- $this->mark_when['site'] = $values['site'];
|
|
|
- $this->mark_when['scroll'] = $values['scroll'];
|
|
|
- $this->mark_when['reception'] = $values['reception'];
|
|
|
}
|
|
|
public function _sharing ($values) {
|
|
|
$are_url = array ('shaarli', 'poche', 'diaspora');
|
|
|
@@ -268,54 +181,50 @@ class FreshRSS_Configuration extends Minz_Model {
|
|
|
if (!$is_url) {
|
|
|
$value = '';
|
|
|
}
|
|
|
- } elseif(!is_bool ($value)) {
|
|
|
+ } elseif (!is_bool($value)) {
|
|
|
$value = true;
|
|
|
}
|
|
|
|
|
|
- $this->sharing[$key] = $value;
|
|
|
+ $this->data['sharing'][$key] = $value;
|
|
|
}
|
|
|
}
|
|
|
- public function _theme ($value) {
|
|
|
- $this->theme = $value;
|
|
|
+ public function _theme($value) {
|
|
|
+ $this->data['theme'] = $value;
|
|
|
}
|
|
|
- public function _token ($value) {
|
|
|
- $this->token = $value;
|
|
|
+ public function _token($value) {
|
|
|
+ $this->data['token'] = $value;
|
|
|
}
|
|
|
- public function _autoLoadMore ($value) {
|
|
|
- if ($value == 'yes') {
|
|
|
- $this->auto_load_more = 'yes';
|
|
|
- } else {
|
|
|
- $this->auto_load_more = 'no';
|
|
|
- }
|
|
|
+ public function _auto_load_more($value) {
|
|
|
+ $this->data['auto_load_more'] = ((bool)$value) && $value !== 'no';
|
|
|
}
|
|
|
- public function _topline_read ($value) {
|
|
|
- $this->topline_read = $value === 'yes';
|
|
|
+ public function _topline_read($value) {
|
|
|
+ $this->data['topline_read'] = ((bool)$value) && $value !== 'no';
|
|
|
}
|
|
|
- public function _topline_favorite ($value) {
|
|
|
- $this->topline_favorite = $value === 'yes';
|
|
|
+ public function _topline_favorite($value) {
|
|
|
+ $this->data['topline_favorite'] = ((bool)$value) && $value !== 'no';
|
|
|
}
|
|
|
- public function _topline_date ($value) {
|
|
|
- $this->topline_date = $value === 'yes';
|
|
|
+ public function _topline_date($value) {
|
|
|
+ $this->data['topline_date'] = ((bool)$value) && $value !== 'no';
|
|
|
}
|
|
|
- public function _topline_link ($value) {
|
|
|
- $this->topline_link = $value === 'yes';
|
|
|
+ public function _topline_link($value) {
|
|
|
+ $this->data['topline_link'] = ((bool)$value) && $value !== 'no';
|
|
|
}
|
|
|
- public function _bottomline_read ($value) {
|
|
|
- $this->bottomline_read = $value === 'yes';
|
|
|
+ public function _bottomline_read($value) {
|
|
|
+ $this->data['bottomline_read'] = ((bool)$value) && $value !== 'no';
|
|
|
}
|
|
|
- public function _bottomline_favorite ($value) {
|
|
|
- $this->bottomline_favorite = $value === 'yes';
|
|
|
+ public function _bottomline_favorite($value) {
|
|
|
+ $this->data['bottomline_favorite'] = ((bool)$value) && $value !== 'no';
|
|
|
}
|
|
|
- public function _bottomline_sharing ($value) {
|
|
|
- $this->bottomline_sharing = $value === 'yes';
|
|
|
+ public function _bottomline_sharing($value) {
|
|
|
+ $this->data['bottomline_sharing'] = ((bool)$value) && $value !== 'no';
|
|
|
}
|
|
|
- public function _bottomline_tags ($value) {
|
|
|
- $this->bottomline_tags = $value === 'yes';
|
|
|
+ public function _bottomline_tags($value) {
|
|
|
+ $this->data['bottomline_tags'] = ((bool)$value) && $value !== 'no';
|
|
|
}
|
|
|
- public function _bottomline_date ($value) {
|
|
|
- $this->bottomline_date = $value === 'yes';
|
|
|
+ public function _bottomline_date($value) {
|
|
|
+ $this->data['bottomline_date'] = ((bool)$value) && $value !== 'no';
|
|
|
}
|
|
|
- public function _bottomline_link ($value) {
|
|
|
- $this->bottomline_link = $value === 'yes';
|
|
|
+ public function _bottomline_link($value) {
|
|
|
+ $this->data['bottomline_link'] = ((bool)$value) && $value !== 'no';
|
|
|
}
|
|
|
}
|