Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'refactor-comment-template'

  • Loading branch information...
commit 9dee16807866e47ec447db2e08ccbff204e72a94 2 parents 6bf810e + 6ff632d
@asm89 asm89 authored
View
1  Resources/translations/FOSCommentBundle.en.yml
@@ -20,3 +20,4 @@ fos_comment_rss_feed: RSS Feed
fos_comment_thread_close: Close thread
fos_comment_thread_open: Open thread
+fos_comment_thread_comment_count: %count% comment|%count% comments
View
38 Resources/views/Thread/comment.html.twig
@@ -12,40 +12,4 @@
{% set view = view|default('tree') %}
{% set depth = depth|default(0) %}
-<div id="fos_comment_{{ comment.id }}" class="fos_comment_comment_show fos_comment_comment_depth_{{ depth }}" {% if parentId is defined %}data-parent="{{ parentId }}"{% endif %}>
- <div class="fos_comment_comment_metas">
- {% trans from 'FOSCommentBundle' %}fos_comment_comment_show_by{% endtrans %} {{ comment.authorName }} - {{ comment.createdAt|date }}
- {% if fos_comment_can_edit_comment(comment) %}
- <button data-url="{{ url("fos_comment_edit_thread_comment", {"id": comment.thread.id, "commentId": comment.id}) }}" class="fos_comment_comment_edit_show_form">Edit</button>
- {% endif %}
- {% 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="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="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 %}
- </div>
- <div class="fos_comment_comment_body">
- {% if comment is fos_comment_raw %}
- {{ comment.rawBody | raw }}
- {% else %}
- {{ comment.body | nl2br }}
- {% endif %}
- </div>
-
- {% if view is not sameas('flat') %}
- <div class="fos_comment_comment_replies">
- {% if fos_comment_can_comment(comment) %}
- <div class="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="fos_comment_comment_reply_show_form">{% trans from 'FOSCommentBundle' %}fos_comment_comment_show_reply{% endtrans %}</button>
- </div>
- {% endif %}
- {% if children is defined %}
- {% include "FOSCommentBundle:Thread:comments.html.twig" with { "comments": children, "depth": depth + 1, "parentId": comment.id, "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, "parentId": comment.id, "view": view } %}
- {% endif %}
-</div>
+{% include "FOSCommentBundle:Thread:comment_content.html.twig" %}
View
72 Resources/views/Thread/comment_content.html.twig
@@ -0,0 +1,72 @@
+{#
+
+ 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="fos_comment_comment_show fos_comment_comment_depth_{{ depth }}" {% if parentId is defined %}data-parent="{{ parentId }}"{% 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">{{ comment.authorName }}</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-url="{{ url("fos_comment_edit_thread_comment", {"id": comment.thread.id, "commentId": comment.id}) }}" class="fos_comment_comment_edit_show_form">Edit</button>
+ {% endif %}
+ {% endblock fos_comment_comment_metas_edit %}
+
+ {% 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="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="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 class="fos_comment_comment_body">
+ {% block fos_comment_comment_body %}
+ {% if comment is fos_comment_raw %}
+ {{ comment.rawBody | raw }}
+ {% else %}
+ {{ comment.body | nl2br }}
+ {% endif %}
+ {% endblock fos_comment_comment_body %}
+ </div>
+
+ {% block fos_comment_comment_children %}
+ {% if view is not sameas('flat') %}
+ <div class="fos_comment_comment_replies">
+
+ {% 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="fos_comment_comment_reply_show_form">{% trans from 'FOSCommentBundle' %}fos_comment_comment_show_reply{% endtrans %}</button>
+ {% endblock fos_comment_comment_reply %}
+ </div>
+ {% endif %}
+
+ {% if children is defined %}
+ {% include "FOSCommentBundle:Thread:comments.html.twig" with { "comments": children, "depth": depth + 1, "parentId": comment.id, "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, "parentId": comment.id, "view": view } %}
+ {% endif %}
+ {% endblock fos_comment_comment_children %}
+
+</div>
+{% endblock fos_comment_comment %}
View
45 Resources/views/Thread/comment_new.html.twig
@@ -11,44 +11,9 @@
{% set first = first|default(false) %}
-<div class="fos_comment_comment_form_holder">
- {% block fos_comment_form_title %}
- {% if first %}
- <h3>{% trans from 'FOSCommentBundle' %}fos_comment_comment_new_headline_first{% endtrans %}</h3>
- {% elseif parent is not null %}
- <h3>{% trans with {"%name%": parent.authorName } from 'FOSCommentBundle' %}fos_comment_comment_reply_reply_to{% endtrans %}</h3>
- {% else %}
- <h3>{% trans from 'FOSCommentBundle' %}fos_comment_comment_new_headline{% endtrans %}</h3>
- {% endif %}
- {% endblock %}
+{% set url_parameters = {'id': id } %}
+{% if parent is not null %}
+ {% set url_parameters = url_parameters|merge({'parentId': parent.id}) %}
+{% endif %}
- {% set url_parameters = {'id': id } %}
- {% if parent is not null %}
- {% set url_parameters = url_parameters|merge({'parentId': parent.id}) %}
- {% endif %}
-
- <form class="fos_comment_comment_new_form" action="{{ url('fos_comment_post_thread_comments', url_parameters) }}" data-parent="{{ parent.id|default() }}" method="POST">
-
- {% block fos_comment_form_fields %}
- <div class="fos_comment_form_errors">
- {{ form_errors(form) }}
- </div>
- <div class="fos_comment_form_errors">
- {{ form_errors(form.body) }}
- </div>
- {{ form_widget(form.body) }}
-
- {{ form_rest(form) }}
- {% endblock %}
-
- <div class="fos_comment_submit">
- {% block fos_comment_form_submit %}
- {% if parent is not null %}
- <input type="button" value="{% trans from 'FOSCommentBundle' %}fos_comment_comment_reply_cancel{% endtrans %}" class="fos_comment_comment_reply_cancel" />
- {% endif %}
- <input type="submit" value="{% trans from 'FOSCommentBundle' %}fos_comment_comment_new_submit{% endtrans %}" />
- {% endblock %}
- </div>
-
- </form>
-</div>
+{% include "FOSCommentBundle:Thread:comment_new_content.html.twig" %}
View
53 Resources/views/Thread/comment_new_content.html.twig
@@ -0,0 +1,53 @@
+{#
+
+ 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_form_holder %}
+ <div class="fos_comment_comment_form_holder">
+ {% block fos_comment_form_title %}
+ {% if first %}
+ <h3>{% trans from 'FOSCommentBundle' %}fos_comment_comment_new_headline_first{% endtrans %}</h3>
+ {% elseif parent is not null %}
+ <h3>{% trans with {"%name%": parent.authorName } from 'FOSCommentBundle' %}fos_comment_comment_reply_reply_to{% endtrans %}</h3>
+ {% else %}
+ <h3>{% trans from 'FOSCommentBundle' %}fos_comment_comment_new_headline{% endtrans %}</h3>
+ {% endif %}
+ {% endblock %}
+
+
+ {% block fos_comment_comment_new_form %}
+ <form class="fos_comment_comment_new_form" action="{{ url('fos_comment_post_thread_comments', url_parameters) }}" data-parent="{{ parent.id|default() }}" method="POST">
+
+ {% block fos_comment_form_fields %}
+ <div class="fos_comment_form_errors">
+ {{ form_errors(form) }}
+ </div>
+ <div class="fos_comment_form_errors">
+ {{ form_errors(form.body) }}
+ </div>
+ {{ form_widget(form.body) }}
+
+ {{ form_rest(form) }}
+ {% endblock %}
+
+ <div class="fos_comment_submit">
+ {% block fos_comment_form_submit %}
+ {% if parent is not null %}
+ <input type="button" value="{% trans from 'FOSCommentBundle' %}fos_comment_comment_reply_cancel{% endtrans %}" class="fos_comment_comment_reply_cancel" />
+ {% endif %}
+ <input type="submit" value="{% trans from 'FOSCommentBundle' %}fos_comment_comment_new_submit{% endtrans %}" />
+ {% endblock %}
+ </div>
+
+ </form>
+ {% endblock fos_comment_comment_new_form %}
+
+ </div>
+{% endblock fos_comment_comment_form_holder %}
View
3  Resources/views/Thread/comments.html.twig
@@ -24,6 +24,9 @@
</button>
</div>
{% endif %}
+
+ {% set count = thread.numComments %}
+ <h3>{% transchoice count with {'%count%': count} from "FOSCommentBundle" %}fos_comment_thread_comment_count{% endtranschoice %}</h3>
{% endif %}
{% for commentinfo in comments %}
Please sign in to comment.
Something went wrong with that request. Please try again.