blob: da5028da381986b8a9757779b2fbc07f685cf714 (
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
|
<?php
class RSSConfiguration extends Model {
private $posts_per_page;
private $default_view;
private $display_posts;
private $sort_order;
public function __construct () {
$confDAO = new RSSConfigurationDAO ();
$this->_postsPerPage ($confDAO->posts_per_page);
$this->_defaultView ($confDAO->default_view);
$this->_displayPosts ($confDAO->display_posts);
$this->_sortOrder ($confDAO->sort_order);
}
public function postsPerPage () {
return $this->posts_per_page;
}
public function defaultView () {
return $this->default_view;
}
public function displayPosts () {
return $this->display_posts;
}
public function sortOrder () {
return $this->sort_order;
}
public function _postsPerPage ($value) {
if (is_int ($value)) {
$this->posts_per_page = $value;
} else {
$this->posts_per_page = 10;
}
}
public function _defaultView ($value) {
if ($value == 'not_read') {
$this->default_view = 'not_read';
} else {
$this->default_view = 'all';
}
}
public function _displayPosts ($value) {
if ($value == 'yes') {
$this->display_posts = 'yes';
} else {
$this->display_posts = 'no';
}
}
public function _sortOrder ($value) {
if ($value == 'high_to_low') {
$this->sort_order = 'high_to_low';
} else {
$this->sort_order = 'low_to_high';
}
}
}
class RSSConfigurationDAO extends Model_array {
public $posts_per_page = 10;
public $default_view = 'all';
public $display_posts = 'no';
public $sort_order = 'low_to_high';
public function __construct () {
parent::__construct (PUBLIC_PATH . '/data/db/Configuration.array.php');
if (isset ($this->array['posts_per_page'])) {
$this->posts_per_page = $this->array['posts_per_page'];
}
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['sort_order'])) {
$this->sort_order = $this->array['sort_order'];
}
}
public function save ($values) {
$this->array[0] = array ();
foreach ($values as $key => $value) {
$this->array[0][$key] = $value;
}
$this->writeFile($this->array);
}
}
|