|
1 |
| -<?php |
2 |
| - |
| 1 | +<?php /* vim: set colorcolumn= expandtab shiftwidth=2 softtabstop=2 tabstop=4 smarttab: */ |
3 | 2 | namespace BNETDocs\Templates\News;
|
4 |
| - |
5 | 3 | use \CarlBennett\MVC\Libraries\Pair;
|
6 |
| - |
7 |
| -$title = "Delete News Post"; |
8 |
| -$description = "This form allows an individual to delete a news post."; |
9 |
| - |
10 |
| -$this->opengraph->attach(new Pair("url", "/news/delete")); |
11 |
| -$this->opengraph->attach(new Pair("type", "article")); |
12 |
| - |
13 |
| -switch ($this->getContext()->error) { |
14 |
| - case "ACL_NOT_SET": |
15 |
| - $message = "You do not have the privilege to delete news posts."; |
16 |
| - break; |
17 |
| - case "NOT_FOUND": |
18 |
| - $message = "Cannot find news post by that id."; |
19 |
| - break; |
20 |
| - case "NOT_LOGGED_IN": |
21 |
| - $message = "You must be logged in to delete news posts."; |
22 |
| - break; |
23 |
| - case "INTERNAL_ERROR": |
24 |
| - $message = "An internal error occurred while processing your request. " |
25 |
| - . "Our staff have been notified of the issue. Try again later."; |
26 |
| - break; |
27 |
| - default: |
28 |
| - $message = $this->getContext()->error; |
| 4 | +$title = 'Delete News Post'; |
| 5 | +$description = 'This form allows an individual to delete a news post.'; |
| 6 | +$this->opengraph->attach(new Pair('url', '/news/delete')); |
| 7 | +$this->opengraph->attach(new Pair('type', 'article')); |
| 8 | +$error = $this->getContext()->error; |
| 9 | +$id = $this->getContext()->id; |
| 10 | +$news_post_title = $this->getContext()->title; |
| 11 | +switch ($error) |
| 12 | +{ |
| 13 | + case 'ACL_NOT_SET': $message = 'You do not have the privilege to delete news posts.'; break; |
| 14 | + case 'NOT_FOUND': $message = 'Cannot find news post by that id.'; break; |
| 15 | + case 'NOT_LOGGED_IN': $message = 'You must be logged in to delete news posts.'; break; |
| 16 | + case 'INTERNAL_ERROR': $message = 'An internal error occurred while processing your request. Our staff have been notified of the issue. Try again later.'; break; |
| 17 | + default: $message = $error; |
29 | 18 | }
|
30 |
| - |
31 |
| -require("./header.inc.phtml"); |
32 |
| -?> |
33 |
| - <article> |
34 |
| -<?php if (is_null($this->getContext()->error)) { ?> |
35 |
| - <header>Delete News Post</header> |
36 |
| - <form method="POST" action="?id=<?php echo |
37 |
| - htmlspecialchars($this->getContext()->id, ENT_HTML5, "UTF-8"); ?>"> |
38 |
| - <section> |
39 |
| - <p>Are you sure you wish to delete this news post?</p> |
40 |
| - <p><input type="text" readonly="readonly" value="<?php echo filter_var($this->getContext()->title, FILTER_SANITIZE_STRING); ?>" tabindex="1"/></p> |
41 |
| - <p><input type="submit" value="Delete News Post" tabindex="2" autofocus="autofocus"/></p> |
42 |
| - </section> |
43 |
| - </form> |
44 |
| -<?php } else if ($this->getContext()->error === false) { ?> |
45 |
| - <header class="green">News Post Deleted</header> |
46 |
| - <section class="green"> |
47 |
| - <p>You have successfully deleted the news post!</p> |
48 |
| - <p>Use the navigation to the left to move to another page.</p> |
49 |
| - </section> |
50 |
| -<?php } else { ?> |
51 |
| - <header class="red">Delete News Post</header> |
52 |
| - <section class="red"> |
53 |
| - <p>An error occurred while attempting to delete the news post.</p> |
54 |
| - <p><?php echo $message; ?></p> |
55 |
| - <p>Use the navigation to the left to move to another page.</p> |
56 |
| - </section> |
57 |
| -<?php } ?> |
58 |
| - </article> |
59 |
| -<?php require("./footer.inc.phtml"); ?> |
| 19 | +require('./header.inc.phtml'); ?> |
| 20 | +<div class="container mb-3"> |
| 21 | +<? if (is_null($this->getContext()->error)) { ?> |
| 22 | + <h1 class="text-danger">Delete News Post</h1> |
| 23 | + <form method="POST" action="?id=<?=filter_var($id, FILTER_SANITIZE_FULL_SPECIAL_CHARS)?>"> |
| 24 | + <div class="form-group"> |
| 25 | + <p class="text-danger">Are you sure you wish to delete this news post?</p> |
| 26 | + <div class="card text-light"><div class="card-body"><strong>Title:</strong> <?=filter_var($news_post_title, FILTER_SANITIZE_FULL_SPECIAL_CHARS)?></div></div> |
| 27 | + </div> |
| 28 | + <div class="form-group text-center"> |
| 29 | + <a class="btn btn-primary" href="javascript:history.go(-1);" tabindex="1">Back</a> |
| 30 | + <input class="btn btn-danger" type="submit" value="Delete News Post" tabindex="2" autofocus="autofocus"/> |
| 31 | + </div> |
| 32 | + </form> |
| 33 | +<? } else if ($this->getContext()->error === false) { ?> |
| 34 | + <h1 class="text-success">News Post Deleted</h1> |
| 35 | + <div class="alert alert-success"> |
| 36 | + <p class="mb-0">You have successfully deleted the news post!</p> |
| 37 | + </div> |
| 38 | +<? } else { ?> |
| 39 | + <div class="alert alert-danger"> |
| 40 | + <p>An error occurred while attempting to delete the news post.</p> |
| 41 | + <p class="mb-0"><?=$message?></p> |
| 42 | + </div> |
| 43 | +<? } ?> |
| 44 | +</div> |
| 45 | +<? require('./footer.inc.phtml'); ?> |
0 commit comments