diff options
Diffstat (limited to 'src/application/views')
-rw-r--r-- | src/application/views/form_search.php | 28 | ||||
-rw-r--r-- | src/application/views/nav_guest.php | 1 | ||||
-rw-r--r-- | src/application/views/nav_logged_in.php | 1 | ||||
-rw-r--r-- | src/application/views/view_search_results.php | 33 |
4 files changed, 63 insertions, 0 deletions
diff --git a/src/application/views/form_search.php b/src/application/views/form_search.php new file mode 100644 index 0000000..edc68b8 --- /dev/null +++ b/src/application/views/form_search.php @@ -0,0 +1,28 @@ +<?php + +use mystic\forum\utils\RequestUtils; + +$lastFormUri = ""; +$lastForm = RequestUtils::getLastForm($lastFormUri) ?? []; +if ($lastFormUri !== $_SERVER["REQUEST_URI"]) $lastForm = []; +RequestUtils::clearLastForm(); + +?> +<div class="page-header margin-top-0"> + <h1><?= __("Search") ?></h1> +</div> +<?php +if (($_formError = RequestUtils::getAndClearFormError()) !== null) { + _view("alert_error", ["message" => $_formError]); +} +?> +<form action="<?= htmlentities($_SERVER["REQUEST_URI"]) ?>" method="post"> + <div class="form-group"> + <div class="input-group"> + <input class="form-control" type="search" id="i_query" name="query" value="<?= htmlentities($lastForm["query"] ?? $query ?? "") ?>" required autofocus> + <div class="input-group-btn"> + <button class="btn btn-primary" type="submit"><?= __("Search") ?></button> + </div> + </div> + </div> +</form> diff --git a/src/application/views/nav_guest.php b/src/application/views/nav_guest.php index 1c65a50..88c551b 100644 --- a/src/application/views/nav_guest.php +++ b/src/application/views/nav_guest.php @@ -1,4 +1,5 @@ <ul class="nav navbar-nav navbar-right"> +<li<?= $GLOBALS["action"] === "search" ? ' class="active"' : '' ?>><a href="?_action=search"><span class="glyphicon glyphicon-search" aria-hidden="true"></span><span class="sr-only"><?= __("Search") ?></span></a></li> <li<?= $GLOBALS["action"] === "auth" ? ' class="active"' : '' ?>><a href="?_action=auth&next=<?= htmlentities(urlencode($_SERVER["REQUEST_URI"])) ?>"><?= __("Log in") ?></a></li> <?php if (REGISTRATION_ENABLED): ?> <li<?= $GLOBALS["action"] === "register" ? ' class="active"' : '' ?>><a href="?_action=register&next=<?= htmlentities(urlencode($_SERVER["REQUEST_URI"])) ?>"><?= __("Register") ?></a></li> diff --git a/src/application/views/nav_logged_in.php b/src/application/views/nav_logged_in.php index 39c65cb..0f77f90 100644 --- a/src/application/views/nav_logged_in.php +++ b/src/application/views/nav_logged_in.php @@ -6,6 +6,7 @@ use mystic\forum\orm\User; "user" => ($user->id === User::SUPERUSER_ID) ? ('<strong class="text-danger">' . htmlentities($user->displayName) . '</strong>') : ('<strong>' . htmlentities($user->displayName) . '</strong>') ]) ?> </p></li> +<li<?= $GLOBALS["action"] === "search" ? ' class="active"' : '' ?>><a href="?_action=search"><span class="glyphicon glyphicon-search" aria-hidden="true"></span><span class="sr-only"><?= __("Search") ?></span></a></li> <li><a href="?_action=viewuser&user=<?= htmlentities(urlencode($user->id)) ?>"><span class="glyphicon glyphicon-user" aria-hidden="true"></span><span class="sr-only">View profile</span></a></li> <li><a href="?_action=logout&next=<?= htmlentities(urlencode($_SERVER["REQUEST_URI"])) ?>"><span class="glyphicon glyphicon-log-out" aria-hidden="true"></span><span class="sr-only">Log out</span></a></li> </ul> diff --git a/src/application/views/view_search_results.php b/src/application/views/view_search_results.php new file mode 100644 index 0000000..19a6978 --- /dev/null +++ b/src/application/views/view_search_results.php @@ -0,0 +1,33 @@ +<?php +use mystic\forum\utils\StringUtils; +?> + +<?php if (count($posts) > 0): ?> + <p><?= __("%result_count% result(s) in %search_duration% second(s)", [ + "result_count" => count($posts), + "search_duration" => number_format($search_duration, 2, __(".", context: "Number formatting"), __(",", context: "Number formatting")), + ]) ?></p> + <div class="list-group margin-top"> + <?php foreach ($posts as $post): + if ($post->deleted) continue; + $hasAttachments = count($attachments[$post->id]) > 0; + ?> + <a href="?_action=viewtopic&topic=<?= htmlentities(urlencode($post->topicId)) ?>#post-<?= htmlentities(urlencode($post->id)) ?>" class="list-group-item"> + <?php if ($hasAttachments): ?> + <span class="badge"><span class="glyphicon glyphicon-paperclip"></span></span> + <?php endif; ?> + <?= htmlentities(StringUtils::truncate(strip_tags(renderPost($post->content)), 100)) ?><br> + <span class="text-muted"><?= __("posted by %author% on %post_date% in %topic%", [ + "author" => '<em>' . htmlentities($users[$post->authorId]?->displayName ?? __("unknown")) . '</em>', + "post_date" => '<span class="_time">' . htmlentities($post->postDate->format("c")) . '</span>', + "topic" => '<em>' . htmlentities($topics[$post->topicId]?->title ?? "unknown") . '</em>', + ]) ?></span> + </a> + <?php endforeach; ?> + </div> +<?php else: ?> + <div class="well icon-well text-info margin-top margin-bottom"> + <span class="glyphicon glyphicon-info-sign color-info" aria-hidden="true"></span> + <em><?= __("No results for this search") ?></em> + </div> +<?php endif; ?> |