1
|
|
|
<?php |
2
|
|
|
namespace core\contenus; |
3
|
|
|
|
4
|
|
|
use core\App; |
5
|
|
|
use core\functions\ChaineCaractere; |
6
|
|
|
use core\RedirectError; |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
class Contenus { |
10
|
|
|
//pour la table page |
11
|
|
|
protected $id_page; |
12
|
|
|
protected $titre; |
13
|
|
|
protected $contenu; |
14
|
|
|
protected $url; |
15
|
|
|
protected $meta_description; |
16
|
|
|
protected $balise_title; |
17
|
|
|
protected $parent; |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
|
21
|
|
|
//-------------------------- CONSTRUCTEUR ----------------------------------------------------------------------------// |
22
|
|
|
public function __construct($url, $admin_contenu = null) { |
23
|
|
|
if ($admin_contenu === null) { |
24
|
|
|
$this->getPage($url); |
25
|
|
|
} |
26
|
|
|
} |
27
|
|
|
//-------------------------- FIN CONSTRUCTEUR ----------------------------------------------------------------------------// |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
|
31
|
|
|
//-------------------------- GETTER ----------------------------------------------------------------------------// |
32
|
|
|
//pour la table page |
33
|
|
|
public function getIdPage() { |
34
|
|
|
return $this->id_page; |
35
|
|
|
} |
36
|
|
|
public function getTitre() { |
37
|
|
|
return $this->titre; |
38
|
|
|
} |
39
|
|
|
public function getContenu() { |
40
|
|
|
return $this->contenu; |
41
|
|
|
} |
42
|
|
|
public function getUrl() { |
43
|
|
|
return $this->url; |
44
|
|
|
} |
45
|
|
|
public function getMetaDescription() { |
46
|
|
|
return $this->meta_description; |
47
|
|
|
} |
48
|
|
|
public function getBaliseTitle() { |
49
|
|
|
return $this->balise_title; |
50
|
|
|
} |
51
|
|
|
public function getParent() { |
52
|
|
|
return $this->parent; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @param $url |
57
|
|
|
* function that get all content of a page |
58
|
|
|
*/ |
59
|
|
|
private function getPage($url) { |
60
|
|
|
$dbc = \core\App::getDb(); |
61
|
|
|
$query = $dbc->select()->from("page")->where("url", "=", $url)->get(); |
62
|
|
|
|
63
|
|
|
if (RedirectError::testRedirect404($query, $url) === true) { |
64
|
|
|
foreach ($query as $obj) { |
65
|
|
|
$redirect = 0; |
66
|
|
|
if (ChaineCaractere::FindInString($url, "http://") === true) { |
67
|
|
|
$redirect = 1; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
$this->setContenu($redirect, $obj); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
//-------------------------- FIN GETTER ----------------------------------------------------------------------------// |
75
|
|
|
|
76
|
|
|
|
77
|
|
|
|
78
|
|
|
//-------------------------- SETTER ----------------------------------------------------------------------------// |
79
|
|
|
/** |
80
|
|
|
* @param $redirect |
81
|
|
|
* @param $obj |
82
|
|
|
*/ |
83
|
|
|
private function setContenu($redirect, $obj) { |
84
|
|
|
App::setValues(["contenus" => [ |
85
|
|
|
"id_page" => $this->id_page = $obj->ID_page, |
86
|
|
|
"meta_description" => $this->meta_description = $obj->meta_description, |
87
|
|
|
"balise_title" => $this->balise_title = $obj->balise_title, |
88
|
|
|
"url" => $this->url = $obj->url, |
89
|
|
|
"titre" => $this->titre = $obj->titre, |
90
|
|
|
"contenu" => $this->contenu = $obj->contenu, |
91
|
|
|
"parent" => $this->parent = $obj->parent, |
92
|
|
|
"redirect_page" => $redirect, |
93
|
|
|
"bloc_editable" => $obj->bloc_editable |
94
|
|
|
]]); |
95
|
|
|
} |
96
|
|
|
//-------------------------- FIN SETTER ----------------------------------------------------------------------------// |
97
|
|
|
} |