1
|
|
|
<?php |
2
|
|
|
namespace core; |
3
|
|
|
class Navigation { |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
|
7
|
|
|
//-------------------------- CONSTRUCTEUR ----------------------------------------------------------------------------// |
8
|
|
|
public function __construct() { |
9
|
|
|
$dbc = App::getDb(); |
10
|
|
|
|
11
|
|
|
$query = $dbc->select()->from("navigation")->orderBy("ordre")->get(); |
12
|
|
|
|
13
|
|
|
if (is_array($query) && (count($query) > 0)) { |
14
|
|
|
foreach ($query as $obj) { |
15
|
|
|
if ($obj->ID_page === null) { |
16
|
|
|
$this->getLienNavigationModule($obj->ID_module); |
17
|
|
|
} |
18
|
|
|
else { |
19
|
|
|
$this->getLienNavigationPage($obj->ID_page); |
20
|
|
|
} |
21
|
|
|
} |
22
|
|
|
} |
23
|
|
|
} |
24
|
|
|
//-------------------------- FIN CONSTRUCTEUR ----------------------------------------------------------------------------// |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
|
28
|
|
|
//-------------------------- GETTER ----------------------------------------------------------------------------// |
29
|
|
View Code Duplication |
private function getLienNavigationPage($id_page) { |
|
|
|
|
30
|
|
|
$dbc = App::getDb(); |
31
|
|
|
|
32
|
|
|
$query = $dbc->select() |
33
|
|
|
->from("navigation") |
34
|
|
|
->from("page") |
35
|
|
|
->where("navigation.ID_page", "=", "page.ID_page", "AND") |
36
|
|
|
->where("page.ID_page", "=", $id_page) |
37
|
|
|
->get(); |
38
|
|
|
|
39
|
|
|
if (is_array($query) && (count($query) > 0)) { |
40
|
|
|
foreach ($query as $obj) { |
41
|
|
|
echo($obj->titre." ++ ".$obj->url."<br>"); |
42
|
|
|
} |
43
|
|
|
} |
44
|
|
|
} |
45
|
|
|
|
46
|
|
View Code Duplication |
private function getLienNavigationModule($id_module) { |
|
|
|
|
47
|
|
|
$dbc = App::getDb(); |
48
|
|
|
|
49
|
|
|
$query = $dbc->select() |
50
|
|
|
->from("navigation") |
51
|
|
|
->from("module") |
52
|
|
|
->where("navigation.ID_module", "=", "module.ID_module", "AND") |
53
|
|
|
->where("module.ID_module", "=", $id_module) |
54
|
|
|
->get(); |
55
|
|
|
|
56
|
|
|
if (is_array($query) && (count($query) > 0)) { |
57
|
|
|
foreach ($query as $obj) { |
58
|
|
|
echo($obj->nom_module." ++ ".$obj->url."<br>"); |
59
|
|
|
} |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
//-------------------------- FIN GETTER ----------------------------------------------------------------------------// |
63
|
|
|
|
64
|
|
|
|
65
|
|
|
|
66
|
|
|
//-------------------------- SETTER ----------------------------------------------------------------------------// |
67
|
|
|
//-------------------------- FIN SETTER ----------------------------------------------------------------------------// |
68
|
|
|
} |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.