-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathjokes_controller.php
57 lines (43 loc) · 1.18 KB
/
jokes_controller.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
<?php
// default action will be used in init.php...
$default_action = 'list';
require_once('includes/init.php');
require_once('includes/jokes_db.php');
require_once('includes/authors_db.php');
require_once('includes/helpers.php');
switch ($action) {
case 'list':
$jokes = listJokes($page);
$totalJokes = countJokes();
$title = 'Joke list';
$output = 'jokes/list.php';
break;
case 'edit':
$title = 'Edit this joke';
$joke = getJoke($_GET['jokeid']);
$authors = listAuthors();
$output = 'jokes/form.php';
break;
case 'new':
$title = "New joke";
$joke = getJoke();
$authors = listAuthors();
$output = "jokes/form.php";
break;
case 'save':
if ($result = saveJoke($_POST)) {
header("Location: jokes_controller.php?action=list");
}
break;
case 'delete':
$title = 'Delete this joke';
$output = 'jokes/confirm_delete.php';
break;
case 'deletenow':
// if ($result = deleteJoke($_POST)) {
setMessage("Joke {$_POST['jokeid']} has been deleted.");
session_write_close();
header("Location: jokes_controller.php?action=list");
// }
}
include('page.php' );