Quote thread posts from LP - refs BT#9892 #TMI

Angel Fernando Quiroz Campos 11 years ago
parent a0de1f5f62
commit a3c59f54a2
  1. 2
      main/forum/viewthread.php
  2. 28
      main/inc/ajax/forum.ajax.php
  3. 26
      main/template/games/forum/flat_learnpath.tpl

@ -189,7 +189,7 @@ if ($my_message != 'PostDeletedSpecial') {
'#', '#',
'reply', 'reply',
'default', 'default',
['id' => 'btn-reply-thread'] ['class' => 'btn-reply-post']
); );
} }
// new thread link // new thread link

@ -151,6 +151,7 @@ if (!empty($action)) {
break; break;
case 'reply_form': case 'reply_form':
$parentPostId = isset($_REQUEST['post']) ? intval($_REQUEST['post']) : 0; $parentPostId = isset($_REQUEST['post']) ? intval($_REQUEST['post']) : 0;
$quotePost = isset($_REQUEST['action']) && $_REQUEST['action'] == 'quote';
$form = new FormValidator('form_reply'); $form = new FormValidator('form_reply');
$form->addHidden('thread', $current_thread['thread_id']); $form->addHidden('thread', $current_thread['thread_id']);
@ -189,6 +190,33 @@ if (!empty($action)) {
$form->addHidden('sec_token', Security::get_token()); $form->addHidden('sec_token', Security::get_token());
if ($parentPostId > 0 && $quotePost) {
$parentPost = get_post_information($parentPostId);
$parentPostText = Display::tag('p', null);
$parentPostText .= Display::tag(
'div',
Display::tag(
'div',
Display::tag(
'blockquote',
Display::tag(
'p',
sprintf(
get_lang('QuotingToXUser'),
api_get_person_name($parentPost['firstname'], $parentPost['lastname'])
)
) . prepare4display($parentPost['post_text'])
)
)
);
$parentPostText .= Display::tag('p', null);
$form->setDefaults([
'post_text' => $parentPostText
]);
}
$json['error'] = false; $json['error'] = false;
$json['form'] = $form->returnForm(); $json['form'] = $form->returnForm();
break; break;

@ -1,14 +1,15 @@
<script> <script>
var replyForm = { var replyForm = {
parentPostId: 0, parentPostId: 0,
show: function() { show: function(action) {
$('#form_reply').remove(); $('#form_reply').remove();
var getForm = $.getJSON('{{ _p.web_ajax }}forum.ajax.php?{{ _p.web_cid_query }}', { var getForm = $.getJSON('{{ _p.web_ajax }}forum.ajax.php?{{ _p.web_cid_query }}', {
a: 'reply_form', a: 'reply_form',
post: replyForm.parentPostId, post: replyForm.parentPostId,
forum: parseInt({{ forum.forum_id }}), forum: parseInt({{ forum.forum_id }}),
thread: parseInt({{ thread_id }}) thread: parseInt({{ thread_id }}),
action: action
}); });
$.when(getForm).done(function(response) { $.when(getForm).done(function(response) {
@ -31,13 +32,22 @@
}; };
$(document).on('ready', function() { $(document).on('ready', function() {
$('.btn-reply-post, #btn-reply-thread').on('click', function(e) { $('.btn-reply-post').on('click', function(e) {
e.preventDefault(); e.preventDefault();
var replyToPost = $(this).data('reply-to') || 0; var parentPostId = $(this).data('parent-post') || 0;
replyForm.parentPostId = parseInt(replyToPost); replyForm.parentPostId = parseInt(parentPostId);
replyForm.show(); replyForm.show('reply');
});
$('.btn-quote-post').on('click', function(e) {
e.preventDefault();
var parentPostId = $(this).data('parent-post') || 0;
replyForm.parentPostId = parseInt(parentPostId);
replyForm.show('quote');
}); });
$('body').on('submit', '#form_reply', function(e) { $('body').on('submit', '#form_reply', function(e) {
@ -92,11 +102,11 @@
</div> </div>
<div class="tools-disqus"> <div class="tools-disqus">
{% if allow_reply %} {% if allow_reply %}
<a data-reply-to="{{ post.post_id }}" href="#" class="btn btn-primary btn-xs reply-disqus btn-reply-post"> <a data-parent-post="{{ post.post_id }}" href="#" class="btn btn-primary btn-xs reply-disqus btn-reply-post">
<i class="fa fa-reply"></i> {{ "Reply"|get_lang }} <i class="fa fa-reply"></i> {{ "Reply"|get_lang }}
</a> </a>
<a href="reply.php?{{ _p.web_cid_query ~ '&' ~ {'forum': forum.forum_id, 'thread': thread_id, 'post': post.post_id, 'action': 'quote'}|url_encode }}" class="btn btn-success btn-xs quote-disqus"> <a data-parent-post="{{ post.post_id }}" href="#" class="btn btn-success btn-xs quote-disqus btn-quote-post">
<i class="fa fa-quote-left"></i> {{ "Quote"|get_lang }} <i class="fa fa-quote-left"></i> {{ "Quote"|get_lang }}
</a> </a>
{% endif %} {% endif %}

Loading…
Cancel
Save