{% load i18n %}

<div id="filebrowser"
     style="min-width:800px">
    <h1>{% trans "Files" %}</h1>

    <div style="padding-bottom:10px">
        <table width="100%">
            <tr>
                <td>
                    <span>{% trans "Your are here" %}:</span>
                    <a class="fb-obj"
                       href="{% url 'lfc_filebrowser' %}?obj_id=">{% trans "Portal" %}</a>

                    {% for obj in objs %}
                        &gt;
                        <a class="fb-obj"
                           href="{% url 'lfc_filebrowser' %}?obj_id={{ obj.id }}">{{ obj.title }}</a>
                    {% endfor %}
                </td>
                <td align="right">
                    <a class="fb-obj"
                       href="{% url 'lfc_filebrowser' %}?obj_id={{ current_id }}">{% trans "Current Object" %}</a>
                </td>
            </tr>
        </table>
    </div>

    <table class="lfs-manage-table" width="100%">
        <tr>
            <td width="200px">
                <table width="100%">
                    <tr>
                        <th>
                            {% trans "Type" %}
                        </th>
                    </tr>
                    <tr>
                        <td>
                            <div>
                                <a class="content-form-link"
                                   href=".">{% trans "Content" %}</a>
                            </div>
                            <div>
                                <a class="extern-form-link"
                                   href=".">{% trans "Extern" %}</a>
                            </div>
                            <div>
                                <a class="email-form-link"
                                   href=".">{% trans "Mail" %}</a>
                            </div>
                        </td>
                    </tr>
                </table>
            </td>

            <td width="350px">

                {#  Mail #}
                <table width="100%"
                       class="email-form">
                    <tr>
                        <th colspan="2">
                            {% trans "E-Mail" %}
                        </th>
                    </tr>
                    <tr>
                        <td>
                           <form>
                               <label>{% trans "E-mail" %}</label>
                               <input class="fb-email" type="text" {% if mail_url %}value="{{ mail_url }}"{% endif %} />
                           </form>
                       </td>
                    </tr>
                </table>

                <table width="100%"
                       class="extern-form">
                    <tr>
                        <th>
                            {% trans "External Link" %}
                        </th>
                    </tr>
                    <tr>
                        <td>
                           <form>
                               <select class="fb-extern-protocol" style="width:80px">
                                   <option>http://</option>
                                   <option>https://</option>
                               </select>
                               <input class="fb-extern" type="text" {% if external_url %}value="{{ external_url }}"{% endif %} />
                           </form>
                       </td>
                    </tr>
                </table>

                {# Content #}
                <table width="100%"
                       class="content-form">
                    <tr>
                        <th colspan="2" width="300px">
                            {% trans "Content" %}
                        </th>
                    </tr>
                    {% if children %}
                        <tr>
                            <td colspan="2">
                                {% trans "Children" %}
                            </td>
                        </tr>
                    {% endif %}
                    {% for child in children %}
                        <tr>
                            <td width="10px">
                                <input class="child" name="child" value="{{ child.url }}" type="radio" {% if child.checked %}checked="checked"{% endif %}/>
                            </td>
                            <td>
                                <div>
                                    {% if child.display %}
                                        <a class="fb-obj"
                                           href="{% url 'lfc_filebrowser' %}?obj_id={{ child.id }}">{{ child.title }} {{ child.display }}</a>
                                    {% else %}
                                        <span class="fb-obj">{{ child.title }}</a>
                                    {% endif %}
                                </div>
                            </td>
                        </tr>
                    {% endfor %}
                    {% if files %}
                        <tr>
                            <td colspan="2">
                                {% trans "Files" %}
                            </td>
                        </tr>
                    {% endif %}
                    {% for file in files %}
                        <tr>
                            <td width="10px">
                                <input class="child" name="child" value="{{ file.url }}" type="radio" {% if file.checked %}checked="checked"{% endif %} />
                            </td>
                            <td valign="top">
                                {{ file.title }}
                            </td>
                        </tr>
                    {% endfor %}
                    {% if images %}
                        <tr>
                            <td colspan="2">
                                {% trans "Images" %}
                            </td>
                        </tr>
                    {% endif %}
                    {% for image in images %}
                        <tr>
                            <td width="10px">
                                <input class="child" name="child" value="{{ image.url }}" type="radio" {% if image.checked %}checked="checked"{% endif %} />
                            </td>
                            <td valign="top">
                                {{ image.title }}
                            </td>
                        </tr>
                    {% endfor %}
                </table>
            </td>
            <td>
                <table>
                    <tr>
                        <th>
                            {% trans "Attributes" %}
                        </th>
                    </tr>
                    <tr>
                        <td>
                            <div>
                                <label>{% trans "Title" %}</label>
                            </div>
                            <input id="fb-title" type="text" name="title" {% if title %}value="{{ title }}"{% endif %}/>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <div>
                                <label>{% trans "Target" %}</label>
                            </div>
                            <select id="fb-target">
                                <option value="_self" {% ifequal target "_self"  %}selected="selected"{% endifequal %}>{% trans "Same window" %}</option>
                                <option value="_blank" {% ifequal target "_blank"  %}selected="selected"{% endifequal %}>{% trans "New window" %}</option>
                            </select>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    <div class="right">
        <input type="button" value='{% trans "Insert" %}' id="insert-file" />
    </div>

    <h1>{% trans "Upload file to" %} {{ current_obj.title }}</h1>
    {% if display_upload %}
        <form action="{% url 'lfc_fb_upload_file' %}"
              method="post"
              enctype="multipart/form-data">
            {% csrf_token %}
            <input type="hidden" name="obj_id" value="{{ obj_id }}">
            <input type="file" name="image" />
            <input class="ajax-submit"
                   type="submit" />
        </form>
    {% else %}
        {% trans "You have to save content object before you can upload images for it." %}
    {% endif %}
</div>
