function admin_form(&$qa_content)
 {
     // process config change
     $saved_msg = '';
     if (qa_clicked('tag_synonyms_save_button')) {
         qa_opt('tag_synonyms', trim(qa_post_text('tag_synonyms_text')));
         qa_opt('tag_synonyms_prevent', (int) qa_post_text('tag_synonyms_prevent'));
         qa_opt('tag_synonyms_rep', (int) qa_post_text('tag_synonyms_rep'));
         $saved_msg = 'Tag Synonyms settings saved';
         // convert all old tags based on synonyms
         if (qa_post_text('tag_synonyms_convert')) {
             $synonyms = $this->_synonyms_to_array(qa_opt('tag_synonyms'));
             $edited = 0;
             qa_suspend_event_reports(true);
             // avoid infinite loop
             foreach ($synonyms as $syn) {
                 list($questions, $qcount) = qa_db_select_with_pending(qa_db_tag_recent_qs_selectspec(null, $syn['from'], 0, false, 500), qa_db_tag_count_qs_selectspec($syn['from']));
                 foreach ($questions as $q) {
                     $oldtags = qa_tagstring_to_tags($q['tags']);
                     $newtags = $this->_convert_tags($oldtags, $synonyms);
                     qa_post_set_content($q['postid'], null, null, null, $newtags);
                     $edited++;
                 }
             }
             qa_suspend_event_reports(false);
             $saved_msg .= ' (and ' . $edited . ' tags edited)';
         }
     }
     // set fields to show/hide when checkbox is clicked
     qa_set_display_rules($qa_content, array('tag_synonyms_rep' => 'tag_synonyms_prevent'));
     return array('ok' => $saved_msg, 'fields' => array(array('label' => 'Tag Synonyms', 'tags' => 'name="tag_synonyms_text" id="tag_synonyms_text"', 'value' => qa_opt('tag_synonyms'), 'type' => 'textarea', 'rows' => 20, 'note' => 'Put each pair of synonyms on a new line. <code>q2a,question2answer</code> means that a tag of <code>q2a</code> will be replaced by <code>question2answer</code>, while <code>help</code> on its own means that tag will be removed.'), array('label' => 'Also convert existing tags using above rules', 'tags' => 'name="tag_synonyms_convert" id="tag_synonyms_convert"', 'value' => '', 'type' => 'checkbox'), array('type' => 'blank'), array('label' => 'Prevent new users from creating new tags', 'tags' => 'name="tag_synonyms_prevent" id="tag_synonyms_prevent"', 'value' => qa_opt('tag_synonyms_prevent'), 'type' => 'checkbox'), array('id' => 'tag_synonyms_rep', 'label' => 'Minimum reputation to create new tags', 'value' => qa_opt('tag_synonyms_rep'), 'tags' => 'name="tag_synonyms_rep"', 'type' => 'number')), 'buttons' => array(array('label' => 'Save Changes', 'tags' => 'name="tag_synonyms_save_button"')));
 }
Example #2
0
if (!defined('QA_VERSION')) {
    // don't allow this page to be requested directly from browser
    header('Location: ../');
    exit;
}
// report that we entered this page
qa_report_event('page_enter', qa_get_logged_in_userid(), qa_get_logged_in_handle(), qa_cookie_get(), array('params' => $_SERVER['QUERY_STRING'], 'path' => $_SERVER['SCRIPT_NAME']));
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
$tag = @$pass_subrequests[0];
// picked up from qa-page.php
if (!strlen($tag)) {
    qa_redirect('tags');
}
//	Find the questions with this tag
list($questions, $qcount) = qa_db_select_with_pending(qa_db_tag_recent_qs_selectspec($qa_login_userid, $tag, $qa_start), qa_db_tag_count_qs_selectspec($tag));
$pagesize = qa_opt('page_size_tag_qs');
$questions = array_slice($questions, 0, $pagesize);
$usershtml = qa_userids_handles_html($questions);
//	Prepare content for theme
$qa_content = qa_content_prepare(true);
$qa_content['title'] = qa_lang_html_sub('main/questions_tagged_x', qa_html($tag));
if (!count($questions)) {
    $qa_content['q_list']['title'] = qa_lang_html('main/no_questions_found');
}
$qa_content['q_list']['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"');
$qa_content['q_list']['qs'] = array();
foreach ($questions as $postid => $question) {
    $qa_content['q_list']['qs'][] = qa_post_html_fields($question, $qa_login_userid, $qa_cookieid, $usershtml, null, qa_post_html_defaults('Q'));
}
$qa_content['page_links'] = qa_html_page_links($qa_request, $qa_start, $pagesize, $qcount, qa_opt('pages_prev_next'));