コード例 #1
0
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;
}
コード例 #2
0
}
if (qa_opt('do_ask_check_qs') || qa_opt('do_example_tags')) {
    $qa_content['script_rel'][] = 'qa-content/qa-ask.js?' . QA_VERSION;
    $qa_content['form']['fields']['title']['tags'] .= ' onchange="qa_title_change(this.value);"';
    if (strlen(@$in['title'])) {
        $qa_content['script_onloads'][] = 'qa_title_change(' . qa_js($in['title']) . ');';
    }
}
if (isset($followanswer)) {
    $viewer = qa_load_viewer($followanswer['content'], $followanswer['format']);
    $field = 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())));
    qa_array_insert($qa_content['form']['fields'], 'title', array('follows' => $field));
}
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));
}
コード例 #3
0
             if ($catleveladd || count($userlevels)) {
                 $userlevels[] = array('entitytype' => QA_ENTITY_CATEGORY);
             }
             $index = 0;
             foreach ($userlevels as $userlevel) {
                 if ($userlevel['entitytype'] == QA_ENTITY_CATEGORY) {
                     $index++;
                     $id = 'ls_' . +$index;
                     $qa_content['form_profile']['fields']['uc_' . $index . '_level'] = array('label' => qa_lang_html('users/category_level_label'), 'type' => 'select', 'tags' => 'name="uc_' . $index . '_level" id="' . qa_html($id) . '" onchange="this.qa_prev=this.options[this.selectedIndex].value;"', 'options' => $catleveloptions, 'value' => isset($userlevel['level']) ? qa_html(qa_user_level_string($userlevel['level'])) : '', 'suffix' => qa_lang_html('users/category_level_in'));
                     $qa_content['form_profile']['fields']['uc_' . $index . '_cat'] = array();
                     if (isset($userlevel['entityid'])) {
                         $fieldnavcategories = qa_db_select_with_pending(qa_db_category_nav_selectspec($userlevel['entityid'], true));
                     } else {
                         $fieldnavcategories = $navcategories;
                     }
                     qa_set_up_category_field($qa_content, $qa_content['form_profile']['fields']['uc_' . $index . '_cat'], 'uc_' . $index . '_cat', $fieldnavcategories, @$userlevel['entityid'], true, true);
                     unset($qa_content['form_profile']['fields']['uc_' . $index . '_cat']['note']);
                 }
             }
             $qa_content['script_lines'][] = array("function qa_update_category_levels()", "{", "\tglob=document.getElementById('level_select');", "\tif (!glob)", "\t\treturn;", "\tvar opts=glob.options;", "\tvar lev=parseInt(opts[glob.selectedIndex].value);", "\tfor (var i=1; i<9999; i++) {", "\t\tvar sel=document.getElementById('ls_'+i);", "\t\tif (!sel)", "\t\t\tbreak;", "\t\tsel.qa_prev=sel.qa_prev || sel.options[sel.selectedIndex].value;", "\t\tsel.options.length=1;", "\t\tfor (var j=0; j<opts.length; j++)", "\t\t\tif (parseInt(opts[j].value)>lev)", "\t\t\t\tsel.options[sel.options.length]=new Option(opts[j].text, opts[j].value, false, (opts[j].value==sel.qa_prev));", "\t}", "}");
             $qa_content['script_onloads'][] = array("qa_update_category_levels();");
             $qa_content['form_profile']['fields']['level']['tags'] .= ' id="level_select" onchange="qa_update_category_levels();"';
         }
     }
 } else {
     foreach ($userlevels as $userlevel) {
         if ($userlevel['entitytype'] == QA_ENTITY_CATEGORY && $userlevel['level'] > $useraccount['level']) {
             $qa_content['form_profile']['fields']['level']['value'] .= '<br/>' . strtr(qa_lang_html('users/level_for_category'), array('^1' => qa_html(qa_user_level_string($userlevel['level'])), '^2' => '<a href="' . qa_path_html(implode('/', array_reverse(explode('/', $userlevel['backpath'])))) . '">' . qa_html($userlevel['title']) . '</a>'));
         }
     }
 }
