예제 #1
0
if (qa_using_categories() && count($categories)) {
    $field = array('label' => qa_lang_html('question/q_category_label'), 'error' => qa_html(@$errors['categoryid']));
    qa_set_up_category_field($qa_content, $field, 'category', $categories, $in['categoryid'], true, qa_opt('allow_no_sub_category'));
    if (!qa_opt('allow_no_category')) {
        // don't auto-select a category even though one is required
        $field['options'][''] = '';
    }
    qa_array_insert($qa_content['form']['fields'], 'content', array('category' => $field));
}
if (qa_opt('extra_field_active')) {
    $field = array('label' => qa_html(qa_opt('extra_field_prompt')), 'tags' => 'name="extra"', 'value' => qa_html(@$in['extra']), 'error' => qa_html(@$errors['extra']));
    qa_array_insert($qa_content['form']['fields'], null, array('extra' => $field));
}
if (qa_using_tags()) {
    $field = array('error' => qa_html(@$errors['tags']));
    qa_set_up_tag_field($qa_content, $field, 'tags', isset($in['tags']) ? $in['tags'] : array(), array(), qa_opt('do_complete_tags') ? array_keys($completetags) : array(), qa_opt('page_size_ask_tags'));
    qa_array_insert($qa_content['form']['fields'], null, array('tags' => $field));
}
if (!isset($userid)) {
    qa_set_up_name_field($qa_content, $qa_content['form']['fields'], @$in['name']);
}
qa_set_up_notify_fields($qa_content, $qa_content['form']['fields'], 'Q', qa_get_logged_in_email(), isset($in['notify']) ? $in['notify'] : qa_opt('notify_users_default'), @$in['email'], @$errors['email']);
if ($captchareason) {
    require_once 'qa-app-captcha.php';
    qa_set_up_captcha_field($qa_content, $qa_content['form']['fields'], @$errors, qa_captcha_reason_note($captchareason));
}
$qa_content['focusid'] = 'title';
return $qa_content;
/*
	Omit PHP closing tag to help avoid accidental output
*/
예제 #2
0
function qa_page_q_add_c_form(&$qa_content, $questionid, $parentid, $formid, $usecaptcha, $in, $errors, $loadfocusnow)
{
    switch (qa_user_permit_error('permit_post_c')) {
        case 'login':
            $form = array('title' => qa_insert_login_links(qa_lang_html('question/comment_must_login'), qa_request()));
            break;
        case 'confirm':
            $form = array('title' => qa_insert_login_links(qa_lang_html('question/comment_must_confirm'), qa_request()));
            break;
        case 'limit':
            $form = array('title' => qa_lang_html('question/comment_limit'));
            break;
        default:
            $form = array('title' => qa_lang_html('users/no_permission'));
            break;
        case false:
            $prefix = 'c' . $parentid . '_';
            $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_cs');
            $editor = qa_load_editor(@$in['content'], @$in['format'], $editorname);
            if (method_exists($editor, 'update_script')) {
                $updatescript = $editor->update_script($prefix . 'content');
            } else {
                $updatescript = '';
            }
            $custom = qa_opt('show_custom_comment') ? trim(qa_opt('custom_comment')) : '';
            $form = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '" NAME="c_form_' . qa_html($parentid) . '"', 'title' => qa_lang_html($questionid == $parentid ? 'question/your_comment_q' : 'question/your_comment_a'), 'fields' => array('custom' => array('type' => 'custom', 'note' => $custom), 'content' => array_merge(qa_editor_load_field($editor, $qa_content, @$in['content'], @$in['format'], $prefix . 'content', 4, $loadfocusnow, $loadfocusnow), array('error' => qa_html(@$errors['content'])))), 'buttons' => array('comment' => array('tags' => 'onClick="' . $updatescript . ' return qa_submit_comment(' . qa_js($questionid) . ', ' . qa_js($parentid) . ', this);"', 'label' => qa_lang_html('question/add_comment_button')), 'cancel' => array('tags' => 'NAME="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array($prefix . 'editor' => qa_html($editorname), $prefix . 'doadd' => '1'));
            if (!strlen($custom)) {
                unset($form['fields']['custom']);
            }
            qa_set_up_notify_fields($qa_content, $form['fields'], 'C', qa_get_logged_in_email(), isset($in['notify']) ? $in['notify'] : qa_opt('notify_users_default'), $in['email'], @$errors['email'], $prefix);
            $onloads = array();
            if ($usecaptcha) {
                $userid = qa_get_logged_in_userid();
                $captchaloadscript = qa_set_up_captcha_field($qa_content, $form['fields'], $errors, qa_insert_login_links(qa_lang_html(isset($userid) ? 'misc/captcha_confirm_fix' : 'misc/captcha_login_fix')));
                if (strlen($captchaloadscript)) {
                    $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_show=function() { ' . $captchaloadscript . ' }';
                }
            }
            if (!$loadfocusnow) {
                if (method_exists($editor, 'load_script')) {
                    $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_load=function() { ' . $editor->load_script($prefix . 'content') . ' }';
                }
                if (method_exists($editor, 'focus_script')) {
                    $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_focus=function() { ' . $editor->focus_script($prefix . 'content') . ' }';
                }
                $form['buttons']['cancel']['tags'] .= ' onClick="return qa_toggle_element()"';
            }
            if (count($onloads)) {
                $qa_content['script_onloads'][] = $onloads;
            }
    }
    $form['id'] = $formid;
    $form['collapse'] = !$loadfocusnow;
    $form['style'] = 'tall';
    return $form;
}
function qa_page_q_edit_c_form(&$qa_content, $id, $comment, $in, $errors)
{
    $commentid = $comment['postid'];
    $prefix = 'c' . $commentid . '_';
    $content = isset($in['content']) ? $in['content'] : $comment['content'];
    $format = isset($in['format']) ? $in['format'] : $comment['format'];
    $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_cs');
    $editor = qa_load_editor($content, $format, $editorname);
    $form = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'id' => $id, 'title' => qa_lang_html('question/edit_c_title'), 'style' => 'tall', 'fields' => array('content' => array_merge(qa_editor_load_field($editor, $qa_content, $content, $format, $prefix . 'content', 4, true), array('error' => qa_html(@$errors['content'])))), 'buttons' => array('save' => array('tags' => 'onclick="qa_show_waiting_after(this, false); ' . (method_exists($editor, 'update_script') ? $editor->update_script($prefix . 'content') : '') . '"', 'label' => qa_lang_html('main/save_button')), 'cancel' => array('tags' => 'name="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array($prefix . 'editor' => qa_html($editorname), $prefix . 'dosave' => '1', $prefix . 'code' => qa_get_form_security_code('edit-' . $commentid)));
    if ($comment['isbyuser']) {
        if (!qa_is_logged_in()) {
            qa_set_up_name_field($qa_content, $form['fields'], isset($in['name']) ? $in['name'] : @$comment['name'], $prefix);
        }
        qa_set_up_notify_fields($qa_content, $form['fields'], 'C', qa_get_logged_in_email(), isset($in['notify']) ? $in['notify'] : !empty($comment['notify']), isset($in['email']) ? $in['email'] : @$comment['notify'], @$errors['email'], $prefix);
    }
    if (!qa_user_post_permit_error('permit_edit_silent', $comment)) {
        $form['fields']['silent'] = array('type' => 'checkbox', 'label' => qa_lang_html('question/save_silent_label'), 'tags' => 'name="' . $prefix . 'silent"', 'value' => qa_html(@$in['silent']));
    }
    return $form;
}
    switch (qa_user_permit_error('permit_post_a')) {
        case 'login':
            $answerform = array('style' => 'tall', 'title' => qa_insert_login_links(qa_lang_html('question/answer_must_login'), $qa_request));
            break;
        case 'confirm':
            $answerform = array('style' => 'tall', 'title' => qa_insert_login_links(qa_lang_html('question/answer_must_confirm'), $qa_request));
            break;
        case false:
            $editorname = isset($ineditor) ? $ineditor : qa_opt('editor_for_as');
            $editor = qa_load_editor(@$incontent, @$informat, $editorname);
            $answerform = array('title' => qa_lang_html('question/your_answer_title'), 'style' => 'tall', 'fields' => array('content' => array_merge($editor->get_field($qa_content, @$incontent, @$informat, 'content', 12, $formrequested), array('error' => qa_html(@$errors['content'])))), 'buttons' => array('answer' => array('tags' => 'NAME="doansweradd"', 'label' => qa_lang_html('question/add_answer_button'))), 'hidden' => array('editor' => qa_html($editorname)));
            if ($formrequested) {
                // only show cancel button if user explicitly requested the form
                $answerform['buttons']['cancel'] = array('tags' => 'NAME="docancel"', 'label' => qa_lang_html('main/cancel_button'));
            }
            qa_set_up_notify_fields($qa_content, $answerform['fields'], 'A', qa_get_logged_in_email(), isset($innotify) ? $innotify : qa_opt('notify_users_default'), @$inemail, @$errors['email']);
            if ($usecaptcha) {
                qa_set_up_captcha_field($qa_content, $answerform['fields'], @$errors, qa_insert_login_links(qa_lang_html(isset($qa_login_userid) ? 'misc/captcha_confirm_fix' : 'misc/captcha_login_fix')));
            }
            break;
    }
    if ($formrequested || empty($qa_content['a_list']['as'])) {
        $qa_content['q_view']['a_form'] = $answerform;
    } else {
        $answerkeys = array_keys($qa_content['a_list']['as']);
        $qa_content['a_list']['as'][$answerkeys[count($answerkeys) - 1]]['c_form'] = $answerform;
        // under last answer
    }
}
//	List of related questions
if ($relatedcount > 1 && !$question['hidden']) {
예제 #5
0
function qa_page_q_add_c_form(&$qa_content, $question, $parent, $formid, $captchareason, $in, $errors, $loadfocusnow)
{
    // The 'approve', 'login', 'confirm', 'userblock', 'ipblock' permission errors are reported to the user here
    // The other option ('level') prevents the comment button being shown, in qa_page_q_post_rules(...)
    switch (qa_user_post_permit_error('permit_post_c', $parent, QA_LIMIT_COMMENTS)) {
        case 'login':
            $form = array('title' => qa_insert_login_links(qa_lang_html('question/comment_must_login'), qa_request()));
            break;
        case 'confirm':
            $form = array('title' => qa_insert_login_links(qa_lang_html('question/comment_must_confirm'), qa_request()));
            break;
        case 'approve':
            $form = array('title' => qa_lang_html('question/comment_must_be_approved'));
            break;
        case 'limit':
            $form = array('title' => qa_lang_html('question/comment_limit'));
            break;
        default:
            $form = array('title' => qa_lang_html('users/no_permission'));
            break;
        case false:
            $prefix = 'c' . $parent['postid'] . '_';
            $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_cs');
            $editor = qa_load_editor(@$in['content'], @$in['format'], $editorname);
            if (method_exists($editor, 'update_script')) {
                $updatescript = $editor->update_script($prefix . 'content');
            } else {
                $updatescript = '';
            }
            $custom = qa_opt('show_custom_comment') ? trim(qa_opt('custom_comment')) : '';
            $form = array('tags' => 'method="post" action="' . qa_self_html() . '" name="c_form_' . qa_html($parent['postid']) . '"', 'title' => qa_lang_html($question['postid'] == $parent['postid'] ? 'question/your_comment_q' : 'question/your_comment_a'), 'fields' => array('custom' => array('type' => 'custom', 'note' => $custom), 'content' => array_merge(qa_editor_load_field($editor, $qa_content, @$in['content'], @$in['format'], $prefix . 'content', 4, $loadfocusnow, $loadfocusnow), array('error' => qa_html(@$errors['content'])))), 'buttons' => array('comment' => array('tags' => 'onclick="' . $updatescript . ' return qa_submit_comment(' . qa_js($question['postid']) . ', ' . qa_js($parent['postid']) . ', this);"', 'label' => qa_lang_html('question/add_comment_button')), 'cancel' => array('tags' => 'name="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array($prefix . 'editor' => qa_html($editorname), $prefix . 'doadd' => '1', $prefix . 'code' => qa_get_form_security_code('comment-' . $parent['postid'])));
            if (!strlen($custom)) {
                unset($form['fields']['custom']);
            }
            if (!qa_is_logged_in()) {
                qa_set_up_name_field($qa_content, $form['fields'], @$in['name'], $prefix);
            }
            qa_set_up_notify_fields($qa_content, $form['fields'], 'C', qa_get_logged_in_email(), isset($in['notify']) ? $in['notify'] : qa_opt('notify_users_default'), $in['email'], @$errors['email'], $prefix);
            $onloads = array();
            if ($captchareason) {
                $captchaloadscript = qa_set_up_captcha_field($qa_content, $form['fields'], $errors, qa_captcha_reason_note($captchareason));
                if (strlen($captchaloadscript)) {
                    $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_show=function() { ' . $captchaloadscript . ' };';
                }
            }
            if (!$loadfocusnow) {
                if (method_exists($editor, 'load_script')) {
                    $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_load=function() { ' . $editor->load_script($prefix . 'content') . ' };';
                }
                if (method_exists($editor, 'focus_script')) {
                    $onloads[] = 'document.getElementById(' . qa_js($formid) . ').qa_focus=function() { ' . $editor->focus_script($prefix . 'content') . ' };';
                }
                $form['buttons']['cancel']['tags'] .= ' onclick="return qa_toggle_element()"';
            }
            if (count($onloads)) {
                $qa_content['script_onloads'][] = $onloads;
            }
    }
    $form['id'] = $formid;
    $form['collapse'] = !$loadfocusnow;
    $form['style'] = 'tall';
    return $form;
}
function qa_page_q_edit_c_form(&$qa_content, $id, $comment, $in, $errors)
{
    $commentid = $comment['postid'];
    $prefix = 'c' . $commentid . '_';
    $content = isset($in['content']) ? $in['content'] : $comment['content'];
    $format = isset($in['format']) ? $in['format'] : $comment['format'];
    $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_cs');
    $editor = qa_load_editor($content, $format, $editorname);
    $form = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'id' => $id, 'title' => qa_lang_html('question/edit_c_title'), 'style' => 'tall', 'fields' => array('content' => array_merge(qa_editor_load_field($editor, $qa_content, $content, $format, $prefix . 'content', 4, true), array('error' => qa_html(@$errors['content'])))), 'buttons' => array('save' => array('tags' => method_exists($editor, 'update_script') ? 'onClick="' . $editor->update_script($prefix . 'content') . '"' : '', 'label' => qa_lang_html('main/save_button')), 'cancel' => array('tags' => 'NAME="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array($prefix . 'editor' => qa_html($editorname), $prefix . 'dosave' => '1'));
    if ($comment['isbyuser']) {
        qa_set_up_notify_fields($qa_content, $form['fields'], 'C', qa_get_logged_in_email(), isset($in['notify']) ? $in['notify'] : !empty($comment['notify']), isset($in['email']) ? $in['email'] : @$comment['notify'], @$errors['email'], $prefix);
    }
    return $form;
}
 function qa_ajax_comment_form()
 {
     global $qa_content, $incomment, $informat, $errors, $questionid, $ineditor, $innotify, $inemail, $jumptoanchor, $focusonid, $usecaptcha, $qa_login_userid;
     $jumptoanchor = isset($answerid) ? qa_anchor('A', $answerid) : qa_anchor('Q', $questionid);
     $focusonid = 'comment';
     $editorname = isset($ineditor) ? $ineditor : qa_opt('editor_for_cs');
     $editor = qa_load_editor(@$incomment, @$informat, $editorname);
     $form = array('title' => qa_lang_html(isset($answerid) ? 'question/your_comment_a' : 'question/your_comment_q'), 'style' => 'tall', 'fields' => array('content' => array_merge($editor->get_field($qa_content, @$incomment, @$informat, 'comment', 4, true), array('error' => qa_html(@$errors['content']), 'rows' => 8))), 'buttons' => array('comment' => array('tags' => 'onclick="ajaxPostComment()"', 'label' => qa_lang_html('question/add_comment_button'), 'ajax_comment' => $this->idx2), 'cancel' => array('tags' => 'NAME="docancel"', 'label' => qa_lang_html('main/cancel_button'), 'ajax_comment' => $this->idx2)), 'hidden' => array('editor' => qa_html($editorname)));
     $form['fields']['content']['tags'] = @$form['fields']['tags'] . ' id="comment" onkeydown="if(event.keyCode == 27) toggleComment(false);"';
     // add reminder text if commenting on answer to own question
     $ourid = qa_get_logged_in_userid();
     if (qa_opt('ajax_comment_answer_reminder') && !$this->content['q_view']['raw']['selchildid'] && isset($answerid) && $this->content['q_view']['raw']['userid'] == $ourid && @$this->content['a_list']['as'][$this->idx - 1]['raw']['userid'] != $ourid) {
         $form['fields']['custom_message'] = array('note' => '<div class="ajax-comment-reminder">' . qa_opt('ajax_comment_answer_reminder_text') . '</div>', 'type' => 'static');
     }
     qa_set_up_notify_fields($qa_content, $form['fields'], 'C', qa_get_logged_in_email(), isset($innotify) ? $innotify : qa_opt('notify_users_default'), @$inemail, @$errors['email']);
     if ($usecaptcha) {
         qa_set_up_captcha_field($qa_content, $form['fields'], @$errors, qa_insert_login_links(qa_lang_html(isset($qa_login_userid) ? 'misc/captcha_confirm_fix' : 'misc/captcha_login_fix')));
     }
     $form['ajax_comment'] = 0;
     $this->idx2++;
     return $form;
 }
function qa_page_q_edit_c_form($commentid, $answerid)
{
    global $commentsfollows, $qa_content, $errors, $incomment, $informat, $ineditor, $questionid, $jumptoanchor, $focusonid, $innotify, $inemail;
    $comment = $commentsfollows[$commentid];
    $content = isset($incomment) ? $incomment : $comment['content'];
    $format = isset($informat) ? $informat : $comment['format'];
    $editorname = isset($ineditor) ? $ineditor : qa_opt('editor_for_cs');
    $editor = qa_load_editor($content, $format, $editorname);
    $jumptoanchor = isset($answerid) ? qa_anchor('A', $answerid) : qa_anchor('Q', $questionid);
    $form = array('title' => '<A NAME="edit">' . qa_lang_html('question/edit_c_title') . '</A>', 'style' => 'tall', 'fields' => array('content' => array_merge($editor->get_field($qa_content, $content, $format, 'comment', 4, true), array('error' => qa_html($errors['content'])))), 'buttons' => array('save' => array('label' => qa_lang_html('main/save_button')), 'cancel' => array('tags' => 'NAME="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array('editor' => qa_html($editorname), 'dosavec_' . qa_html($commentid) => '1'));
    if ($comment['isbyuser']) {
        qa_set_up_notify_fields($qa_content, $form['fields'], 'C', qa_get_logged_in_email(), isset($innotify) ? $innotify : !empty($comment['notify']), isset($inemail) ? $inemail : @$comment['notify'], @$errors['email']);
    }
    return $form;
}