-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.php
134 lines (105 loc) · 5.54 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
123
124
125
126
127
128
129
130
131
132
133
134
<?php
// Application Routes
// white list routes
use System\Application;
$app = Application::getInstance();
// If the URL contains '/admin' which means the user is trying to access the Admin Panel, call index() method in AccessController.php Class
if (strpos($app->request->url(), '/admin') === 0 ) {
// check if the current url started with /admin
// if so, then call our middlewares
$app->route->callFirst(function ($app) {
$app->load->action('Admin/Access', 'index');
});
// share admin layout
$app->share('adminLayout', function ($app) {
return $app->load->controller('Admin/Common/Layout');
});
} else {
// share Blog layout
$app->share('blogLayout', function ($app) {
return $app->load->controller('Blog/Common/Layout');
});
// share|load settings for each request
$app->share('settings', function ($app) {
$settingsModel = $app->load->model('Settings');
$settingsModel->loadAll();
return $settingsModel;
});
}
// Application Routes
// Admin Routes
$app->route->add('/admin/login', 'Admin/Login'); // if the user is already authenticated/logged-in, redirect them to the DashboardController.php (dashboard.php page) (by the index() method in LoginController.php Class)
$app->route->add('/admin/login/submit', 'Admin/Login@submit', 'POST');
// dashboard
$app->route->add('/admin' , 'Admin/Dashboard'); // If the user is unauthenticated/not logged-in/guest, they get redirected to '/admin/login' page (by the index() method in AccessController.php)
$app->route->add('/admin/dashboard' , 'Admin/Dashboard');
$app->route->add('/admin/submit' , 'Admin/Dashboard@submit', 'POST');
// admin => users
$app->route->add('/admin/users', 'Admin/Users');
$app->route->add('/admin/users/add', 'Admin/Users@add', 'POST');
$app->route->add('/admin/users/submit', 'Admin/Users@submit', 'POST');
$app->route->add('/admin/users/edit/:id', 'Admin/Users@edit', 'POST');
$app->route->add('/admin/users/save/:id', 'Admin/Users@save' , 'POST');
$app->route->add('/admin/users/delete/:id', 'Admin/Users@delete', 'POST');
// admin => user profile
$app->route->add('/admin/profile/update', 'Admin/Profile@update' , 'POST');
// admin => users groups
$app->route->add('/admin/users-groups', 'Admin/UsersGroups');
$app->route->add('/admin/users-groups/add', 'Admin/UsersGroups@add', 'POST');
$app->route->add('/admin/users-groups/submit', 'Admin/UsersGroups@submit', 'POST');
$app->route->add('/admin/users-groups/edit/:id', 'Admin/UsersGroups@edit', 'POST');
$app->route->add('/admin/users-groups/save/:id', 'Admin/UsersGroups@save' , 'POST');
$app->route->add('/admin/users-groups/delete/:id', 'Admin/UsersGroups@delete', 'POST');
// admin => posts
$app->route->add('/admin/posts', 'Admin/Posts');
$app->route->add('/admin/posts/add', 'Admin/Posts@add', 'POST');
$app->route->add('/admin/posts/submit', 'Admin/Posts@submit', 'POST');
$app->route->add('/admin/posts/edit/:id', 'Admin/Posts@edit', 'POST');
$app->route->add('/admin/posts/save/:id', 'Admin/Posts@save' , 'POST');
$app->route->add('/admin/posts/delete/:id', 'Admin/Posts@delete', 'POST');
// Admin => Comments
//$app->route->add('/admin/posts/:id/comments', 'Admin/Comments');
//$app->route->add('/admin/comments/edit/:id', 'Admin/Comments@edit');
//$app->route->add('/admin/comments/save/:id', 'Admin/Comments@save', 'POST');
//$app->route->add('/admin/comments/delete/:id', 'Admin/Comments@delete');
// Admin Categories Routes
$app->route->add('/admin/categories', 'Admin/Categories');
$app->route->add('/admin/categories/add', 'Admin/Categories@add', 'POST');
$app->route->add('/admin/categories/submit', 'Admin/Categories@submit', 'POST');
$app->route->add('/admin/categories/edit/:id', 'Admin/Categories@edit', 'POST');
$app->route->add('/admin/categories/save/:id', 'Admin/Categories@save' , 'POST');
$app->route->add('/admin/categories/delete/:id', 'Admin/Categories@delete', 'POST');
// Admin settings
$app->route->add('/admin/settings', 'Admin/Settings');
$app->route->add('/admin/settings/save', 'Admin/Settings@save', 'POST');
// Admin Contacts
$app->route->add('/admin/contacts', 'Admin/Contacts');
$app->route->add('/admin/contacts/reply/:id', 'Admin/Contacts@reply');
$app->route->add('/admin/contacts/send/:id', 'Admin/Contacts@send' , 'POST');
// admin => ads
$app->route->add('/admin/ads', 'Admin/Ads');
$app->route->add('/admin/ads/add', 'Admin/Ads@add', 'POST');
$app->route->add('/admin/ads/submit', 'Admin/Ads@submit', 'POST');
$app->route->add('/admin/ads/edit/:id', 'Admin/Ads@edit', 'POST');
$app->route->add('/admin/ads/save/:id', 'Admin/Ads@save' , 'POST');
$app->route->add('/admin/ads/delete/:id', 'Admin/Ads@delete', 'POST');
// logout
$app->route->add('/admin/logout', 'Admin/Logout');
// Blog Routes
$app->route->add('/', 'Blog/Home'); // Home Page
$app->route->add('/category/:text/:id', 'Blog/Category');
$app->route->add('/post/:text/:id', 'Blog/Post');
$app->route->add('/post/:text/:id/add-comment', 'Blog/Post@addComment', 'POST');
$app->route->add('/register', 'Blog/Register');
$app->route->add('/register/submit', 'Blog/Register@submit', 'POST');
$app->route->add('/login', 'Blog/Login');
$app->route->add('/login/submit', 'Blog/Login@submit', 'POST');
$app->route->add('/logout', 'Blog/Logout');
//$app->route->add('/contact-us', 'Blog/Contact');
//$app->route->add('/contact-us/submit', 'Blog/Contact@submit', 'POST');
//$app->route->add('/about-us', 'Blog/About');
//$app->route->add('/profile', 'Blog/Profile');
//$app->route->add('/search', 'Blog/Search');
// Not Found Routes
$app->route->add('/404', 'NotFound');
$app->route->notFound('/404');