-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
122 lines (100 loc) · 3.15 KB
/
index.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
//classes necessárias
include_once "controller/HomeController.php";
include_once "controller/UsuarioController.php";
include_once "controller/CategoriaController.php";
include_once "controller/NoticiaController.php";
//minha url
define('URL','http://localhost/etecnewsCRUD/');
/* SE existe(isset) url */
if(isset($_GET['url']))
{
/* explode - quebra e guarda as coisas, em um array, de acordo com o delimitador que nesse caso é a '/' */
$url = explode('/', $_GET['url']);
switch($url[0])
{
case 'cadastro-usuario':
$usu = new UsuarioController();
$usu->abrirCadastro();
break;
case 'consulta-usuario':
$usu = new UsuarioController();
$usu->abrirConsulta();
break;
case 'cadastro-categoria':
$usu = new CategoriaController();
$usu->abrirCadastro();
break;
case 'consulta-categoria':
$usu = new CategoriaController();
$usu->abrirConsulta();
break;
case 'cadastro-noticia':
$usu = new NoticiaController();
$usu->abrirCadastro();
break;
case 'consulta-noticia':
$usu = new NoticiaController();
$usu->abrirConsulta();
break;
/* Enviar os cadastros */
case 'enviar-usuario':
$usu = new UsuarioController();
$usu->cadastrar();
break;
case 'enviar-categoria':
$usu = new CategoriaController();
$usu->cadastrar();
break;
case 'enviar-noticia':
$usu = new NoticiaController();
$usu->cadastrar();
break;
/* Excluir os cadastros */
/* Colocamos o [1] para pegar o codusuario que é mandado para a url. O [0] é o excluir-usuario, porque ele é a primeira posição do array que fica lá em cima no
$url = explode('/', $_GET['url']);
switch($url[0])
{
*/
case 'excluir-usuario':
$usu = new UsuarioController();
$usu->excluir($url[1]);
break;
case 'excluir-categoria':
$usu = new CategoriaController();
$usu->excluir($url[1]);
break;
// Editar dados do usuario
case 'editar-usuario':
$usu = new UsuarioController();
$usu->editar($url[1]);
break;
case 'atualizar-usuario':
$usu = new UsuarioController();
$usu->atualizar();
break;
// Editar categorias
case 'editar-categoria':
$usu = new CategoriaController();
$usu->editar($url[1]);
break;
case 'atualizar-categoria':
$usu = new CategoriaController();
$usu->atualizar();
break;
// Editar noticias
default:
echo "página não encontrada<br>
Verificar se existe a rota criada<br>
Tentando acessar a rota: $url[0]";
//poderá depois abrir uma página de aviso
break;
}
}
else
{
//abrir a página inicial
$home = new HomeController();
$home->abrirHome();
}
?>