コード例 #4
0
     unset($qa_content['form']['fields']['content']);
     $qa_content['form']['fields']['parent'] = array('label' => qa_lang_html('admin/category_parent'));
     $childdepth = qa_db_category_child_depth($editcategory['categoryid']);
     qa_set_up_category_field($qa_content, $qa_content['form']['fields']['parent'], 'parent', isset($incategories) ? $incategories : $categories, isset($inparentid) ? $inparentid : @$editcategory['parentid'], true, true, QA_CATEGORY_DEPTH - 1 - $childdepth, @$editcategory['categoryid']);
     $qa_content['form']['fields']['parent']['options'][''] = qa_lang_html('admin/category_top_level');
     @($qa_content['form']['fields']['parent']['note'] .= qa_lang_html_sub('admin/category_max_depth_x', QA_CATEGORY_DEPTH));
 } elseif (isset($editcategory['categoryid'])) {
     // existing category
     if ($hassubcategory) {
         $qa_content['form']['fields']['name']['note'] = qa_lang_html('admin/category_no_delete_subs');
         unset($qa_content['form']['fields']['delete']);
         unset($qa_content['form']['fields']['reassign']);
     } else {
         $qa_content['form']['fields']['delete'] = array('tags' => 'name="dodelete" id="dodelete"', 'label' => '<span id="reassign_shown">' . qa_lang_html('admin/delete_category_reassign') . '</span>' . '<span id="reassign_hidden" style="display:none;">' . qa_lang_html('admin/delete_category') . '</span>', 'value' => 0, 'type' => 'checkbox');
         $qa_content['form']['fields']['reassign'] = array('id' => 'reassign_display', 'tags' => 'name="reassign"');
         qa_set_up_category_field($qa_content, $qa_content['form']['fields']['reassign'], 'reassign', $categories, $editcategory['parentid'], true, true, null, $editcategory['categoryid']);
     }
     $qa_content['form']['fields']['questions'] = array('label' => qa_lang_html('admin/total_qs'), 'type' => 'static', 'value' => '<a href="' . qa_path_html('questions/' . qa_category_path_request($categories, $editcategory['categoryid'])) . '">' . ($editcategory['qcount'] == 1 ? qa_lang_html_sub('main/1_question', '1', '1') : qa_lang_html_sub('main/x_questions', number_format($editcategory['qcount']))) . '</a>');
     if ($hassubcategory && !qa_opt('allow_no_sub_category')) {
         $nosubcount = qa_db_count_categoryid_qs($editcategory['categoryid']);
         if ($nosubcount) {
             $qa_content['form']['fields']['questions']['error'] = strtr(qa_lang_html('admin/category_no_sub_error'), array('^q' => number_format($nosubcount), '^1' => '<a href="' . qa_path_html(qa_request(), array('edit' => $editcategory['categoryid'], 'missing' => 1)) . '">', '^2' => '</a>'));
         }
     }
     qa_set_display_rules($qa_content, array('position_display' => '!dodelete', 'slug_display' => '!dodelete', 'content_display' => '!dodelete', 'parent_display' => '!dodelete', 'children_display' => '!dodelete', 'reassign_display' => 'dodelete', 'reassign_shown' => 'dodelete', 'reassign_hidden' => '!dodelete'));
 } else {
     // new category
     unset($qa_content['form']['fields']['delete']);
     unset($qa_content['form']['fields']['reassign']);
     unset($qa_content['form']['fields']['slug']);
     unset($qa_content['form']['fields']['questions']);
コード例 #5
0
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;
}
コード例 #6
0
$qa_content['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"', 'style' => 'tall', 'ok' => $passwordsent ? qa_lang_html('users/password_sent') : null, 'fields' => array('email_handle' => array('label' => qa_lang_html('users/email_handle_label'), 'tags' => 'NAME="emailhandle" ID="emailhandle"', 'value' => qa_html(@$inemailhandle), 'error' => qa_html(@$errors['emailhandle'])), 'password' => array('type' => 'password', 'label' => qa_lang_html('users/password_label'), 'tags' => 'NAME="password" ID="password"', 'value' => qa_html(@$inpassword), 'error' => empty($errors['password']) ? '' : qa_html(@$errors['password']) . ' - ' . $forgothtml . ' ->' . qa_html(@$errors['category']) . '<-', 'note' => $passwordsent ? qa_lang_html('users/password_sent') : $forgothtml), 'category' => array('label' => qa_lang_html('question/q_category_label'), 'tags' => 'NAME="category" ID="category"', 'value' => qa_html(@$incategory), 'error' => qa_html(@$errors['category'])), 'remember' => array('type' => 'checkbox', 'label' => qa_lang_html('users/remember_label'), 'tags' => 'NAME="remember"', 'value' => @$inremember ? true : false)), 'buttons' => array('login' => array('label' => qa_lang_html('users/login_button'))), 'hidden' => array('dologin' => '1'));
$modulenames = qa_list_modules('login');
foreach ($modulenames as $tryname) {
    $module = qa_load_module('login', $tryname);
    if (method_exists($module, 'login_html')) {
        ob_start();
        $module->login_html(qa_opt('site_url') . qa_get('to'), 'login');
        $html = ob_get_clean();
        if (strlen($html)) {
            @($qa_content['custom'] .= '<BR>' . $html . '<BR>');
        }
    }
}
$qa_content['focusid'] = isset($inemailhandle) && !isset($errors['emailhandle']) ? 'password' : 'emailhandle';
// add handling of sub categories
//if (qa_using_categories() && count($categories)) {
//	$incategoryid=qa_get_category_field_value('category');
//	if (!isset($incategoryid))
//		$incategoryid=qa_get('cat');
$incategoryid = qa_get_category_field_value('category');
$categories = qa_db_select_with_pending(qa_db_category_nav_selectspec($incategoryid, true));
qa_set_up_category_field($qa_content, $qa_content['form']['fields']['category'], 'category', $categories, $incategoryid, false, 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']);
return $qa_content;
/*
	Omit PHP closing tag to help avoid accidental output
*/
コード例 #7
0
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;
}