|
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
|
|
|
|
|
12
|
|
|
//-------------------------- BUILDER ----------------------------------------------------------------------------// |
|
13
|
|
|
public function __construct() { |
|
14
|
|
|
|
|
15
|
|
|
} |
|
16
|
|
|
//-------------------------- END BUILDER ----------------------------------------------------------------------------// |
|
17
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
//-------------------------- GETTER ----------------------------------------------------------------------------// |
|
20
|
|
|
/** |
|
21
|
|
|
* this function load the configuration of the blog |
|
22
|
|
|
*/ |
|
23
|
|
|
public static function getConfiguration() { |
|
24
|
|
|
if (self::$force_login_comment == null) { |
|
25
|
|
|
$dbc = App::getDb(); |
|
26
|
|
|
|
|
27
|
|
|
$query = $dbc->select()->from("_blog_configuration")->where("ID_configuration", "=", 1)->get(); |
|
28
|
|
|
|
|
29
|
|
|
foreach ($query as $obj) { |
|
30
|
|
|
self::$force_login_comment = $obj->force_login_comment; |
|
31
|
|
|
self::$article_index = $obj->article_index; |
|
32
|
|
|
self::$validate_comment = $obj->validate_comment; |
|
33
|
|
|
} |
|
34
|
|
|
} |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @return mixed |
|
39
|
|
|
* this function get force login comment, if return 1 the user must be connected to post a comment |
|
40
|
|
|
* on the article |
|
41
|
|
|
*/ |
|
42
|
|
|
public static function getForceLoginComment() { |
|
43
|
|
|
if (self::$force_login_comment == null) { |
|
44
|
|
|
self::getConfiguration(); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
return self::$force_login_comment; |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/* |
|
51
|
|
|
* funciton that return the max nuber of article that we will get on index page |
|
52
|
|
|
*/ |
|
53
|
|
|
public static function getArticleIndex() { |
|
54
|
|
|
if (self::$article_index == null) { |
|
55
|
|
|
self::getConfiguration(); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
return self::$article_index; |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @return mixed |
|
63
|
|
|
* function return if a comment must be validate to be displayed on the website only if this function |
|
64
|
|
|
* return 1 |
|
65
|
|
|
*/ |
|
66
|
|
|
public static function getValidateComment() { |
|
67
|
|
|
if (self::$validate_comment == null) { |
|
68
|
|
|
self::getConfiguration(); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
return self::$validate_comment; |
|
72
|
|
|
} |
|
73
|
|
|
//-------------------------- END GETTER ----------------------------------------------------------------------------// |
|
74
|
|
|
|
|
75
|
|
|
|
|
76
|
|
|
//-------------------------- SETTER ----------------------------------------------------------------------------// |
|
77
|
|
|
//-------------------------- END SETTER ----------------------------------------------------------------------------// |
|
78
|
|
|
} |