Skip to content

Commit

Permalink
Some visuals improvements for the forum.
Browse files Browse the repository at this point in the history
  • Loading branch information
ngodfraind committed Feb 11, 2015
1 parent 4a887e1 commit b607010
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 21 deletions.
8 changes: 5 additions & 3 deletions Controller/ForumController.php
Original file line number Diff line number Diff line change
Expand Up @@ -949,12 +949,14 @@ public function replyMessageAction(Message $message)
{
$subject = $message->getSubject();
$forum = $subject->getCategory()->getForum();
$form = $this->container->get('form.factory')->create(new MessageType, new Message());
$reply = new Message();
$reply->setContent($this->manager->getMessageQuoteHTML($message));
$form = $this->container->get('form.factory')->create(new MessageType, $reply);
$form->handleRequest($this->get('request'));

if ($form->isValid()) {
$newMsg = $form->getData();
$this->manager->replyMessage($newMsg, $message);
$reply = $form->getData();
$this->manager->replyMessage($reply, $message);

return new RedirectResponse(
$this->generateUrl('claro_forum_messages', array('subject' => $subject->getId()))
Expand Down
30 changes: 18 additions & 12 deletions Manager/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -545,21 +545,27 @@ public function copy(Forum $forum)
return $newForum;
}

public function replyMessage(Message $message, Message $oldMessage)
public function getMessageQuoteHTML(Message $message)
{
// todo: this should be in a template...
$mask = '<div class="well"><div class="original-poster">%s :</div>%s</div>%s';
$oldAuthor = $oldMessage->getCreator()->getFirstName()
$answer = $this->translator->trans('answer_message', array(), 'forum');
$author = $message->getCreator()->getFirstName()
. ' '
. $oldMessage->getCreator()->getLastName();
$message->setContent(
sprintf(
$mask,
$oldAuthor,
$oldMessage->getContent(),
$message->getContent()
)
. $message->getCreator()->getLastName();
$date = $message->getCreationDate()->format($this->translator->trans('date_range.format.with_hours', array(), 'platform'));
$by = $this->translator->trans('posted_by', array('%author%' => $author, '%date%' => $date), 'forum');
$mask = '<div class="original-poster"><b>' . $by . '</b></div><div class="well">%s</div></div>' . $answer . ':</div>';

return sprintf(
$mask,
$message->getContent()
);
}

public function replyMessage(Message $message, Message $oldMessage)
{
// todo: this should be in a template...
$html = $this->getMessageQuoteHTML($oldMessage) . $message->getContent();
$message->setContent($html);
$this->createMessage($message, $oldMessage->getSubject());
}

Expand Down
3 changes: 3 additions & 0 deletions Resources/translations/forum.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ notifications_explanation: Global notifications will send a mail to each user wh
activate_global_notifications: Activate global notifications
disable_global_notifications: Disable global notifications
responses: Replies
answer_message: Reply
posted_by: Posted by %author% the %date%
fast_reply: Fast reply
3 changes: 3 additions & 0 deletions Resources/translations/forum.es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,6 @@ notifications_explanation: Cuando se agrega un mensaje, la activación de las no
activate_global_notifications: Activar las notificaciones globales
disable_global_notifications: Anular las notificaciones globales
responses: Respuestas
answer_message: Respuesta
posted_by: Iniciado por %author% el %date%
fast_reply: Veloz respuesta
3 changes: 3 additions & 0 deletions Resources/translations/forum.fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,6 @@ notifications_explanation: L'activation des notifications globales entraîne l'e
activate_global_notifications: Activer les notifications globales
disable_global_notifications: Annuler les notifications globales
responses: Réponses
answer_message: Réponse
posted_by: Posté par %author% le %date%
fast_reply: Réponse rapide
13 changes: 9 additions & 4 deletions Resources/views/Forum/messages.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@
{% if creator.isEnabled() %}
<a href="{{ path('claro_public_profile_view', {'publicUrl': creator.getPublicUrl()}) }}">
{% endif %}

{{ message.getAuthor() }}
{% if creator.isEnabled() %}

{% if creator.isEnabled() %}
</a>
{% endif %}
</div>
Expand Down Expand Up @@ -130,8 +130,10 @@
</table>
<div>
{{ renderPager(subject.getId(), pager, max) }}
<btn id='fast-reply-btn' class='btn btn-primary pull-right'>{{ 'fast_reply'|trans({}, 'forum')}}</btn>
</div>
{% if canAnswer %}
<div class="fast-reply" style="display: none;">
<h4><i class="fa fa-reply"></i> {{ 'new_message' | trans({}, 'forum') }}</h4>
<div>
{% if not subject.isClosed() %}
Expand All @@ -140,6 +142,7 @@
{% endif %}
</div>
{% endif %}
</div>
</div>
<div class="panel-footer clearfix">
<div class="pull-right">
Expand Down Expand Up @@ -228,7 +231,9 @@
{'subject': {{ subject.getId()}}, 'max': $(this).val()}
);
});
$('body').on('click', '#fast-reply-btn', function() {
$('.fast-reply').show();
});
</script>
{% endif %}
{% endblock %}

11 changes: 9 additions & 2 deletions Resources/views/Forum/replyMessageForm.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
<div class="panel-heading">
<h3 class="panel-title">{{ 'reply_message'|trans({}, 'forum') }}</h3>
</div>
<div class="well"> {{ message.getContent()|raw }} </div>
{% form_theme form 'ClarolineCoreBundle::form_theme.html.twig' %}
<form novalidate="novalidate" action="{{ path('claro_forum_reply_message_form', {'message': message.getId()}) }}" method="post" {{ form_enctype(form) }} id="message_form">
<div class="panel-body">
Expand All @@ -29,4 +28,12 @@
<a class="btn btn-default" href="{{ path('claro_forum_messages', {'subject': subject.getId()}) }}">{{ 'cancel' | trans({}, 'platform' )}}</a>
</div>
</form>
{% endblock %}
{% endblock %}

{% block javascripts %}
{{ parent() }}
<script>
window.tinymce.activeEditor.selection.select(tinyMCE.activeEditor.getBody(), true);
window.tinymce.activeEditor.selection.collapse(false);
</script>
{% endblock %}

0 comments on commit b607010

Please sign in to comment.