{% extends 'layout.html.twig' %}

{% block title %}{{'搜索：'|trans}}{% if keywords %}{{ keywords }}{% else %}{{'全部课程'|trans}}{% endif %} - {{ parent() }}{% endblock %}
{% set bodyClass = 'bg-blank' %}

{% do script(['libs/echo-js.js','app/js/search/index.js']) %}

{% block top_content %}
  <div class="course-banner es-banner">
    <div class="container">
      <div class="title">
        <span>{{'搜索'|trans}}</span>{% if app.request.locale == 'zh_CN' %}SEARCH{% endif %}
      </div>
    </div>
  </div>
{% endblock %}

{% block content %}

  <div class="course-filter search-filter" id="course-filter">
    <div class="result-declare">
  {% if keywords %}
    {{'共找到<span>%count%</span>门<span>“%keywords%”</span>相关课程'|trans({'%count%': count, '%keywords%': keywords})|raw}}
  {% else %}
    {{'共找到<span>%count%</span>门课程'|trans({'%count%': count})|raw}}
    {% endif %}
    </div>
    <ul class="nav nav-pills hidden-xs" role="tablist">
      <li role="presentation" class="{% if not filter %}active{% endif %}"><a href="{{ path('search', {q:keywords}) }}">{{'全部课程'|trans}}</a></li>
      {% if isShowVipSearch  %}
        {% if currentUserVipLevel  %}
          <li role="presentation" class="{% if filter == 'vip' %}active{% endif %}">
            <a href="{{ path('search',{filter:'vip', q:keywords}) }}">{{'会员课程'|trans}}</a>
          </li>
        {% endif %}
      {% endif %}
      <li role="presentation" class="{% if filter == 'free' %}active{% endif %}">
          <a href="{{ path('search',{filter:'free', q:keywords}) }}">{{'免费课程'|trans}}</a>
      </li>
      <li role="presentation" class="{% if filter == 'live' %}active{% endif %}">
          <a href="{{ path('search',{filter:'live', q:keywords}) }}">{{'直播课程'|trans}}</a>
      </li>
    </ul>
    <div class="btn-group visible-xs">
      <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown" aria-expanded="false">{{ dict_text('searchCourseType',filter|default('all')) }}
      <span class="caret"></span></button>

      <ul class="dropdown-menu" role="menu">
        <li role="presentation" class="{% if not filter %}active{% endif %}"><a href="{{ path('search') }}">{{'全部课程'|trans}}</a></li>
        {% if isShowVipSearch  %}
            {% if currentUserVipLevel  %}
              <li role="presentation" class="{% if filter == 'vip' %}active{% endif %}">
                <a href="{{ path('search',{filter:'vip'}) }}">{{'会员课程'|trans}}</a>
              </li>
          {% endif %}
        {% endif %}
        <li role="presentation" class="{% if filter == 'free' %}active{% endif %}">
            <a href="{{ path('search',{filter:'free'}) }}">{{'免费课程'|trans}}</a>
        </li>
        <li role="presentation" class="{% if filter == 'live' %}active{% endif %}">
            <a href="{{ path('search',{filter:'live'}) }}">{{'直播课程'|trans}}</a>
        </li>
      </ul>
    </div>

  </div>

  <!-- 课程列表 -->
  <div class="course-list">
    {% if courseSets %}
      <div class="row">
        {% for courseSet in courseSets %}
          <div class="col-lg-3 col-md-4 col-xs-6">
            {% include 'course/widgets/course-grid.html.twig' with { courseSet: courseSet} %}
          </div>
        {% endfor %}
      </div>
    {% else %}
      <div class="empty">{{'没有搜到相关课程，请换个关键词试试！'|trans}}</div>
    {% endif %}
  </div>

  <nav class="text-center">
    {% if courseSets %}
    {{ web_macro.paginator(paginator) }}
    {% endif %}
  </nav>

{% endblock %}