{% load i18n fb_tags fb_versions %}

{% for file in page.object_list %}
    <tr class="{% cycle 'row1' 'row2' %}{% if file.filetype == "Folder" %} fb_folder{% endif %}">
        
        <!-- FILESELECT FOR FILEBROWSEFIELD -->
        {% if query.pop == "1" and results_var.select_total %}
            <td class="fb_icon">
                {% selectable file.filetype query.type %}
                {% if selectable %}
                    <button class="btn btn-success" onclick="FileSubmit('{{ file.url_save }}', '{{ file.url_thumbnail }}', '{{ file.filetype }}');">{% trans "Select" %}</button>
                {% else %}
                    &nbsp;
                {% endif %}
            </td>
        {% endif %}
        
        <!-- FILESELECT FOR RTE/TINYMCE -->
        {% if query.pop == "2" and results_var.select_total %}
            <td class="fb_icon">
                {% selectable file.filetype query.type %}
                {% if selectable %}
                    <button class="btn btn-success" onclick="FileBrowserDialogue.fileSubmit('{{ file.url_save|escapejs }}');">{% trans "Select" %}</button>
                {% else %}
                    &nbsp;
                {% endif %}
            </td>
        {% endif %}
        
        <!-- FILESELECT FOR CKEDITOR (FORMER "FCKEDITOR") -->
        {% if query.pop == "3" and results_var.select_total %}
            <td class="fb_icon">
                {% selectable file.filetype query.type %}
                {% if selectable %}
                    <button class="btn btn-success" onclick="OpenFile(ProtectPath('{{ file.url_full|escapejs }}'));return false;">{% trans "Select" %}</button>
                {% else %}
                    &nbsp;
                {% endif %}
            </td>
        {% endif %}

        <!-- FILESELECT FOR REDACTOR -->
        {% if query.pop == "4" and results_var.select_total %}
            <td class="fb_icon">
                {% selectable file.filetype query.type %}
                {% if selectable %}
                    <!--<button class="btn btn-success" name="redactor-select" onclick="RedactorSubmit('{{ file.url_save }}', '{{ file.url_thumbnail }}', '{{ file.filetype }}');">{% trans "Select" %}</button>-->
                    <button class="btn btn-success" name="redactor-select" data-file="{{ file.url_full }}" data-thumb="{{ file.url_thumbnail }}" data-type="{{ file.filetype }}">{% trans "Select" %}</button>
                {% else %}
                    &nbsp;
                {% endif %}
            </td>
        {% endif %}

        <!-- FILESELECT FOR SIXFOOT -->
        {% if query.pop == "5" and results_var.select_total %}
            <td class="fb_icon">
                {% selectable file.filetype query.type %}
                {% if selectable %}
                    <!--<button class="btn btn-success" name="redactor-select" onclick="RedactorSubmit('{{ file.url_save }}', '{{ file.url_thumbnail }}', '{{ file.filetype }}');">{% trans "Select" %}</button>-->
                    <button class="btn btn-success" name="sixfoot-select" data-file="{{ file.url_full }}" data-thumb="{{ file.url_thumbnail }}" data-type="{{ file.filetype }}">{% trans "Select" %}</button>
                {% else %}
                    &nbsp;
                {% endif %}
            </td>
        {% endif %}

        <!-- FILEICON -->
        <td>
            <img src="{{ settings_var.URL_FILEBROWSER_MEDIA }}img/filebrowser_type_{{ file.filetype|lower }}.gif" />
        </td>
        
        <!-- THUMBNAIL -->
        <td class="fb_thumbnail">
            {% if file.filetype == "Image" %}
                <a href="{{ file.url_full }}" class="fb_viewlink"><img src="{% version file.path settings_var.ADMIN_THUMBNAIL %}" title="{% trans 'View Image' %}" /></a>
            {% endif %}
        </td>
        
        <!-- FILENAME/DIMENSIONS -->
        {% if file.filetype == "Folder" %}
            <td><a href="{% url "fb_browse" %}{% query_string "" "q,dir,p" %}&amp;dir={{ file.path_relative_directory|urlencode }}"><strong>{{ file.filename }}</strong></a></td>
        {% else %}
            <td>
                <b><a href="{{ file.url_full }}">{{ file.filename }}</a></b>
                {% if file.dimensions %}
                    <br /><span class="tiny">{{ file.dimensions.0 }} x {{ file.dimensions.1 }} px</span><br clear="all" />
                {% endif %}
                {% comment %}
                {% if file.filetype == "Image" %}
                    <a class="preview fb_showpreview" href="javascript://" title="{% trans 'Preview' %}">{% trans 'Preview' %}</a>
                    <div class="fb_preview_container">
                        <a href="{{ file.url_full }}" class="fb_view_image external" target="_blank"><span>{% trans 'View Image' %}</span><img src="{% version file.path settings_var.PREVIEW_VERSION %}" title="{% trans 'View Image' %}" class="fb_preview" /></a>
                    </div>
                {% endif %}
                {% endcomment %}
                {% if results_var.images_total and settings_var.ADMIN_VERSIONS and file.filetype == "Image" %}
                    <a class="internal fb_showversions" href="{% url "fb_versions" %}{% query_string "" "p" %}&amp;filename={{ file.filename }}" title="{% trans 'Versions' %}">{% trans 'Versions' %}</a>
                {% endif %}
            </td>
        {% endif %}

          
        <!-- SIZE -->
        <td>{{ file.filesize|filesizeformat }}</td>
        
        <!-- DATE -->
        <td>{{ file.datetime|date:"N j, Y" }}</td>

        <!-- RENAME -->
        <td class="fb_icon">
            <a href="{% url "fb_rename" %}{% query_string %}&amp;filename={{ file.filename }}" class="btn btn-info" title="{% trans 'Rename' %}">
                <i class="icon-pencil icon-white"></i>
            </a>
        </td>

        <!-- DELETE -->
        {% if results_var.delete_total %}
        <td class="fb_icon">
          {% ifnotequal file.filetype 'Folder' %}
          <a href="{% url "fb_delete" %}{% query_string %}&amp;filename={{ file.filename }}&amp;filetype={{ file.filetype }}" class="btn btn-info" onclick="return confirm('{% trans "Are you sure you want to delete this file?" %}');" title="{% trans 'Delete File' %}">
              <i class="icon-trash icon-white"></i>
          </a>
          {% else %}
          {% if file.is_empty %}
          <a href="{% url "fb_delete" %}{% query_string %}&amp;filename={{ file.filename }}&amp;filetype={{ file.filetype }}" class="btn btn-info" onclick="return confirm('{% trans "Are you sure you want to delete this Folder?" %}');" title="{% trans 'Delete Folder' %}">
              <i class="icon-trash icon-white"></i>
          </a>
          {% endif %}
          {% endifnotequal %}
        </td>
        {% endif %}
        
        <!-- DEBUG -->
        {% if settings_var.DEBUG %}
        <td>
            <strong>Filename</strong> {{ file.filename }}<br />
            <strong>Filetype</strong> {{ file.filetype }}<br />
            <strong>Filesize</strong> {{ file.filesize }}<br />
            <strong>Extension</strong> {{ file.extension }}<br />
            <strong>Date</strong> {{ file.date }}<br />
            <strong>Datetime Object</strong> {{ file.datetime }}<br /><br />
            <strong>Relative Path</strong> {{ file.path_relative }}<br />
            <strong>Full Path</strong> {{ file.path_full }}<br />
            <strong>Relative URL</strong> {{ file.url_relative }}<br />
            <strong>Full URL</strong> {{ file.url_full }}<br /><br />
            <strong>URL for FileBrowseField</strong> {{ file.url_save }}<br />
            <strong>Thumbnail URL</strong> {{ file.url_thumbnail }}
            {% if file.filetype == "Image" %}
                <br /><br />
                <strong>Dimensions</strong> {{ file.dimensions }}<br />
                <strong>Width</strong> {{ file.width }}<br />
                <strong>Height</strong> {{ file.height }}<br />
                <strong>Orientation</strong> {{ file.orientation }}
            {% endif %}
            {% if file.filetype == "Folder" %}
                <br /><br />
                <strong>Is Empty</strong> {{ file.is_empty }}
            {% endif %}
        </td>
        {% endif %}
        
    </tr>
{% endfor %}

 
