diff --git a/Controller/ForumController.php b/Controller/ForumController.php index aa6ed92..1afbb42 100644 --- a/Controller/ForumController.php +++ b/Controller/ForumController.php @@ -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())) diff --git a/Manager/Manager.php b/Manager/Manager.php index fd250c3..41e475e 100644 --- a/Manager/Manager.php +++ b/Manager/Manager.php @@ -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 = '
%s :
%s
%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 = '
' . $by . '
%s
' . $answer . ':'; + + 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()); } diff --git a/Resources/translations/forum.en.yml b/Resources/translations/forum.en.yml index 8b17e2b..0361c13 100644 --- a/Resources/translations/forum.en.yml +++ b/Resources/translations/forum.en.yml @@ -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 diff --git a/Resources/translations/forum.es.yml b/Resources/translations/forum.es.yml index 4e96255..b47aa97 100644 --- a/Resources/translations/forum.es.yml +++ b/Resources/translations/forum.es.yml @@ -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 diff --git a/Resources/translations/forum.fr.yml b/Resources/translations/forum.fr.yml index 2cf49cf..188aa05 100644 --- a/Resources/translations/forum.fr.yml +++ b/Resources/translations/forum.fr.yml @@ -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 diff --git a/Resources/views/Forum/messages.html.twig b/Resources/views/Forum/messages.html.twig index 0869b1a..4923585 100644 --- a/Resources/views/Forum/messages.html.twig +++ b/Resources/views/Forum/messages.html.twig @@ -88,10 +88,10 @@ {% if creator.isEnabled() %} {% endif %} - + {{ message.getAuthor() }} - - {% if creator.isEnabled() %} + + {% if creator.isEnabled() %} {% endif %} @@ -130,8 +130,10 @@
{{ renderPager(subject.getId(), pager, max) }} + {{ 'fast_reply'|trans({}, 'forum')}}
{% if canAnswer %} +