{% extends "base.html" %}
{% load i18n %}
{% load static %}
{% load thumbnail %}

{% block title %}{{block.super}} &gt; {% trans 'Marked Renkans list' %}{% endblock %}

{% block css_import %}
{{block.super}}
    <link rel="stylesheet" type="text/css" href="{% static 'hdalab/css/index.css' %}" />
    <link rel="stylesheet" type="text/css" href="{% static 'hdalab/css/ui-lightness/jquery-ui-1.10.4.min.css' %}" />
    <link rel="stylesheet" type="text/css" href="{% static 'hdalab/css/profile.css' %}" />
{% endblock %}

{% block renkans_actif %}{% if not hide_favorite %}actif{% endif %}{% endblock %}

{% block js_import %}
{{block.super}}
<script src="{% static 'hdalab/lib/jquery-ui-1.10.4.min.js' %}"></script>
<script src="{% static 'hdalab/js/renkan-search.js' %}"></script>
<script type="text/javascript">
    var favorite = {{favorite}};
    initSearch(favorite);
</script>
{% endblock %}

{% block main_content %}
	<div class="all-title">
            {% block main_content_title %}<h1>{% trans 'Public Renkans list' %}</h1>&nbsp;<h2><a href="{% url 'renkan_favorite_list' %}">{% trans 'Marked Renkans list' %}</a></h2>{% endblock %}            
            <div id="new_renkan">{% block new_renkan %}
            <form action="{% url 'renkan_new' %}" method="post">{% csrf_token %}
            <p>{% blocktrans %}
            Consultez des cartes de connaissances sur les arts et 
            <button id="new-renkan-button" title="Nouveau Renkan" class="renkan-inline-action"><span id="new-renkan">créez vos propres cartes</span></button>
            à partir des ressources Histoire des arts et Wikipedia.
            {% endblocktrans %}
            </p>
            </form>
            {% endblock %}</div>
    </div>
    
    <p class="inline">{% if page.has_previous %}<a href="?page={{ page.previous_page_number }}&sort={{ sort_param }}&order={{ order_param }}{{ filters }}" >{% trans 'Previous' %}</a>{% endif %}
       {% if page.has_previous and page.has_next %} - {% endif %}{% if page.has_next %}<a href="?page={{ page.next_page_number }}&sort={{ sort_param }}&order={{ order_param }}{{ filters }}">{% trans 'Next' %}</a>{% endif %}</p>
    <form class="inline"><p>{% if page.has_previous or page.has_next %} - {% endif %}{% trans 'Filter' %} : <input type="text" name="title" value="{{ title }}"/> - <span class="hand_cursor" id="toggle-search">{% trans 'Advanced search' %}</span></p></p></form>
    <form id="advanced-form" style="display: {% if startdate != '' or enddate != '' or username != '' or state != '' %}block{% else %}none{% endif %};">
      <p>{% trans 'Title' %} : <input type="text" name="title" value="{{ title }}"/></p>
      <p>{% trans 'Modification date' %} : {% trans 'begin' %} <input type="text" name="startdate" value="{{ startdate }}" class="date" /> -
                                           {% trans 'end' %} : <input type="text" name="enddate" value="{{ enddate }}" class="date" /></p>
      {% if show_username %}
      <p>{% trans 'Username' %} : <input type="text" name="username" value="{{ username }}"/></p>
      {% endif %}
      {% if not hide_favorite %}
      <p>{% trans 'Favorite' %} : <input type="checkbox" id="filter-favorite-chkbx" {% if favorite >= 1 %} checked="checked" {% endif %} value="{{favorite}}" /><input type="hidden" id="filter-favorite" name="favorite" value="{{favorite}}"/></p>
      {% endif %}
      <p><input type="submit" value="{% trans 'Search' %}"/></p>
    </form>
    <table id="rk-table">
      <thead>
        <tr class="border_bottom">
          <th><a class="" href="?sort=title&order={% if sort_param == 'title' %}{{ opposite }}{% else %}asc{% endif %}{{ filters }}">{% trans 'Title' %}</a>
              {% if sort_param == 'title' %}<span class="ui-icon {% if opposite == 'asc' %}ui-icon-triangle-1-s{% else %}ui-icon-triangle-1-n{% endif %}"></span>{% endif %}</th>
          {% if not hide_favorite %}
          <th><a href="?sort=favorite&order={% if sort_param == 'favorite' %}{{ opposite }}{% else %}desc{% endif %}{{ filters }}">{% trans 'Fav.' %}</a>
              {% if sort_param == 'favorite' %}<span class="ui-icon {% if opposite == 'asc' %}ui-icon-triangle-1-s{% else %}ui-icon-triangle-1-n{% endif %}"></span>{% endif %}</th>
          {% endif %}
          {% if show_username %}
          <th><a href="?sort=user&order={% if sort_param == 'user' %}{{ opposite }}{% else %}desc{% endif %}{{ filters }}">{% trans 'User' %}</a>
              {% if sort_param == 'user' %}<span class="ui-icon {% if opposite == 'asc' %}ui-icon-triangle-1-s{% else %}ui-icon-triangle-1-n{% endif %}"></span>{% endif %}</th>
          {% endif %}
          <th><a href="?sort=date&order={% if sort_param == 'date' %}{{ opposite }}{% else %}desc{% endif %}{{ filters }}">{% trans 'Modification date' %}</a>
              {% if sort_param == 'date' %}<span class="ui-icon {% if opposite == 'asc' %}ui-icon-triangle-1-s{% else %}ui-icon-triangle-1-n{% endif %}"></span>{% endif %}</th>
          <th>Preview</th><th>Actions</th></tr>
      </thead>
      <tbody>
      {% for hr in page.object_list %}
       {% with hr.renkan as r %}
        <tr class="border_bottom">
            <td><div class="renkan-list-title-div"><a title="{% trans 'View renkan' %}" href="{% url 'renkan_view' %}?rk_id={{ r.rk_id }}">{{ r.title }}</a></div></td>
            {% if not hide_favorite %}
            <td>{% if hr.favorite %}<span class="publish-renkan">&nbsp;</span>{% else %}&nbsp;{% endif %}</td>
            {% endif %}
            {% if show_username %}
            <td>{{ r.owner.username }}</td>
            {% endif %}
            <td>{{ r.modification_date|date:"Y-m-d H:i" }}</td>
            <td>{% thumbnail r.image 100x100 as thumb %}<img src="{{ thumb.url }}" width="{{ thumb.width }}" height="{{ thumb.height }}" /></td>
            <td class="renkan_list_actions">
                <a title="{% trans 'View renkan' %}" href="{% url 'renkan_view' %}?rk_id={{ r.rk_id }}" class="renkan-basic-action"><span class="ui-icon ui-icon-eye"></span></a>
                <form action="{% url 'renkan_copy' rk_id=r.rk_id %}" method="post">
                    {% csrf_token %}
                    <input type="hidden" name="next" value="{% url 'profile_home' %}" />
                    <button title="Copy renkan" class="renkan-basic-action" onclick="return confirm('{% trans "Are you sure you want to copy this renkan ?" %}');" ><span class="ui-icon ui-icon-copy"></span></button>
                </form>
            </td>
        </tr>
       {% endwith %}
      {% endfor %}
      </tbody>
    </table>
    <p>{% if page.has_previous %}<a href="?page={{ page.previous_page_number }}&sort={{ sort_param }}&order={{ order_param }}{{ filters }}" >{% trans 'Previous' %}</a>{% endif %}
       {% if page.has_previous and page.has_next %} - {% endif %}{% if page.has_next %}<a href="?page={{ page.next_page_number }}&sort={{ sort_param }}&order={{ order_param }}{{ filters }}">{% trans 'Next' %}</a>{% endif %}</p>
{% endblock %}