summaryrefslogtreecommitdiff
path: root/src/application/templates/old/search.twig
blob: 0bdd497f5442dd5c757a6c71338f52519d5e02c0 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{% set title = __("Search") %}
{% set formId = "search" %}
{% set formError = getAndClearFormError(formId) %}

{% extends "base.twig" %}

{% block content %}

<hr color="silver" noshade>
<h1>{{ __("Search") }}</h1>

{% 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">
    <table border="1" cellspacing="0" cellpadding="4" bordercolor="silver" width="100%">
    <tr>
    <td width="100%">
        <input class="fw" type="search" id="i_query" name="query" value="{{ lastFormField(formId, "query")|default(g.get.query)|default("") }}" required placeholder="{{ __("Enter your search query...") }}">
    </td>
    <td>
    <nobr>
        <button type="submit">{{ __("Search") }}</button>
    </nobr>
    </td>
    </tr>
    </table>
</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>

        {% for post in ctx.posts|filter(p => not p.deleted) %}
            {% set hasAttachments = ctx.attachments[post.id]|length > 0 %}
            {% set postAuthor = ctx.users[post.authorId] %}
            <font size="2"><b><a href="?_action=viewtopic&amp;topic={{ post.topicId|url_encode }}#post-{{ post.id|url_encode }}">{{ renderPostSummary(post.content) }}</a></b></font><br>
            {{ __("posted by %author% on %post_date% in %topic%", {
                "author": '<b>' ~ (postAuthor ? postAuthor.displayName : __("unknown"))|e("html") ~ '</b>',
                "post_date": '<br><span class="_time">' ~ post.postDate.format("c")|e("html") ~ '</span>',
                "topic": '<br><font color="green">'
                    ~ (ctx.topics[post.topicId].isLocked ? ('<img src="/ui/theme-files/old/lock_small.gif" class="inline-icon" width="10" height="10" draggable="false" alt="' ~ __("This topic has been locked") ~ '"> ') : '')
                    ~ (ctx.topics[post.topicId] ? ctx.topics[post.topicId].title : null)|default(__("unknown"))|e("html") ~ '</font>',
            }) }}
            <br><br>
        {% endfor %}
    {% else %}
        <hr color="silver" noshade>
        <table cellspacing="0" cellpadding="4" bgcolor="lightskyblue" border="1" bordercolor="skyblue">
        <tr><td>
            <img src="/ui/theme-files/old/information.gif" border="0" alt="" width="16" height="16" draggable="false" class="inline-icon">&nbsp;{#
            #}{{ __("No results for this search") }}
        </td></tr>
        </table>
        <br>
    {% endif %}
{% endif %}

{% endblock %}


{% block scripts %}
{{ parent() }}
{% if not (g.get.query is defined and g.get.query is not null and g.get.query != "") %}
<script type="text/javascript">
$(function() {
    $("#i_query").focus();
});
</script>
{% endif %}
{% endblock %}