{#

 This file is part of the FOSCommentBundle package.

 (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>

 This source file is subject to the MIT license that is bundled
 with this source code in the file LICENSE.

#}

{% set depth = depth|default(0) %}
{% set view = view|default('tree') %}

{% if depth == 0 %}
    {% if fos_comment_can_comment_thread(thread) %}
        {% render url("fos_comment_new_thread_comments", {"id": thread.id}) %}
    {% endif %}

    {% if fos_comment_can_edit_thread(thread) %}
        <div class="fos_comment_thread_commentable">
            <button data-url="{{ url('fos_comment_edit_thread_commentable', {'id': thread.id, 'value': not thread.commentable}) }}" class="fos_comment_thread_commentable_action">
                {{ (thread.commentable ? 'fos_comment_thread_close' : 'fos_comment_thread_open') | trans({}, 'FOSCommentBundle') }}
            </button>
        </div>
    {% endif %}

    {% set count = thread.numComments %}
    <h3 class="panel-title">{% transchoice count with {'%count%': count} from "FOSCommentBundle" %}fos_comment_thread_comment_count{% endtranschoice %}</h3>
{% endif %}

{% for commentinfo in comments %}
    {% if not commentinfo.comment.private %}
        {% include "FOSCommentBundle:Thread:comment.html.twig" with { "children": commentinfo.children, "comment": commentinfo.comment, "depth": depth, "view": view } %}
    {% endif %}
{% endfor %}
