{% set page_title = _("Forums") %}

{% extends theme("management/management_layout.html") %}

{% block breadcrumb %}
<ol class="breadcrumb flaskbb-breadcrumb">
    <li><a href="{{ url_for('forum.index') }}">{% trans %}Forum{% endtrans %}</a></li>
    <li><a href="{{ url_for('management.overview') }}">{% trans %}Management{% endtrans %}</a></li>
    <li class="active">{% trans %}Forums{% endtrans %}</li>
</ol>
{% endblock %}

{% block management_content %}
{% from theme('macros.html') import render_pagination, navlink with context %}

<div class="col-md-3 settings-col">
    <div class="nav-sidebar">
        <ul class="nav">
        {{ navlink('management.forums', _("Manage Forums")) }}
        {{ navlink('management.add_forum', _("Add Forum")) }}
        {{ navlink('management.add_category', _("Add Category")) }}
        </ul>
    </div>
</div>

<div class="col-md-9 settings-col with-left-border">
    <div class="panel settings-panel">
        <div class="panel-heading settings-head">
            <span class="fa fa-comments"></span> {% trans %}Manage Forums{% endtrans %}
        </div>
        <div class="panel-body settings-body">
            <div class="settings-content">
                {% for category in categories %}
                <div class="panel category-panel">
                    <div class="panel-heading category-head">
                        <div class="row">
                            <div class="col-md-12">
                                <div class="pull-left">
                                    <a href="{{ category.url }}"><strong>{{ category.title }}</strong></a>
                                </div>
                                <div class="pull-right">
                                    <a class="btn btn-xs btn-default" href="{{ url_for('management.add_forum', category_id=category.id) }}">
                                        <span class="fa fa-plus"></span> {% trans %}Add Forum{% endtrans %}
                                    </a>
                                    <a class="btn btn-xs btn-success" href="{{ url_for('management.edit_category', category_id = category.id) }}">
                                        <span class="fa fa-pencil"></span> {% trans %}Edit Category{% endtrans %}
                                    </a>
                                    <form class="inline-form" method="post" action="{{ url_for('management.delete_category', category_id=category.id) }}">
                                        <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
                                        <button class="btn btn-xs btn-danger" name="confirmDialog">
                                            <span class="fa fa-trash"></span> {% trans %}Delete Category{% endtrans %}
                                        </button>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="panel-body category-body">
                        <div class="category-meta">
                            <div class="col-md-5 col-sm-5 col-xs-8 forum-name">{% trans %}Forum{% endtrans %}</div>
                            <div class="col-md-2 col-sm-2 hidden-xs forum-stats">{% trans %}Topics / Posts{% endtrans %}</div>
                            <div class="col-md-5 col-sm-5 col-xs-4 forum-last-post"></div>
                        </div>
                        {% for forum in category.forums %}
                        <div class="row category-row hover">

                            {% if forum.external %}
                            <div class="col-md-5 col-sm-5 col-xs-8 forum-info">
                                <div class="row">
                                    <!-- Icon -->
                                    <div class="col-md-1 col-sm-2 col-xs-2 forum-status">
                                        <span class="fa fa-external-link forum-external"></span>
                                    </div>

                                    <div class="col-md-11 col-sm-10 col-xs-10">
                                        <!-- Forum Name -->
                                        <div class="forum-name">
                                            <span class="forum-link">{% trans %}Link to{% endtrans %}:</span> <a href="{{ forum.url }}">{{ forum.title }}</a>
                                        </div>

                                        <!-- Forum Description -->
                                        <div class="forum-description">
                                            {{ forum.description|markup }}
                                        </div>
                                    </div>
                                </div>
                            </div> <!-- end forum-info -->

                            <!-- Post Count -->
                            <div class="col-md-2 col-sm-2 hidden-xs forum-posts">
                                - -
                            </div>

                            <!-- Forum Actions -->
                            <div class="col-md-5 col-sm-5 col-xs-4 forum-last-post">
                                <div class="forum-actions pull-right">
                                    <a class="btn btn-sm btn-success" href="{{ url_for('management.edit_forum', forum_id = forum.id) }}">
                                        <span class="fa fa-pencil"></span> {% trans %}Edit Link{% endtrans %}
                                    </a>

                                    <form class="inline-form" method="post" action="{{ url_for('management.delete_forum', forum_id=forum.id) }}">
                                        <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
                                        <button class="btn btn-sm btn-danger" name="confirmDialog">
                                            <span class="fa fa-trash"></span> {% trans %}Delete Link{% endtrans %}
                                        </button>
                                    </form>
                                </div>
                            </div>
                            {% else %}
                            <div class="col-md-5 col-sm-5 col-xs-8 forum-info">
                                <div class="row">
                                    <!-- Icon -->
                                    <div class="col-md-1 col-sm-2 col-xs-2 forum-status">
                                        {% if forum.locked %}
                                            <span class="fa fa-lock forum-locked"></span>
                                        {% else %}
                                            <span class="fa fa-comments-o forum-read"></span>
                                        {% endif %}
                                    </div>

                                    <div class="col-md-11 col-sm-10 col-xs-10">
                                        <!-- Forum Name -->
                                        <div class="forum-name">
                                            <a href="{{ forum.url }}">{{ forum.title }}</a>
                                        </div>

                                        <!-- Forum Description -->
                                        <div class="forum-description">
                                            {{ forum.description|markup }}
                                        </div>

                                        <!-- Forum Moderators -->
                                        {% if forum.show_moderators %}
                                        <div class="forum-moderators">
                                            {% trans %}Moderators{% endtrans %}:
                                            {% for moderator in forum.moderators %}
                                            <a href="{{ url_for('user.profile', username=moderator.username) }}">{{ moderator.username }}</a>{% if not loop.last %}, {% endif %}
                                            {% endfor %}
                                        </div>
                                        {% endif %}
                                    </div>
                                </div>
                            </div> <!-- end forum-info -->

                            <!-- Post Count -->
                            <div class="col-md-2 col-sm-2 hidden-xs forum-topics">
                                {{ forum.topic_count }} / {{ forum.post_count }}
                            </div>

                            <!-- Forum Actions -->
                            <div class="col-md-5 col-sm-5 col-xs-4 forum-last-post">
                                <div class="forum-actions pull-right">
                                    <a class="btn btn-sm btn-primary" href="{{ url_for('management.edit_forum', forum_id = forum.id) }}">
                                        <span class="fa fa-pencil"></span> {% trans %}Edit Forum{% endtrans %}
                                    </a>

                                    <form class="inline-form" method="post" action="{{ url_for('management.delete_forum', forum_id=forum.id) }}">
                                        <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
                                        <button class="btn btn-sm btn-danger" name="confirmDialog">
                                            <span class="fa fa-trash"></span> {% trans %}Delete Forum{% endtrans %}
                                        </button>
                                    </form>
                                </div>
                            </div>

                        {% endif %} {# endif forum.external #}
                        </div> <!-- end category-content -->

                        {% endfor %}
                    </div>
                </div>
                {% endfor %}
            </div>
        </div>
    </div>
</div>
{% include theme('confirm_dialog.html') %}
{% endblock %}
