summaryrefslogtreecommitdiff
path: root/src/application/templates/bootstrap-3/search.twig
blob: c8f63151cafba918ab3bcfe0fa99b2ab460cbc91 (plain)
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
{% set title = __("Search") %}
{% set formId = "search" %}
{% set formError = getAndClearFormError(formId) %}

{% extends "base.twig" %}

{% block content %}

<div class="page-header margin-top-0">
    <h1>{{ __("Search") }}</h1>
</div>

{% if formError %}
    {% include "components/alert_error.twig" with { message: formError } %}
{% endif %}

<form action="." method="get">
    <input type="hidden" name="form_id" value="{{ formId }}">
    <input type="hidden" name="_action" value="search">
    <div class="form-group">
        <div class="input-group">
            <input class="form-control" type="search" id="i_query" name="query" value="{{ lastFormField(formId, "query")|default(g.get.query)|default("") }}" required autofocus placeholder="{{ __("Enter your search query...") }}">
            <div class="input-group-btn">
                <button class="btn btn-primary" type="submit">{{ __("Search") }}</button>
            </div>
        </div>
    </div>
</form>

{% if g.get.query is defined and g.get.query is not null and g.get.query != "" %}
    {% if ctx.posts|length > 0 %}
        <p>{{ __("%result_count% result(s) in %search_duration% second(s)", {
            "result_count": ctx.posts|length,
            "search_duration": ctx.search_duration|number_format(2, __(".", context: "Number formatting"), __(",", context: "Number formatting")),
        }) }}</p>
        <div class="list-group margin-top">
            {% for post in ctx.posts|filter(p => not p.deleted) %}
                {% set hasAttachments = ctx.attachments[post.id]|length > 0 %}
                {% set postAuthor = ctx.users[post.authorId] %}
                <a href="?_action=viewtopic&amp;topic={{ post.topicId|url_encode }}#post-{{ post.id|url_encode }}" class="list-group-item">
                    {% if hasAttachments %}
                        <span class="badge"><span class="fa fa-paperclip"></span></span>
                    {% endif %}
                    {{ renderPostSummary(post.content) }}<br>
                    <span class="text-muted">{{ __("posted by %author% on %post_date% in %topic%", {
                        "author": '<em>' ~ (postAuthor ? postAuthor.displayName : __("unknown"))|e("html") ~ '</em>',
                        "post_date": '<span class="_time">' ~ post.postDate.format("c")|e("html") ~ '</span>',
                        "topic": '<em>'
                            ~ (topics[post.topicId].isLocked ? '<span class="fa fa-lock text-muted" aria-hidden="true"></span> ' : '')
                            ~ (topics[post.topicId] ? topics[post.topicId].title : null)|default("unknown")|e("html") ~ '</em>',
                    }) }}</span>
                </a>
            {% endfor %}
        </div>
    {% else %}
        <div class="well icon-well text-info margin-top margin-bottom">
            <span class="fa fa-info-circle text-info" aria-hidden="true"></span>
            <em>{{ __("No results for this search") }}</em>
        </div>
    {% endif %}
{% endif %}

{% endblock %}