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',
'default',
['id' => 'btn-reply-thread']
['class' => 'btn-reply-post']
);
}
// new thread link

@ -151,6 +151,7 @@ if (!empty($action)) {
break;
case 'reply_form':
$parentPostId = isset($_REQUEST['post']) ? intval($_REQUEST['post']) : 0;
$quotePost = isset($_REQUEST['action']) && $_REQUEST['action'] == 'quote';
$form = new FormValidator('form_reply');
$form->addHidden('thread', $current_thread['thread_id']);
@ -189,6 +190,33 @@ if (!empty($action)) {
$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['form'] = $form->returnForm();
break;

@ -1,14 +1,15 @@
<script>
var replyForm = {
parentPostId: 0,
show: function() {
show: function(action) {
$('#form_reply').remove();
var getForm = $.getJSON('{{ _p.web_ajax }}forum.ajax.php?{{ _p.web_cid_query }}', {
a: 'reply_form',
post: replyForm.parentPostId,
forum: parseInt({{ forum.forum_id }}),
thread: parseInt({{ thread_id }})
thread: parseInt({{ thread_id }}),
action: action
});
$.when(getForm).done(function(response) {
@ -31,13 +32,22 @@
};
$(document).on('ready', function() {
$('.btn-reply-post, #btn-reply-thread').on('click', function(e) {
$('.btn-reply-post').on('click', function(e) {
e.preventDefault();
var replyToPost = $(this).data('reply-to') || 0;
var parentPostId = $(this).data('parent-post') || 0;
replyForm.parentPostId = parseInt(replyToPost);
replyForm.show();
replyForm.parentPostId = parseInt(parentPostId);
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) {
@ -92,11 +102,11 @@
</div>
<div class="tools-disqus">
{% 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 }}
</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 }}
</a>
{% endif %}

Loading…
Cancel
Save