{#

 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.

#}

{% block fos_comment_comment %}
    <div id="fos_comment_{{ comment.id }}" class="panel-body fos_comment_comment_show fos_comment_comment_depth_{{ depth }}" {% if parent is defined and parent is not null %}data-parent="{{ parent.id }}"{% endif %}>

        <div class="fos_comment_comment_metas">
            {% block fos_comment_comment_metas %}
                {% block fos_comment_comment_metas_authorline %}
                    {% trans from 'FOSCommentBundle' %}fos_comment_comment_show_by{% endtrans %}
                    <span class="fos_comment_comment_authorname">
                    {% if comment is fos_comment_in_state(constant('FOS\\CommentBundle\\Model\\CommentInterface::STATE_DELETED')) %}
                        {% trans from 'FOSCommentBundle' %}fos_comment_comment_deleted{% endtrans %}
                    {% else %}
                        {{ comment.authorName }}
                    {% endif %}
                </span> - {{ comment.createdAt|date }}
                {% endblock fos_comment_comment_metas_authorline %}

                {% block fos_comment_comment_metas_edit %}
                    {% if fos_comment_can_edit_comment(comment) %}
                        <button data-container="#fos_comment_comment_body_{{ comment.id }}" data-url="{{ url("fos_comment_edit_thread_comment", {"id": comment.thread.id, "commentId": comment.id}) }}" class="fos_comment_comment_edit_show_form">{% trans from 'FOSCommentBundle' %}fos_comment_comment_edit{% endtrans %}</button>
                    {% endif %}
                {% endblock fos_comment_comment_metas_edit %}

                {% block fos_comment_comment_metas_delete %}
                    {% if fos_comment_can_delete_comment(comment) %}
                        {% if comment is fos_comment_in_state(constant('FOS\\CommentBundle\\Model\\CommentInterface::STATE_DELETED')) %}
                            {# undelete #}
                            <button data-url="{{ url("fos_comment_remove_thread_comment", {"id": comment.thread.id, "commentId": comment.id, "value": constant('FOS\\CommentBundle\\Model\\CommentInterface::STATE_VISIBLE') }) }}" class="btn btn-default fos_comment_comment_remove">{% trans from 'FOSCommentBundle' %}fos_comment_comment_undelete{% endtrans %}</button>
                        {% else %}
                            {# delete #}
                            <button data-url="{{ url("fos_comment_remove_thread_comment", {"id": comment.thread.id, "commentId": comment.id, "value":  constant('FOS\\CommentBundle\\Model\\CommentInterface::STATE_DELETED')}) }}" class="btn btn-default fos_comment_comment_remove">{% trans from 'FOSCommentBundle' %}fos_comment_comment_delete{% endtrans %}</button>
                        {% endif %}
                    {% endif %}
                {% endblock fos_comment_comment_metas_delete %}

                {% block fos_comment_comment_metas_voting %}
                    {% if fos_comment_can_vote(comment) %}
                        <div class="fos_comment_comment_voting">
                            <button data-url="{{ url("fos_comment_new_thread_comment_votes", {"id": comment.thread.id, "commentId": comment.id, "value": 1}) }}" class="btn btn-default fos_comment_comment_vote">{% trans from 'FOSCommentBundle' %}fos_comment_comment_show_voteup{% endtrans %}</button>
                            <button data-url="{{ url("fos_comment_new_thread_comment_votes", {"id": comment.thread.id, "commentId": comment.id, "value": -1}) }}" class="btn btn-default fos_comment_comment_vote">{% trans from 'FOSCommentBundle' %}fos_comment_comment_show_votedown{% endtrans %}</button>
                            <div class="fos_comment_comment_score" id="fos_comment_score_{{ comment.id }}">{% include "FOSCommentBundle:Thread:comment_votes.html.twig" with { 'commentScore': comment.score } %}</div>
                        </div>
                    {% endif %}
                {% endblock fos_comment_comment_metas_voting %}
            {% endblock fos_comment_comment_metas %}
        </div>

        <div id="fos_comment_comment_body_{{ comment.id }}" class="fos_comment_comment_body">
            {% block fos_comment_comment_body %}
                {% if comment is fos_comment_in_state(constant('FOS\\CommentBundle\\Model\\CommentInterface::STATE_DELETED')) %}
                    {% trans from 'FOSCommentBundle' %}fos_comment_comment_deleted{% endtrans %}
                {% else %}
                    {% if comment.note %}
                        <p>{{ 'sonata_comment_note_given'|trans({}, 'SonataCommentBundle') }}{{ comment.note }}</p>
                    {% endif %}

                    {% if comment is fos_comment_raw %}
                        {{ comment.rawBody | raw }}
                    {% else %}
                        {{ comment.body | nl2br }}
                    {% endif %}
                {% endif %}
            {% endblock fos_comment_comment_body %}
        </div>

        {% block fos_comment_comment_children %}
            {% if view is not sameas('flat') %}
                {% if fos_comment_can_comment(comment) %}
                    <div class="fos_comment_comment_reply">
                        {% block fos_comment_comment_reply %}
                            <button data-url="{{ url('fos_comment_new_thread_comments', {"id": comment.thread.id}) }}" data-name="{{ comment.authorName }}" data-parent-id="{{ comment.id }}" class="btn btn-primary fos_comment_comment_reply_show_form">{% trans from 'FOSCommentBundle' %}fos_comment_comment_show_reply{% endtrans %}</button>
                        {% endblock fos_comment_comment_reply %}
                    </div>
                {% endif %}

                <div class="col-sm-offset-1 fos_comment_comment_replies">

                    {% if children is defined %}
                        {% include "FOSCommentBundle:Thread:comments.html.twig" with { "comments": children, "depth": depth + 1, "parent": comment, "view": view } %}
                    {% endif %}

                </div>
            {% elseif view is sameas('flat') and children is defined %}
                {% include "FOSCommentBundle:Thread:comments.html.twig" with { "comments": children, "depth": depth + 1, "parent": comment, "view": view } %}
            {% endif %}
        {% endblock fos_comment_comment_children %}

    </div>
{% endblock fos_comment_comment %}
