|
1 | | -<?php |
2 | | - |
| 1 | +<?php /* vim: set colorcolumn=: */ |
3 | 2 | namespace BNETDocs\Templates\Document; |
4 | | - |
5 | 3 | use \BNETDocs\Libraries\Document; |
6 | 4 | use \BNETDocs\Libraries\User; |
7 | 5 | use \CarlBennett\MVC\Libraries\Common; |
8 | 6 | use \CarlBennett\MVC\Libraries\Pair; |
9 | | - |
10 | | -$title = 'Document Index'; |
11 | | -$description = 'The index for documents on BNETDocs'; |
| 7 | +$title = 'All Documents'; |
| 8 | +$description = 'This page is an index for all of the document pages on BNETDocs'; |
12 | 9 | $this->opengraph->attach(new Pair('url', '/document/index')); |
13 | | - |
14 | 10 | $order = $this->getContext()->order; |
15 | | - |
16 | | -require('./header.inc.phtml'); |
17 | | -?> |
18 | | - <article> |
19 | | - <header>Document Index</header> |
20 | | - <section> |
21 | | - <form method="GET"> |
22 | | - <label for="order">Order by:</label> |
23 | | - <select name="order" id="order" onchange="form.submit();" |
24 | | - style="display:inline-block;width:200px;"> |
25 | | - <option value="created-asc"<?php |
26 | | - if ($order === 'created-asc') { echo ' selected="selected"'; |
27 | | - } ?>>Created (Ascending)</option> |
28 | | - <option value="created-desc"<?php |
29 | | - if ($order === 'created-desc') { echo ' selected="selected"'; |
30 | | - } ?>>Created (Descending)</option> |
31 | | - <option value="id-asc"<?php |
32 | | - if ($order === 'id-asc') { echo ' selected="selected"'; |
33 | | - } ?>>Id (Ascending)</option> |
34 | | - <option value="id-desc"<?php |
35 | | - if ($order === 'id-desc') { echo ' selected="selected"'; |
36 | | - } ?>>Id (Descending)</option> |
37 | | - <option value="title-asc"<?php |
38 | | - if ($order === 'title-asc') { echo ' selected="selected"'; |
39 | | - } ?>>Title (Ascending)</option> |
40 | | - <option value="title-desc"<?php |
41 | | - if ($order === 'title-desc') { echo ' selected="selected"'; |
42 | | - } ?>>Title (Descending)</option> |
43 | | - <option value="updated-asc"<?php |
44 | | - if ($order === 'updated-asc') { echo ' selected="selected"'; |
45 | | - } ?>>Updated (Ascending)</option> |
46 | | - <option value="updated-desc"<?php |
47 | | - if ($order === 'updated-desc') { echo ' selected="selected"'; |
48 | | - } ?>>Updated (Descending)</option> |
49 | | - <option value="user-id-asc"<?php |
50 | | - if ($order === 'user-id-asc') { echo ' selected="selected"'; |
51 | | - } ?>>User Id (Ascending)</option> |
52 | | - <option value="user-id-desc"<?php |
53 | | - if ($order === 'user-id-desc') { echo ' selected="selected"'; |
54 | | - } ?>>User Id (Descending)</option> |
55 | | - </select> |
56 | | - <input type="submit" value="Reorder"/> |
57 | | - </form> |
58 | | - <table> |
59 | | - <thead> |
60 | | - <tr> |
61 | | - <th class="left">Found <?php echo number_format($this->getContext()->sum_documents); ?> document<?php echo ($this->getContext()->sum_documents != 1 ? "s" : ""); ?></th> |
62 | | - <th class="left">Author</th> |
63 | | - </tr> |
64 | | - </thead><tbody> |
| 11 | +require('./header.inc.phtml'); ?> |
| 12 | +<div class="container mb-3"> |
| 13 | + <h2><?=$title?></h2> |
| 14 | + <p><?=$description?></p> |
| 15 | + <form method="GET" class="m-2" id="order_by_form"> |
| 16 | + <label for="order">Order by:</label> |
| 17 | + <select class="form-control form-control-sm" name="order" id="order" onchange="form.submit();" |
| 18 | + style="display:inline-block;width:200px;"> |
| 19 | + <option value="created-asc"<?php |
| 20 | + if ($order === 'created-asc') { echo ' selected="selected"'; |
| 21 | + } ?>>Created (Ascending)</option> |
| 22 | + <option value="created-desc"<?php |
| 23 | + if ($order === 'created-desc') { echo ' selected="selected"'; |
| 24 | + } ?>>Created (Descending)</option> |
| 25 | + <option value="id-asc"<?php |
| 26 | + if ($order === 'id-asc') { echo ' selected="selected"'; |
| 27 | + } ?>>Id (Ascending)</option> |
| 28 | + <option value="id-desc"<?php |
| 29 | + if ($order === 'id-desc') { echo ' selected="selected"'; |
| 30 | + } ?>>Id (Descending)</option> |
| 31 | + <option value="title-asc"<?php |
| 32 | + if ($order === 'title-asc') { echo ' selected="selected"'; |
| 33 | + } ?>>Title (Ascending)</option> |
| 34 | + <option value="title-desc"<?php |
| 35 | + if ($order === 'title-desc') { echo ' selected="selected"'; |
| 36 | + } ?>>Title (Descending)</option> |
| 37 | + <option value="updated-asc"<?php |
| 38 | + if ($order === 'updated-asc') { echo ' selected="selected"'; |
| 39 | + } ?>>Updated (Ascending)</option> |
| 40 | + <option value="updated-desc"<?php |
| 41 | + if ($order === 'updated-desc') { echo ' selected="selected"'; |
| 42 | + } ?>>Updated (Descending)</option> |
| 43 | + <option value="user-id-asc"<?php |
| 44 | + if ($order === 'user-id-asc') { echo ' selected="selected"'; |
| 45 | + } ?>>User Id (Ascending)</option> |
| 46 | + <option value="user-id-desc"<?php |
| 47 | + if ($order === 'user-id-desc') { echo ' selected="selected"'; |
| 48 | + } ?>>User Id (Descending)</option> |
| 49 | + </select> |
| 50 | + <input class="btn btn-sm btn-secondary" type="submit" value="Reorder"/> |
| 51 | + </form> |
| 52 | + <table class="table table-hover table-striped" id="docs_tbl"> |
| 53 | + <thead> |
| 54 | + <tr> |
| 55 | + <th class="left">Found <?php echo number_format($this->getContext()->sum_documents); ?> document<?php echo ($this->getContext()->sum_documents != 1 ? "s" : ""); ?></th> |
| 56 | + <th class="left">Author</th> |
| 57 | + </tr> |
| 58 | + </thead><tbody> |
65 | 59 | <?php foreach ($this->getContext()->documents as $document) { |
66 | | - $user = $document->getUser(); |
67 | | - if ($user) { |
68 | | - $user_url = $user->getURI(); |
69 | | - $avatar_url = $user->getAvatarURI(22); |
70 | | - } |
| 60 | +$user = $document->getUser(); |
| 61 | +if ($user) { |
| 62 | + $user_url = $user->getURI(); |
| 63 | + $avatar_url = $user->getAvatarURI(22); |
| 64 | +} |
71 | 65 | ?> |
72 | | - <tr> |
73 | | - <td><strong><a href="<?php echo $document->getURI(); ?>"><?php echo filter_var($document->getTitle(), FILTER_SANITIZE_STRING); ?></a></strong><br/><span style="color:#aaa;"><?php echo rtrim(Common::stripUpTo(Common::stripUpTo(trim(filter_var($document->getContent(true), FILTER_SANITIZE_STRING)), "\n", 90), ". ", 90), "."); ?></span></td> |
74 | | - <td><?php if ($user) { ?><a href="<?php echo $user_url; ?>"><img class="avatar" src="<?php echo $avatar_url; ?>"/> <?php echo filter_var($user->getName(), FILTER_SANITIZE_STRING); ?></a><?php } else { ?>Anonymous<?php } ?></td> |
75 | | - </tr> |
| 66 | + <tr> |
| 67 | + <td><strong><a href="<?php echo $document->getURI(); ?>"><?php echo filter_var($document->getTitle(), FILTER_SANITIZE_STRING); ?></a></strong><br/><span style="color:#aaa;"><?php echo rtrim(Common::stripUpTo(Common::stripUpTo(trim(filter_var($document->getContent(true), FILTER_SANITIZE_STRING)), "\n", 90), ". ", 90), "."); ?></span></td> |
| 68 | + <td><?php if ($user) { ?><a href="<?php echo $user_url; ?>"><img class="avatar" src="<?php echo $avatar_url; ?>"/> <?php echo filter_var($user->getName(), FILTER_SANITIZE_STRING); ?></a><?php } else { ?>Anonymous<?php } ?></td> |
| 69 | + </tr> |
76 | 70 | <?php } ?> |
77 | | - </tbody></table> |
78 | | - </section> |
79 | | - </article> |
| 71 | + </tbody></table> |
| 72 | +</div> |
| 73 | +<?php ob_start(); ?> |
| 74 | + <script type="text/javascript"> |
| 75 | + $(document).ready(function(){ |
| 76 | + $('#order_by_form').hide(); |
| 77 | + $('#docs_tbl').DataTable({ |
| 78 | + "responsive": true |
| 79 | + }); |
| 80 | + }); |
| 81 | + </script> |
| 82 | +<? $_footer_script = ob_get_clean(); require('./footer.inc.phtml'); ?> |
0 commit comments