1
|
|
|
<?php |
2
|
|
|
namespace modules\blog\app\controller; |
3
|
|
|
|
4
|
|
|
|
5
|
|
|
use core\App; |
6
|
|
|
|
7
|
|
|
class Blog { |
8
|
|
|
private static $force_login_comment; |
9
|
|
|
private static $article_index; |
10
|
|
|
private static $validate_comment; |
11
|
|
|
private static $category; |
12
|
|
|
|
13
|
|
|
public static $router_parameter; |
14
|
|
|
|
15
|
|
|
private static $values = []; |
16
|
|
|
|
17
|
|
|
//-------------------------- BUILDER ----------------------------------------------------------------------------// |
18
|
|
|
public function __construct() { |
19
|
|
|
|
20
|
|
|
} |
21
|
|
|
//-------------------------- END BUILDER ----------------------------------------------------------------------------// |
22
|
|
|
|
23
|
|
|
|
24
|
|
|
//-------------------------- GETTER ----------------------------------------------------------------------------// |
25
|
|
|
/** |
26
|
|
|
* @return array |
27
|
|
|
* get array of all values wich will be used in the page |
28
|
|
|
*/ |
29
|
|
|
public static function getValues() { |
30
|
|
|
return ["blog" => self::$values]; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* this function load the configuration of the blog |
35
|
|
|
*/ |
36
|
|
|
private static function getConfiguration() { |
37
|
|
|
$dbc = App::getDb(); |
38
|
|
|
|
39
|
|
|
$query = $dbc->select()->from("_blog_configuration")->where("ID_configuration", "=", 1)->get(); |
40
|
|
|
|
41
|
|
|
foreach ($query as $obj) { |
42
|
|
|
self::$force_login_comment = $obj->force_login_comment; |
43
|
|
|
self::$article_index = $obj->article_index; |
44
|
|
|
self::$validate_comment = $obj->validate_comment; |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @return mixed |
50
|
|
|
* this function get force login comment, if return 1 the user must be connected to post a comment |
51
|
|
|
* on the article |
52
|
|
|
*/ |
53
|
|
|
public static function getForceLoginComment() { |
54
|
|
|
if (self::$force_login_comment == null) { |
55
|
|
|
self::getConfiguration(); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
return self::$force_login_comment; |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/* |
62
|
|
|
* funciton that return the max nuber of article that we will get on index page |
63
|
|
|
*/ |
64
|
|
|
public static function getArticleIndex() { |
65
|
|
|
if (self::$article_index == null) { |
66
|
|
|
Blog::getConfiguration(); |
67
|
|
|
|
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
return self::$article_index; |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/** |
74
|
|
|
* @return mixed |
75
|
|
|
* function return if a comment must be validate to be displayed on the website only if this function |
76
|
|
|
* return 1 |
77
|
|
|
*/ |
78
|
|
|
public static function getValidateComment() { |
79
|
|
|
if (self::$validate_comment == null) { |
80
|
|
|
self::getConfiguration(); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
return self::$validate_comment; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
public static function getCategory() { |
87
|
|
|
if (self::$category == null) { |
88
|
|
|
self::$category = new Category(); |
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
return self::$category; |
92
|
|
|
} |
93
|
|
|
//-------------------------- END GETTER ----------------------------------------------------------------------------// |
94
|
|
|
|
95
|
|
|
|
96
|
|
|
//-------------------------- SETTER ----------------------------------------------------------------------------// |
97
|
|
|
/** |
98
|
|
|
* @param $values |
99
|
|
|
* can set values while keep older infos |
100
|
|
|
*/ |
101
|
|
|
public static function setValues($values) { |
102
|
|
|
Blog::$values = array_merge(Blog::$values, $values); |
103
|
|
|
} |
104
|
|
|
//-------------------------- END SETTER ----------------------------------------------------------------------------// |
105
|
|
|
} |