function qa_favorite_q_list_view($questions, $usershtml) { $q_list = array('qs' => array()); if (count($questions) === 0) { return $q_list; } $q_list['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote'))); $defaults = qa_post_html_defaults('Q'); foreach ($questions as $question) { $q_list['qs'][] = qa_post_html_fields($question, qa_get_logged_in_userid(), qa_cookie_get(), $usershtml, null, qa_post_html_options($question, $defaults)); } return $q_list; }
public function output_widget($region, $place, $themeobject, $template, $request, $qa_content) { require_once QA_INCLUDE_DIR . 'db/selects.php'; if (!isset($qa_content['q_view']['raw']['type']) || $qa_content['q_view']['raw']['type'] != 'Q') { // question might not be visible, etc... return; } $questionid = $qa_content['q_view']['raw']['postid']; $userid = qa_get_logged_in_userid(); $cookieid = qa_cookie_get(); $questions = qa_db_single_select(qa_db_related_qs_selectspec($userid, $questionid, qa_opt('page_size_related_qs'))); $minscore = qa_match_to_min_score(qa_opt('match_related_qs')); foreach ($questions as $key => $question) { if ($question['score'] < $minscore) { unset($questions[$key]); } } $titlehtml = qa_lang_html(count($questions) ? 'main/related_qs_title' : 'main/no_related_qs_title'); if ($region == 'side') { $themeobject->output('<div class="qa-related-qs">', '<h2 style="margin-top:0; padding-top:0;">', $titlehtml, '</h2>'); $themeobject->output('<ul class="qa-related-q-list">'); foreach ($questions as $question) { $themeobject->output('<li class="qa-related-q-item">' . '<a href="' . qa_q_path_html($question['postid'], $question['title']) . '">' . qa_html($question['title']) . '</a>' . '</li>'); } $themeobject->output('</ul>', '</div>'); } else { $themeobject->output('<h2>', $titlehtml, '</h2>'); $q_list = array('form' => array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote'))), 'qs' => array()); $defaults = qa_post_html_defaults('Q'); $usershtml = qa_userids_handles_html($questions); foreach ($questions as $question) { $q_list['qs'][] = qa_post_html_fields($question, $userid, $cookieid, $usershtml, null, qa_post_html_options($question, $defaults)); } $themeobject->q_list_and_form($q_list); } }
function output_widget($region, $place, $themeobject, $template, $request, $qa_content) { require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; if (@$qa_content['q_view']['raw']['type'] != 'Q') { // question might not be visible, etc... return; } $questionid = $qa_content['q_view']['raw']['postid']; $userid = qa_get_logged_in_userid(); $cookieid = qa_cookie_get(); $questions = qa_db_single_select(qa_db_related_qs_selectspec($userid, $questionid, qa_opt('page_size_related_qs'))); $minscore = qa_match_to_min_score(qa_opt('match_related_qs')); foreach ($questions as $key => $question) { if ($question['score'] < $minscore) { unset($questions[$key]); } } $titlehtml = qa_lang_html(count($questions) ? 'main/related_qs_title' : 'main/no_related_qs_title'); if ($region == 'side') { $themeobject->output('<DIV CLASS="qa-related-qs">', '<H2 STYLE="margin-top:0; padding-top:0;">', $titlehtml, '</H2>'); $themeobject->output('<UL CLASS="qa-related-q-list">'); foreach ($questions as $question) { $themeobject->output('<LI CLASS="qa-related-q-item"><A HREF="' . qa_q_path_html($question['postid'], $question['title']) . '">' . qa_html($question['title']) . '</A></LI>'); } $themeobject->output('</UL>', '</DIV>'); } else { $themeobject->output('<H2>', $titlehtml, '</H2>'); $q_list = array('form' => array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"'), 'qs' => array()); $options = qa_post_html_defaults('Q'); $usershtml = qa_userids_handles_html($questions); foreach ($questions as $question) { $q_list['qs'][] = qa_post_html_fields($question, $userid, $cookieid, $usershtml, null, $options); } $themeobject->q_list_and_form($q_list); } }
*/ require_once QA_INCLUDE_DIR . 'qa-app-users.php'; require_once QA_INCLUDE_DIR . 'qa-app-cookies.php'; require_once QA_INCLUDE_DIR . 'qa-app-votes.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; require_once QA_INCLUDE_DIR . 'qa-app-options.php'; require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; $postid = qa_post_text('postid'); $vote = qa_post_text('vote'); $code = qa_post_text('code'); $userid = qa_get_logged_in_userid(); $cookieid = qa_cookie_get(); if (!qa_check_form_security_code('vote', $code)) { $voteerror = qa_lang_html('misc/form_security_reload'); } else { $post = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $postid)); $voteerror = qa_vote_error_html($post, $vote, $userid, qa_request()); } if ($voteerror === false) { qa_vote_set($post, $userid, qa_get_logged_in_handle(), $cookieid, $vote); $post = qa_db_select_with_pending(qa_db_full_post_selectspec($userid, $postid)); $fields = qa_post_html_fields($post, $userid, $cookieid, array(), null, array('voteview' => qa_get_vote_view($post, true))); $themeclass = qa_load_theme_class(qa_get_site_theme(), 'voting', null, null); echo "QA_AJAX_RESPONSE\n1\n"; $themeclass->voting_inner_html($fields); } else { echo "QA_AJAX_RESPONSE\n0\n" . $voteerror; } /* Omit PHP closing tag to help avoid accidental output */
} $qa_content['q_list']['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote'))); $qa_content['q_list']['qs'] = array(); $qdefaults = qa_post_html_defaults('Q'); foreach ($results as $result) { if (!isset($result['question'])) { // if we have any non-question results, display with less statistics $qdefaults['voteview'] = false; $qdefaults['answersview'] = false; $qdefaults['viewsview'] = false; break; } } foreach ($results as $result) { if (isset($result['question'])) { $fields = qa_post_html_fields($result['question'], $userid, qa_cookie_get(), $usershtml, null, qa_post_html_options($result['question'], $qdefaults)); } elseif (isset($result['url'])) { $fields = array('what' => qa_html($result['url']), 'meta_order' => qa_lang_html('main/meta_order')); } else { continue; } // nothing to show here if (isset($qdefaults['blockwordspreg'])) { $result['title'] = qa_block_words_replace($result['title'], $qdefaults['blockwordspreg']); } $fields['title'] = qa_html($result['title']); $fields['url'] = qa_html($result['url']); $qa_content['q_list']['qs'][] = $fields; } $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $start + $gotcount, qa_opt('pages_prev_next'), array('q' => $inquery), $gotcount >= $count); if (qa_opt('feed_for_search')) {
function qa_page_q_comment_follow_list($parent, $commentsfollows, $alwaysfull, $usershtml, $formrequested, $formpostid) { $parentid = $parent['postid']; $userid = qa_get_logged_in_userid(); $cookieid = qa_cookie_get(); $commentlist = array('tags' => 'ID="c' . qa_html($parentid) . '_list"', 'cs' => array()); $showcomments = array(); foreach ($commentsfollows as $commentfollowid => $commentfollow) { if ($commentfollow['parentid'] == $parentid && $commentfollow['viewable'] && $commentfollowid != $formpostid) { $showcomments[$commentfollowid] = $commentfollow; } } $countshowcomments = count($showcomments); if (!$alwaysfull && $countshowcomments > qa_opt('show_fewer_cs_from')) { $skipfirst = $countshowcomments - qa_opt('show_fewer_cs_count'); } else { $skipfirst = 0; } if ($skipfirst == $countshowcomments) { // showing none if ($skipfirst == 1) { $expandtitle = qa_lang_html('question/show_1_comment'); } else { $expandtitle = qa_lang_html_sub('question/show_x_comments', $skipfirst); } } else { if ($skipfirst == 1) { $expandtitle = qa_lang_html('question/show_1_previous_comment'); } else { $expandtitle = qa_lang_html_sub('question/show_x_previous_comments', $skipfirst); } } if ($skipfirst > 0) { $commentlist['cs'][$parentid] = array('url' => qa_html('?state=showcomments-' . $parentid . '&show=' . $parentid . '#' . urlencode(qa_anchor($parent['basetype'], $parentid))), 'expand_tags' => 'onClick="return qa_show_comments(' . qa_js($parentid) . ', this);"', 'title' => $expandtitle); } foreach ($showcomments as $commentfollowid => $commentfollow) { if ($skipfirst > 0) { $skipfirst--; } elseif ($commentfollow['basetype'] == 'C') { $commentlist['cs'][$commentfollowid] = qa_page_q_comment_view($parent, $commentfollow, $usershtml, $formrequested); } elseif ($commentfollow['basetype'] == 'Q') { $htmloptions = qa_post_html_defaults('Q'); $htmloptions['avatarsize'] = qa_opt('avatar_q_page_c_size'); $commentlist['cs'][$commentfollowid] = qa_post_html_fields($commentfollow, $userid, $cookieid, $usershtml, null, $htmloptions); } } if (!count($commentlist['cs'])) { $commentlist['hidden'] = true; } return $commentlist; }
function qa_any_to_q_html_fields($question, $userid, $cookieid, $usershtml, $dummy, $options) { if (isset($question['opostid'])) { $fields = qa_other_to_q_html_fields($question, $userid, $cookieid, $usershtml, null, $options); } else { $fields = qa_post_html_fields($question, $userid, $cookieid, $usershtml, null, $options); } return $fields; }
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'))); $qa_content['q_list']['qs'] = array(); foreach ($questions as $postid => $question) { $qa_content['q_list']['qs'][] = qa_post_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, qa_post_html_options($question)); } $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $tagword['tagcount'], qa_opt('pages_prev_next')); if (empty($qa_content['page_links'])) { $qa_content['suggest_next'] = qa_html_suggest_qs_tags(true); } if (qa_opt('feed_for_tag_qs')) { $qa_content['feed'] = array('url' => qa_path_html(qa_feed_request('tag/' . $tag)), 'label' => qa_lang_html_sub('main/questions_tagged_x', qa_html($tag))); } return $qa_content; /* Omit PHP closing tag to help avoid accidental output */
if ($relatedcount > 1 && !$question['hidden']) { $minscore = qa_match_to_min_score(qa_opt('match_related_qs')); foreach ($relatedquestions as $key => $related) { if ($related['postid'] == $questionid || $related['score'] < $minscore) { // related questions will include itself so remove that unset($relatedquestions[$key]); } } if (count($relatedquestions)) { $qa_content['q_list']['title'] = qa_lang('main/related_qs_title'); } else { $qa_content['q_list']['title'] = qa_lang('main/no_related_qs_title'); } $qa_content['q_list']['qs'] = array(); foreach ($relatedquestions as $related) { $qa_content['q_list']['qs'][] = qa_post_html_fields($related, $qa_login_userid, $qa_cookieid, $usershtml, null, qa_post_html_defaults('Q')); } } // Some generally useful stuff if (qa_using_categories() && count($categories)) { $qa_content['navigation']['cat'] = qa_category_navigation($categories, $question['categoryid']); } if (isset($jumptoanchor)) { $qa_content['script_onloads'][] = array("window.location.hash=" . qa_js($jumptoanchor) . ";"); } if (isset($focusonid)) { $qa_content['script_onloads'][] = array("document.getElementById(" . qa_js($focusonid) . ").focus();"); } // Determine whether the page view should be counted if (qa_opt('do_count_q_views') && !$formrequested && !qa_is_http_post() && qa_is_human_probably() && (!$question['views'] || ($question['lastviewip'] != qa_remote_ip_address() || !isset($question['lastviewip'])) && ($question['createip'] != qa_remote_ip_address() || !isset($question['createip'])) && ($question['userid'] != $qa_login_userid || !isset($question['userid'])) && ($question['cookieid'] != $qa_cookieid || !isset($question['cookieid'])))) { $qa_content['inc_views_postid'] = $questionid;
require_once QA_INCLUDE_DIR . 'qa-app-users.php'; require_once QA_INCLUDE_DIR . 'qa-app-cookies.php'; require_once QA_INCLUDE_DIR . 'qa-app-votes.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; require_once QA_INCLUDE_DIR . 'qa-app-options.php'; require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; function qa_ajax_vote_db_fail_handler() { echo "QA_AJAX_RESPONSE\n0\nA database error occurred."; exit; } qa_base_db_connect('qa_ajax_vote_db_fail_handler'); $postid = qa_post_text('postid'); $qa_login_userid = qa_get_logged_in_userid(); $qa_cookieid = qa_cookie_get(); $post = qa_db_select_with_pending(qa_db_full_post_selectspec($qa_login_userid, $postid)); $voteerror = qa_vote_error_html($post, $qa_login_userid, $qa_request); if ($voteerror === false) { qa_vote_set($post, $qa_login_userid, qa_get_logged_in_handle(), $qa_cookieid, qa_post_text('vote')); $post = qa_db_select_with_pending(qa_db_full_post_selectspec($qa_login_userid, $postid)); $fields = qa_post_html_fields($post, $qa_login_userid, $qa_cookieid, array(), null, array('voteview' => qa_opt('votes_separated') ? 'updown' : 'net')); $themeclass = qa_load_theme_class(qa_opt('site_theme'), 'voting', null, null); echo "QA_AJAX_RESPONSE\n1\n"; $themeclass->voting_inner_html($fields); } else { echo "QA_AJAX_RESPONSE\n0\n" . $voteerror; } qa_base_db_disconnect(); /* Omit PHP closing tag to help avoid accidental output */
function qa_page_q_comment_follow_list($parent) { global $commentsfollows, $qa_login_userid, $qa_cookieid, $usershtml, $formtype, $formpostid, $formrequested; foreach ($commentsfollows as $commentfollowid => $commentfollow) { if ($commentfollow['parentid'] == $parent['postid'] && $commentfollow['viewable'] && $commentfollowid != $formpostid) { if ($commentfollow['basetype'] == 'C') { $htmloptions = qa_post_html_defaults('C', true); $htmloptions['avatarsize'] = qa_opt('avatar_q_page_c_size'); $c_view = qa_post_html_fields($commentfollow, $qa_login_userid, $qa_cookieid, $usershtml, null, $htmloptions); // Buttons for operating on this comment if (!$formrequested) { // don't show if another form is currently being shown on page $c_view['form'] = array('style' => 'light', 'buttons' => array()); if ($commentfollow['editbutton']) { $c_view['form']['buttons']['edit'] = array('tags' => 'NAME="doeditc_' . qa_html($commentfollowid) . '"', 'label' => qa_lang_html('question/edit_button'), 'popup' => qa_lang_html('question/edit_c_popup')); } if ($commentfollow['flagbutton']) { $c_view['form']['buttons']['flag'] = array('tags' => 'NAME="doflagc_' . qa_html($commentfollowid) . '"', 'label' => qa_lang_html($commentfollow['flagtohide'] ? 'question/flag_hide_button' : 'question/flag_button'), 'popup' => qa_lang_html('question/flag_c_popup')); } if ($commentfollow['unflaggable']) { $c_view['form']['buttons']['unflag'] = array('tags' => 'NAME="dounflagc_' . qa_html($commentfollowid) . '"', 'label' => qa_lang_html('question/unflag_button'), 'popup' => qa_lang_html('question/unflag_popup')); } if ($commentfollow['clearflaggable']) { $c_view['form']['buttons']['clearflags'] = array('tags' => 'NAME="doclearflagsc_' . qa_html($commentfollowid) . '"', 'label' => qa_lang_html('question/clear_flags_button'), 'popup' => qa_lang_html('question/clear_flags_popup')); } if ($commentfollow['hideable']) { $c_view['form']['buttons']['hide'] = array('tags' => 'NAME="dohidec_' . qa_html($commentfollowid) . '"', 'label' => qa_lang_html('question/hide_button'), 'popup' => qa_lang_html('question/hide_c_popup')); } if ($commentfollow['reshowable']) { $c_view['form']['buttons']['reshow'] = array('tags' => 'NAME="doshowc_' . qa_html($commentfollowid) . '"', 'label' => qa_lang_html('question/reshow_button')); } if ($commentfollow['deleteable']) { $c_view['form']['buttons']['delete'] = array('tags' => 'NAME="dodeletec_' . qa_html($commentfollowid) . '"', 'label' => qa_lang_html('question/delete_button'), 'popup' => qa_lang_html('question/delete_c_popup')); } if ($commentfollow['claimable']) { $c_view['form']['buttons']['claim'] = array('tags' => 'NAME="doclaimc_' . qa_html($commentfollowid) . '"', 'label' => qa_lang_html('question/claim_button')); } if ($parent['commentbutton'] && qa_opt('show_c_reply_buttons') && !$commentfollow['hidden']) { $c_view['form']['buttons']['comment'] = array('tags' => 'NAME="' . ($parent['basetype'] == 'Q' ? 'docommentq' : 'docommenta_' . qa_html($parent['postid'])) . '"', 'label' => qa_lang_html('question/reply_button'), 'popup' => qa_lang_html('question/reply_c_popup')); } } } elseif ($commentfollow['basetype'] == 'Q') { $htmloptions = qa_post_html_defaults('Q'); $htmloptions['avatarsize'] = qa_opt('avatar_q_page_c_size'); $c_view = qa_post_html_fields($commentfollow, $qa_login_userid, $qa_cookieid, $usershtml, null, $htmloptions); } $commentlist[] = $c_view; } } return @$commentlist; }
foreach ($results as $result) { if (!isset($result['question'])) { // if we have any non-question results, display with less statistics $questionoptions['voteview'] = false; $questionoptions['answersview'] = false; $questionoptions['viewsview'] = false; $fakeoptions = $questionoptions; $fakeoptions['whoview'] = false; $fakeoptions['whenview'] = false; $fakeoptions['whatview'] = false; break; } } foreach ($results as $result) { if (isset($result['question'])) { $fields = qa_post_html_fields($result['question'], $userid, qa_cookie_get(), $usershtml, null, $questionoptions); } elseif (isset($result['url'])) { $fields = array('what' => qa_html($result['url']), 'meta_order' => qa_lang_html('main/meta_order')); } else { continue; } // nothing to show here $fields['title'] = qa_html($result['title']); $fields['url'] = qa_html($result['url']); $qa_content['q_list']['qs'][] = $fields; } $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $start + $gotcount, qa_opt('pages_prev_next'), array('q' => $inquery), $gotcount >= $count); if (qa_opt('feed_for_search')) { $qa_content['feed'] = array('url' => qa_path_html(qa_feed_request('search/' . $inquery)), 'label' => qa_lang_html_sub('main/results_for_x', qa_html($inquery))); } if (empty($qa_content['page_links'])) {
function ajaxCommentCreate($parent, $cid) { global $qa_login_userid, $qa_cookieid, $usershtml, $formtype, $formpostid, $formrequested; $comment = qa_db_single_select(qa_db_full_post_selectspec(null, $cid)); $htmloptions = qa_post_html_defaults('C', true); $htmloptions['avatarsize'] = qa_opt('avatar_q_page_c_size'); $c_view = qa_post_html_fields($comment, $qa_login_userid, $qa_cookieid, $usershtml, null, $htmloptions); // Buttons for operating on this comment $c_view['form'] = array('style' => 'light', 'buttons' => array()); $c_view['form']['buttons']['edit'] = array('tags' => 'NAME="doeditc_' . qa_html($cid) . '"', 'label' => qa_lang_html('question/edit_button'), 'popup' => qa_lang_html('question/edit_c_popup')); $c_view['form']['buttons']['hide'] = array('tags' => 'NAME="dohidec_' . qa_html($cid) . '"', 'label' => qa_lang_html('question/hide_button'), 'popup' => qa_lang_html('question/hide_c_popup')); $comment['claimable'] = !isset($comment['userid']) && isset($qa_login_userid) && strcmp(@$comment['cookieid'], $qa_cookieid) == 0 && !$permiterror_post_c; if ($comment['claimable']) { $c_view['form']['buttons']['claim'] = array('tags' => 'NAME="doclaimc_' . qa_html($cid) . '"', 'label' => qa_lang_html('question/claim_button')); } $parent['commentbutton'] = qa_user_permit_error('permit_post_c') != 'level' && qa_opt($comment['type'] == 'Q' ? 'comment_on_qs' : 'comment_on_as'); if ($parent['commentbutton'] && qa_opt('show_c_reply_buttons') && !$comment['hidden']) { $c_view['form']['buttons']['comment'] = array('tags' => 'NAME="' . ($parent['basetype'] == 'Q' ? 'docommentq' : 'docommenta_' . qa_html($parent['postid'])) . '"', 'label' => qa_lang_html('question/reply_button'), 'popup' => qa_lang_html('question/reply_c_popup')); } return @$c_view; }
} // Prepare content for theme $qa_content = qa_content_prepare(true); if (strlen(qa_get('q'))) { $qa_content['search']['value'] = qa_html($inquery); } if (isset($questions)) { if (count($questions)) { $qa_content['title'] = qa_lang_html_sub('main/results_for_x', qa_html($inquery)); } else { $qa_content['title'] = qa_lang_html_sub('main/no_results_for_x', qa_html($inquery)); } $qa_content['q_list']['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"'); $qa_content['q_list']['qs'] = array(); foreach ($questions as $question) { $fields = qa_post_html_fields($question, $qa_login_userid, $qa_cookieid, $usershtml, null, qa_post_html_defaults('Q')); $fields['url'] = qa_path_html(qa_q_request($question['postid'], $question['title']), null, null, null, qa_search_max_match_anchor($question)); $qa_content['q_list']['qs'][] = $fields; } $qa_content['page_links'] = qa_html_page_links($qa_request, $qa_start, $pagesize, $qa_start + $gotcount, qa_opt('pages_prev_next'), array('q' => $inquery), $gotcount >= $retrieve); if (qa_opt('feed_for_search')) { $qa_content['feed'] = array('url' => qa_path_html(qa_feed_request('search/' . $inquery)), 'label' => qa_lang_html_sub('main/results_for_x', qa_html($inquery))); } } else { $qa_content['title'] = qa_lang_html('main/search_title'); } if (empty($qa_content['page_links'])) { $qa_content['suggest_next'] = qa_html_suggest_qs_tags(qa_using_tags()); } return $qa_content; /*