-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrouter.php
97 lines (91 loc) · 2.33 KB
/
router.php
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
93
94
95
96
97
<?php namespace webshop;
/**
* Created by PhpStorm.
* User: TrainingUser
* Date: 21-5-2015
* Time: 9:04
*/
new Router();
class Router {
public $blog = "";
public $page = "";
public $action = "";
public $id = "";
public $controller = "";
public function __construct()
{
$this->getParam();
$this->routePage();
}
public function getParam()
{
$this->page = isset($_GET['page'])?$this->page = strip_tags($_GET['page']):"";
$this->action = isset($_GET['action'])?$this->action = strip_tags($_GET['action']):"";
$this->id = isset($_GET['id'])?$this->id = strip_tags($_GET['id']):"";
$this->blog = isset($_GET['bloggerid'])?$this->id = strip_tags($_GET['bloggerid']):"";
}
public function routePage()
{
// echo $this->page . "<br>";
// echo $this->action . "<br>";
// echo $this->id . "<br>";
switch ($this->page)
{
case "post":
$this->controller = new controllers\ControllerPost();
break;
case "comment":
$this->controller = new controllers\ControllerComment();
break;
case "product":
$this->controller = new controllers\ControllerProduct();
break;
case "login":
$this->controller = new controllers\ControllerLogin();
break;
case "blogger":
$this->controller = new controllers\ControllerBlogger();
break;
case "order":
$this->controller = new controllers\ControllerOrder();
break;
case "customer":
$this->controller = new controllers\ControllerCustomer();
break;
default:
$this->controller = new controllers\ControllerProduct();
}
switch ($this->action)
{
case "all":
$this->controller->index();
break;
case "show":
$this->controller->show($this->id);
break;
case "create":
$this->controller->create();
break;
case "edit":
$this->controller->edit($this->id);
break;
case "store":
$this->controller->store($this->id);
break;
case "update":
$this->controller->update($this->id);
break;
case "delete":
$this->controller->delete($this->id);
break;
case "manage":
$this->controller->manage($this->blog);
break;
case "confirm":
$this->controller->show(true);
break;
default:
$this->controller->index($this->blog);
}
}
}