-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
101 lines (78 loc) · 3.23 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
<?php error_reporting(E_ALL);
session_start();
require_once('common/PageView.php');
require_once('view/PageNavigationView.php');
require_once('view/PageCompositionView.php');
require_once('database/DBConfig.php');
require_once('database/Database.php');
require_once('controller/LoginController.php');
require_once('controller/RegisterController.php');
require_once('controller/RecordController.php');
require_once('controller/RecordingController.php');
require_once('model/LoginHandler.php');
require_once('view/MasterView.php');
require_once('view/RecordingListNavigationView.php');
class MasterController {
const TITLE = 'sayHello';
public function doControl() {
$loginOutput = null;
$registerOutput = null;
$recBoxOutput = null;
$body = '';
// instances
$dbConfig = new \permag\database\DBConfig();
$db = new \permag\database\Database($dbConfig);
// db connect
$db->connect();
$loginHandler = new \permag\model\LoginHandler($db);
$pageView = new \permag\common\PageView();
$masterView = new \permag\view\MasterView();
$pageNavigationView = new \permag\view\PageNavigationView();
$pageCompositionView = new \permag\view\PageCompositionView();
$recListNavView = new \permag\view\RecordingListNavigationView($pageNavigationView);
// show logo
$pageCompositionView->addToLeftSection($masterView->doLogo());
// login doControl
$loginController = new \permag\controller\LoginController();
$loginOutput = $loginController->doControl($loginHandler, $pageNavigationView);
// page navigation
switch ($pageNavigationView->getController()) {
default:
case \permag\view\PageNavigationView::HOME:
if ($loginHandler->isLoggedIn()) {
// recorder doControl
$recController = new \permag\controller\RecordController($loginHandler, $db);
$recordingController = new \permag\controller\RecordingController($loginHandler, $db, $recListNavView);
// page comp
$pageCompositionView->addToLeftSection($masterView->doNavigationMenu($recListNavView));
$pageCompositionView->addToLeftSection($loginOutput);
$pageCompositionView->addToRightSection($recController->doControlBox());
$pageCompositionView->addToMainSection($recordingController->doControlRecordingsList());
} else {
$pageNavigationView->redirectTo($pageNavigationView->getLoginLink());
}
break;
case \permag\view\PageNavigationView::LOGIN:
// page comp
$pageCompositionView->addToRightSection($masterView->doDescription());
$pageCompositionView->addToMainSection($loginOutput);
break;
case \permag\view\PageNavigationView::REGISTER:
// register doControl
$regController = new \permag\controller\RegisterController();
$registerOutput = $regController->doControl($loginHandler, $db, $pageNavigationView);
// page comp
$pageCompositionView->addToRightSection($masterView->doDescription());
$pageCompositionView->addToMainSection($registerOutput);
break;
}
// kill db conn
$db = null;
// composition
$body = $pageCompositionView->mergeSectionsToPage();
// page view
return $pageView->getHTMLPage(self::TITLE, $body);
}
}
$masterController = new MasterController();
echo $masterController->doControl();