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"'))); }
break; case 'answers': $questions = qa_feed_load_ifcategory($categoryslugs, 'main/recent_as_title', 'main/recent_as_in_x', $title, qa_db_recent_a_qs_selectspec(null, 0, $categoryslugs, null, false, $full, $count)); break; case 'comments': $questions = qa_feed_load_ifcategory($categoryslugs, 'main/recent_cs_title', 'main/recent_cs_in_x', $title, qa_db_recent_c_qs_selectspec(null, 0, $categoryslugs, null, false, $full, $count)); break; case 'qa': $questions = qa_feed_load_ifcategory($categoryslugs, 'main/recent_qs_as_title', 'main/recent_qs_as_in_x', $title, qa_db_qs_selectspec(null, 'created', 0, $categoryslugs, null, false, $full, $count), qa_db_recent_a_qs_selectspec(null, 0, $categoryslugs, null, false, $full, $count)); break; case 'activity': $questions = qa_feed_load_ifcategory($categoryslugs, 'main/recent_activity_title', 'main/recent_activity_in_x', $title, qa_db_qs_selectspec(null, 'created', 0, $categoryslugs, null, false, $full, $count), qa_db_recent_a_qs_selectspec(null, 0, $categoryslugs, null, false, $full, $count), qa_db_recent_c_qs_selectspec(null, 0, $categoryslugs, null, false, $full, $count), qa_db_recent_edit_qs_selectspec(null, 0, $categoryslugs, null, true, $full, $count)); break; case 'tag': $tag = $feedparams[0]; $questions = qa_feed_load_ifcategory(null, null, null, $title, qa_db_tag_recent_qs_selectspec(null, $tag, 0, $full, $count)); $title = qa_lang_sub('main/questions_tagged_x', $tag); $linkrequest = 'tag/' . $tag; break; case 'search': require_once QA_INCLUDE_DIR . 'app/search.php'; $query = $feedparams[0]; $results = qa_get_search_results($query, 0, $count, null, true, $full); $title = qa_lang_sub('main/results_for_x', $query); $linkrequest = 'search'; $linkparams = array('q' => $query); $questions = array(); foreach ($results as $result) { $setarray = array('title' => $result['title'], 'url' => $result['url']); if (isset($result['question'])) { $questions[] = array_merge($result['question'], $setarray);
// don't allow this page to be requested directly from browser header('Location: ../'); exit; } require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; require_once QA_INCLUDE_DIR . 'qa-app-updates.php'; $tag = qa_request_part(1); // picked up from qa-page.php $start = qa_get_start(); $userid = qa_get_logged_in_userid(); // Find the questions with this tag if (!strlen($tag)) { qa_redirect('tags'); } list($questions, $tagword) = qa_db_select_with_pending(qa_db_tag_recent_qs_selectspec($userid, $tag, $start, false, qa_opt_if_loaded('page_size_tag_qs')), qa_db_tag_word_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 (isset($userid) && isset($tagword)) { $favoritemap = qa_get_favorite_non_qs_map(); $favorite = @$favoritemap['tag'][qa_strtolower($tagword['word'])]; $qa_content['favorite'] = qa_favorite_form(QA_ENTITY_TAG, $tagword['wordid'], $favorite, qa_lang_sub($favorite ? 'main/remove_x_favorites' : 'main/add_tag_x_favorites', $tagword['word'])); } 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() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote')));
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'));
// don't allow this page to be requested directly from browser header('Location: ../'); exit; } require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; require_once QA_INCLUDE_DIR . 'qa-app-updates.php'; $tag = qa_request_part(1); // picked up from qa-page.php $start = qa_get_start(); $userid = qa_get_logged_in_userid(); // Find the questions with this tag if (!strlen($tag)) { qa_redirect('tags'); } @(list($questions, $tagword, $favorite) = qa_db_select_with_pending(qa_db_tag_recent_qs_selectspec($userid, $tag, $start, false, qa_opt_if_loaded('page_size_tag_qs')), qa_db_tag_word_selectspec($tag), isset($userid) ? qa_db_is_favorite_selectspec($userid, QA_ENTITY_TAG, $tag) : null)); $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 (isset($userid) && isset($tagword)) { $qa_content['favorite'] = qa_favorite_form(QA_ENTITY_TAG, $tagword['wordid'], $favorite, qa_lang_sub($favorite ? 'main/remove_x_favorites' : 'main/add_tag_x_favorites', $tagword['word'])); } 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) {