-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwording.php
More file actions
72 lines (60 loc) · 2.45 KB
/
Copy pathwording.php
File metadata and controls
72 lines (60 loc) · 2.45 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
<?php
/* ---------------------------------
--------------- MODEL --------------
--------------------------------- */
include("content/includes/model.php");
$actions = array("add", "edit", "generate", "delete");
$action = (isset($_GET["action"])) ? $_GET["action"] : NULL;
$id = (isset($_GET["id"])) ? $_GET["id"] : NULL;
if (isset($action) && in_array($action, $actions) && (isset($id) && check_wording_id($id) || $action == "add")) {
if ($action == "add" || $action == "edit") {
$title = (isset($_POST["title"])) ? htmlspecialchars($_POST["title"], ENT_QUOTES) : NULL;
$content = (isset($_POST["content"])) ? htmlspecialchars($_POST["content"], ENT_QUOTES) : NULL;
if (isset($title) || isset($content)) {
$errors = get_wording_errors($title, $content);
$check = $errors["title"]["valid"] && $errors["content"]["valid"];
if ($check) {
if ($action == "add") {
add_wording($title, $content);
header("Location: " . $config["sitelink"] . "/wordings");
exit();
} else {
edit_wording($id, $title, $content);
}
}
} else if ($action == "edit") {
$wording = get_wording($id);
$title = $wording["title"];
$content = $wording["content"];
}
$page = array(
"link" => $config["sitelink"] . "/wording/" . $action . ($action == "add" ? "" : "/" . $id),
"title" => ($action == "add") ? "Ajout d'un énoncé" : "Modification d'un énoncé",
"breadcrumb" => ($action == "add") ? "Ajouter" : "Modifier",
"card_title" => "Informations concernant l'énoncé",
"btn_text" => ($action == "add") ? "Ajouter l'énoncé" : "Modifier l'énoncé"
);
} else if ($action == "generate") {
$wording = get_wording($id);
$page = array(
"link" => $config["sitelink"] . "/wording/" . $action . "/" . $id,
"title" => $wording["title"],
"card_title" => "Consignes de l'énoncé"
);
$content = generate_wording($wording["content"]);
//header("Content-Type: text/html");
//header("Content-Disposition: attachment; filename=enonce-" . $id . ".html");
} else {
delete_wording($id);
header("Location: " . $config["sitelink"] . "/wordings");
exit();
}
} else {
header("Location: " . $config["sitelink"] . "/wordings");
exit();
}
mysqli_close($db);
/* ---------------------------------
---------------- VUE ---------------
--------------------------------- */
include("content/vues/wording.php");