aboutsummaryrefslogtreecommitdiff
path: root/app/Models/ConfigurationDAO.php
blob: 57fc980472897c97a4d0821764a11beaef26bcf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
class FreshRSS_ConfigurationDAO extends Minz_ModelArray {
	public $language = 'en';
	public $posts_per_page = 20;
	public $view_mode = 'normal';
	public $default_view = 'not_read';
	public $display_posts = 'no';
	public $onread_jump_next = 'yes';
	public $lazyload = 'yes';
	public $sort_order = 'DESC';
	public $old_entries = 3;
	public $shortcuts = array (
		'mark_read' => 'r',
		'mark_favorite' => 'f',
		'go_website' => 'space',
		'next_entry' => 'j',
		'prev_entry' => 'k',
		'collapse_entry' => 'c',
		'load_more' => 'm'
	);
	public $mail_login = '';
	public $mark_when = array (
		'article' => 'yes',
		'site' => 'yes',
		'scroll' => 'no',
		'reception' => 'no'
	);
	public $sharing = array (
		'shaarli' => '',
		'poche' => '',
		'diaspora' => '',
		'twitter' => true,
		'g+' => true,
		'facebook' => true,
		'email' => true,
		'print' => true
	);
	public $theme = 'default';
	public $anon_access = 'no';
	public $token = '';
	public $auto_load_more = 'yes';
	public $topline_read = 'yes';
	public $topline_favorite = 'yes';
	public $topline_date = 'yes';
	public $topline_link = 'yes';
	public $bottomline_read = 'yes';
	public $bottomline_favorite = 'yes';
	public $bottomline_sharing = 'yes';
	public $bottomline_tags = 'yes';
	public $bottomline_date = 'yes';
	public $bottomline_link = 'yes';

	public function __construct ($nameFile = '') {
		if (empty($nameFile)) {
			$nameFile = DATA_PATH . '/' . Minz_Configuration::currentUser () . '_user.php';
		}
		parent::__construct ($nameFile);

		// TODO : simplifier ce code, une boucle for() devrait suffire !
		if (isset ($this->array['language'])) {
			$this->language = $this->array['language'];
		}
		if (isset ($this->array['posts_per_page'])) {
			$this->posts_per_page = $this->array['posts_per_page'];
		}
		if (isset ($this->array['view_mode'])) {
			$this->view_mode = $this->array['view_mode'];
		}
		if (isset ($this->array['default_view'])) {
			$this->default_view = $this->array['default_view'];
		}
		if (isset ($this->array['display_posts'])) {
			$this->display_posts = $this->array['display_posts'];
		}
		if (isset ($this->array['onread_jump_next'])) {
			$this->onread_jump_next = $this->array['onread_jump_next'];
		}
		if (isset ($this->array['lazyload'])) {
			$this->lazyload = $this->array['lazyload'];
		}
		if (isset ($this->array['sort_order'])) {
			$this->sort_order = $this->array['sort_order'];
		}
		if (isset ($this->array['old_entries'])) {
			$this->old_entries = $this->array['old_entries'];
		}
		if (isset ($this->array['shortcuts'])) {
			$this->shortcuts = array_merge (
				$this->shortcuts, $this->array['shortcuts']
			);
		}
		if (isset ($this->array['mail_login'])) {
			$this->mail_login = $this->array['mail_login'];
		}
		if (isset ($this->array['mark_when'])) {
			$this->mark_when = $this->array['mark_when'];
		}
		if (isset ($this->array['sharing'])) {
			$this->sharing = array_merge (
				$this->sharing, $this->array['sharing']
			);
		}
		if (isset ($this->array['theme'])) {
			$this->theme = $this->array['theme'];
		}
		if (isset ($this->array['anon_access'])) {
			$this->anon_access = $this->array['anon_access'];
		}
		if (isset ($this->array['token'])) {
			$this->token = $this->array['token'];
		}
		if (isset ($this->array['auto_load_more'])) {
			$this->auto_load_more = $this->array['auto_load_more'];
		}

		if (isset ($this->array['topline_read'])) {
			$this->topline_read = $this->array['topline_read'];
		}
		if (isset ($this->array['topline_favorite'])) {
			$this->topline_favorite = $this->array['topline_favorite'];
		}
		if (isset ($this->array['topline_date'])) {
			$this->topline_date = $this->array['topline_date'];
		}
		if (isset ($this->array['topline_link'])) {
			$this->topline_link = $this->array['topline_link'];
		}
		if (isset ($this->array['bottomline_read'])) {
			$this->bottomline_read = $this->array['bottomline_read'];
		}
		if (isset ($this->array['bottomline_favorite'])) {
			$this->bottomline_favorite = $this->array['bottomline_favorite'];
		}
		if (isset ($this->array['bottomline_sharing'])) {
			$this->bottomline_sharing = $this->array['bottomline_sharing'];
		}
		if (isset ($this->array['bottomline_tags'])) {
			$this->bottomline_tags = $this->array['bottomline_tags'];
		}
		if (isset ($this->array['bottomline_date'])) {
			$this->bottomline_date = $this->array['bottomline_date'];
		}
		if (isset ($this->array['bottomline_link'])) {
			$this->bottomline_link = $this->array['bottomline_link'];
		}
	}

	public function update ($values) {
		foreach ($values as $key => $value) {
			$this->array[$key] = $value;
		}

		$this->writeFile($this->array);
		invalidateHttpCache();
	}
}