-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.php
64 lines (49 loc) · 1.2 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
<?php
/*!
* \brief The index page for the site, handles url path.
*/
include_once("./app/redux.php");
global $pageData;
global $viewData;
global $classMap;
if (isset ($_GET["page"])) {
$pagePath = $_GET["page"];
} else {
$pagePath = 'index';
}
$pageData->setPath($pagePath);
$slug = $pageData->getSlug();
if (isset($classMap[$slug])) {
$controller = null;
$view = null;
if(isset($classMap[$slug]['controller'])) {
$controller = $classMap[$slug]['controller'];
}
if(isset($classMap[$slug]['view'])) {
$view = $classMap[$slug]['view'];
}
if ($view != null) {
$pageData->setView($view);
if($controller != null) {
// If there is a controller, run its main
$contollerClass = "\Controller\Pages\\" . $controller;
$contollerClass::main($pageData, $viewData);
} else {
// Otherwise, we will assume that the type of the page
// is the same name as the view. (Used for css includes)
$viewData->setType($view);
}
if($pageData->found()) {
$pageData->renderPage();
} else {
// If the controller set the 404 error
throw404();
}
} else {
// If the page has no view
throw404();
}
} else {
// If the slug is not found
throw404();
}