-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
110 lines (87 loc) · 2.96 KB
/
index.php
File metadata and controls
110 lines (87 loc) · 2.96 KB
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
<?php
require 'vendor/autoload.php';
use Slim\Slim;
use Ibonly\Blog\BlogController;
use Ibonly\Blog\MenuController;
use Ibonly\Blog\ContentController;
use Ibonly\Blog\Sub_MenuController;
date_default_timezone_set('Africa/Lagos');
$menu = new MenuController();
$submenu = new Sub_MenuController();
$content = new ContentController();
$blog = new BlogController();
$app = new Slim( array(
'templates.path' => 'resources/view',
'view' => new \Slim\Views\Twig()
));
$twigView = $app->view();
$twigView->parserOptions = array(
'debug' => false
);
$twigView->parserDirectory = 'Twig';
$twigView->parserExtensions = array(
new \Slim\Views\TwigExtension()
);
$app->get('/', function () use ($app, $blog) {
$app->render('home.html.twig', [
'menus' => $blog->getMenu(),
'allContents' => $blog->getAllContent(),
'recentPost' =>$blog->getRecentTitle()
]);
});
$app->get('/menu/:id', function ($id) use ($app, $blog) {
$app->render('menu_list.html.twig', [
'menus' => $blog->getMenu(),
'contents' => $blog->getmenuContent($id),
'recentPost' =>$blog->getRecentTitle()
]);
});
$app->get('/content/:id', function ($id) use ($app, $blog) {
$app->render('content.html.twig', [
'menus' => $blog->getMenu(),
'blogContents' => $blog->getContent($id),
'recentPost' =>$blog->getRecentTitle()
]);
});
$app->post('/search', function () use ($app, $blog) {
$app->render('search.html.twig', [
'menus' => $blog->getMenu(),
'contents' => $blog->getSearch($_POST['search']),
'recentPost' =>$blog->getRecentTitle()
]);
});
$app->get('/admin', function () use ($app, $blog) {
$app->render('admin/home.html.twig', [
'menus' => $blog->getMenu(),
'contents' => $blog->getAllContent()
]);
});
$app->get('/admin/content', function () use ($app, $blog) {
$app->render('admin/content.html.twig', [
'menus' => $blog->getMenu()
]);
});
$app->get('/admin/menu', function () use ($app, $blog) {
$app->render('admin/menu.html.twig', [
'menus' => $blog->getMenu()
]);
});
$app->get('/admin/content/:id', function ($id) use ($app, $blog) {
$app->render('admin/content_update.html.twig', [
'menus' => $blog->getMenu(),
'contents' => $blog->getContent($id)
]);
});
$app->post('/admin/menu/create', function () use ($menu) {
echo $menu->insertMenu($_POST['name'], $_POST['description']);
});
$app->post('/admin/menu/sub_menu', function () use ($submenu) {
echo $submenu->insertSubMenu($_POST['menu_id'], $_POST['submenu_name'], $_POST['submenu_description']);
});
$app->post('/admin/content', function () use ($content) {
echo $content->insertContent($_POST['menu_id'], $_POST['title'], $_POST['content']);
});
$app->post('/admin/content/update', function () use ($content) {
echo $content->updateContent($_POST['id'], $_POST['menu_id'], $_POST['title'], $_POST['content']);
});
$app->run();