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 */
function qa_page_q_edit_q_form(&$qa_content, $question, $in, $errors, $completetags, $categories) { $form = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('title' => array('type' => $question['editable'] ? 'text' : 'static', 'label' => qa_lang_html('question/q_title_label'), 'tags' => 'name="q_title"', 'value' => qa_html($question['editable'] && isset($in['title']) ? $in['title'] : $question['title']), 'error' => qa_html(@$errors['title'])), 'category' => array('label' => qa_lang_html('question/q_category_label'), 'error' => qa_html(@$errors['categoryid'])), 'content' => array('label' => qa_lang_html('question/q_content_label'), 'error' => qa_html(@$errors['content'])), 'extra' => array('label' => qa_html(qa_opt('extra_field_prompt')), 'tags' => 'name="q_extra"', 'value' => qa_html(isset($in['extra']) ? $in['extra'] : $question['extra']), 'error' => qa_html(@$errors['extra'])), 'tags' => array('error' => qa_html(@$errors['tags']))), 'buttons' => array('save' => array('tags' => 'onclick="qa_show_waiting_after(this, false);"', 'label' => qa_lang_html('main/save_button')), 'cancel' => array('tags' => 'name="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array('q_dosave' => '1', 'code' => qa_get_form_security_code('edit-' . $question['postid']))); if ($question['editable']) { $content = isset($in['content']) ? $in['content'] : $question['content']; $format = isset($in['format']) ? $in['format'] : $question['format']; $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_qs'); $editor = qa_load_editor($content, $format, $editorname); $form['fields']['content'] = array_merge($form['fields']['content'], qa_editor_load_field($editor, $qa_content, $content, $format, 'q_content', 12, true)); if (method_exists($editor, 'update_script')) { $form['buttons']['save']['tags'] = 'onclick="qa_show_waiting_after(this, false); ' . $editor->update_script('q_content') . '"'; } $form['hidden']['q_editor'] = qa_html($editorname); } else { unset($form['fields']['content']); } if (qa_using_categories() && count($categories) && $question['retagcatable']) { qa_set_up_category_field($qa_content, $form['fields']['category'], 'q_category', $categories, isset($in['categoryid']) ? $in['categoryid'] : $question['categoryid'], qa_opt('allow_no_category') || !isset($question['categoryid']), qa_opt('allow_no_sub_category')); } else { unset($form['fields']['category']); } if (!($question['editable'] && qa_opt('extra_field_active'))) { unset($form['fields']['extra']); } if (qa_using_tags() && $question['retagcatable']) { qa_set_up_tag_field($qa_content, $form['fields']['tags'], 'q_tags', isset($in['tags']) ? $in['tags'] : qa_tagstring_to_tags($question['tags']), array(), $completetags, qa_opt('page_size_ask_tags')); } else { unset($form['fields']['tags']); } if ($question['isbyuser']) { if (!qa_is_logged_in()) { qa_set_up_name_field($qa_content, $form['fields'], isset($in['name']) ? $in['name'] : @$question['name'], 'q_'); } qa_set_up_notify_fields($qa_content, $form['fields'], 'Q', qa_get_logged_in_email(), isset($in['notify']) ? $in['notify'] : !empty($question['notify']), isset($in['email']) ? $in['email'] : @$question['notify'], @$errors['email'], 'q_'); } if (!qa_user_post_permit_error('permit_edit_silent', $question)) { $form['fields']['silent'] = array('type' => 'checkbox', 'label' => qa_lang_html('question/save_silent_label'), 'tags' => 'name="q_silent"', 'value' => qa_html(@$in['silent'])); } return $form; }
$qa_content['form']['fields']['title']['tags'] .= ' onChange="qa_title_change(this.value);"'; if (strlen(@$intitle)) { $qa_content['script_onloads'][] = 'qa_title_change(' . qa_js($intitle) . ');'; } } //if (qa_using_categories() && count($categories)) { // qa_set_up_category_field($qa_content, $qa_content['form']['fields']['category'], 'category', // $categories, $incategoryid, true, qa_opt('allow_no_sub_category')); // // if (!qa_opt('allow_no_category')) // don't auto-select a category even though one is required // $qa_content['form']['fields']['category']['options']['']=''; // //} else // unset($qa_content['form']['fields']['category']); if (qa_using_tags()) { qa_set_up_tag_field($qa_content, $qa_content['form']['fields']['tags'], 'tags', isset($intags) ? $intags : array(), array(), qa_opt('do_complete_tags') ? array_keys($completetags) : array(), qa_opt('page_size_ask_tags')); } else { unset($qa_content['form']['fields']['tags']); } qa_set_up_notify_fields($qa_content, $qa_content['form']['fields'], 'Q', qa_get_logged_in_email(), isset($innotify) ? $innotify : qa_opt('notify_users_default'), @$inemail, @$errors['email']); if ($usecaptcha) { require_once 'qa-app-captcha.php'; qa_set_up_captcha_field($qa_content, $qa_content['form']['fields'], @$errors, qa_insert_login_links(qa_lang_html(isset($qa_login_userid) ? 'misc/captcha_confirm_fix' : 'misc/captcha_login_fix'))); } if (isset($followanswer)) { $viewer = qa_load_viewer($followanswer['content'], $followanswer['format']); $qa_content['form']['fields']['follows'] = array('type' => 'static', 'label' => qa_lang_html('question/ask_follow_from_a'), 'value' => $viewer->get_html($followanswer['content'], $followanswer['format'], array('blockwordspreg' => qa_get_block_words_preg()))); } else { unset($qa_content['form']['fields']['follows']); } $qa_content['focusid'] = 'title';
function qa_page_q_edit_q_form(&$qa_content, $question, $in, $errors, $completetags, $categories) { $form = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'fields' => array('title' => array('type' => $question['editable'] ? 'text' : 'static', 'label' => qa_lang_html('question/q_title_label'), 'tags' => 'NAME="q_title"', 'value' => qa_html($question['editable'] && isset($in['title']) ? $in['title'] : $question['title']), 'error' => qa_html(@$errors['title'])), 'category' => array('label' => qa_lang_html('question/q_category_label'), 'error' => qa_html(@$errors['categoryid'])), 'content' => array('label' => qa_lang_html('question/q_content_label'), 'error' => qa_html(@$errors['content'])), 'extra' => array('label' => qa_html(qa_opt('extra_field_prompt')), 'tags' => 'NAME="q_extra"', 'value' => qa_html(isset($in['extra']) ? $in['extra'] : $question['extra']), 'error' => qa_html(@$errors['extra'])), 'tags' => array('error' => qa_html(@$errors['tags']))), '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('q_dosave' => '1')); if ($question['editable']) { $content = isset($in['content']) ? $in['content'] : $question['content']; $format = isset($in['format']) ? $in['format'] : $question['format']; $editorname = isset($in['editor']) ? $in['editor'] : qa_opt('editor_for_qs'); $editor = qa_load_editor($content, $format, $editorname); $form['fields']['content'] = array_merge($form['fields']['content'], qa_editor_load_field($editor, $qa_content, $content, $format, 'q_content', 12, true)); $form['buttons']['save']['tags'] = method_exists($editor, 'update_script') ? 'onClick="' . $editor->update_script('q_content') . '"' : ''; $form['hidden']['q_editor'] = qa_html($editorname); } else { unset($form['fields']['content']); } if (qa_using_categories() && count($categories) && $question['retagcatable']) { qa_set_up_category_field($qa_content, $form['fields']['category'], 'q_category', $categories, isset($in['categoryid']) ? $in['categoryid'] : $question['categoryid'], qa_opt('allow_no_category') || !isset($question['categoryid']), qa_opt('allow_no_sub_category')); } else { unset($form['fields']['category']); } if (!($question['editable'] && qa_opt('extra_field_active'))) { unset($form['fields']['extra']); } if (qa_using_tags() && $question['retagcatable']) { qa_set_up_tag_field($qa_content, $form['fields']['tags'], 'q_tags', isset($in['tags']) ? $in['tags'] : qa_tagstring_to_tags($question['tags']), array(), $completetags, qa_opt('page_size_ask_tags')); } else { unset($form['fields']['tags']); } if ($question['isbyuser']) { qa_set_up_notify_fields($qa_content, $form['fields'], 'Q', qa_get_logged_in_email(), isset($in['notify']) ? $in['notify'] : !empty($question['notify']), isset($in['email']) ? $in['email'] : @$question['notify'], @$errors['email'], 'q_'); } return $form; }
function qa_page_q_edit_q_form() { global $qa_content, $question, $inqtitle, $inqcontent, $inqformat, $inqeditor, $inqtags, $qerrors, $innotify, $inemail, $completetags, $categories; $content = isset($inqcontent) ? $inqcontent : $question['content']; $format = isset($inqformat) ? $inqformat : $question['format']; $editorname = isset($inqeditor) ? $inqeditor : qa_opt('editor_for_qs'); $editor = qa_load_editor($content, $format, $editorname); $form = array('style' => 'tall', 'fields' => array('title' => array('label' => qa_lang_html('question/q_title_label'), 'tags' => 'NAME="qtitle"', 'value' => qa_html(isset($inqtitle) ? $inqtitle : $question['title']), 'error' => qa_html(@$qerrors['title'])), 'category' => array('label' => qa_lang_html('question/q_category_label')), 'content' => array_merge($editor->get_field($qa_content, $content, $format, 'qcontent', 12, true), array('label' => qa_lang_html('question/q_content_label'), 'error' => qa_html(@$qerrors['content']))), 'tags' => array('error' => qa_html(@$qerrors['tags']))), '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), 'dosaveq' => '1')); if (qa_using_categories() && count($categories)) { qa_set_up_category_field($qa_content, $form['fields']['category'], 'category', $categories, isset($incategoryid) ? $incategoryid : $question['categoryid'], qa_opt('allow_no_category') || !isset($question['categoryid']), qa_opt('allow_no_sub_category')); } else { unset($form['fields']['category']); } if (qa_using_tags()) { qa_set_up_tag_field($qa_content, $form['fields']['tags'], 'qtags', isset($inqtags) ? $inqtags : qa_tagstring_to_tags($question['tags']), array(), $completetags, qa_opt('page_size_ask_tags')); } else { unset($form['fields']['tags']); } if ($question['isbyuser']) { qa_set_up_notify_fields($qa_content, $form['fields'], 'Q', qa_get_logged_in_email(), isset($innotify) ? $innotify : !empty($question['notify']), isset($inemail) ? $inemail : @$question['notify'], @$qerrors['email']); } return $form; }