function it_q_list_page_content($questions, $pagesize, $start, $count, $sometitle, $nonetitle, $navcategories, $categoryid, $categoryqcount, $categorypathprefix, $feedpathprefix, $suggest, $pagelinkparams = null, $categoryparams = null, $dummy = null) { require_once QA_INCLUDE_DIR . 'qa-app-format.php'; require_once QA_INCLUDE_DIR . 'qa-app-updates.php'; $userid = qa_get_logged_in_userid(); // Chop down to size, get user information for display if (isset($pagesize)) { $questions = array_slice($questions, 0, $pagesize); } $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions)); $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(); if (count($questions)) { $qa_content['title'] = $sometitle; $defaults = qa_post_html_defaults('Q'); foreach ($questions as $question) { $qa_content['q_list']['qs'][] = qa_any_to_q_html_fields($question, $userid, it_cookie_get(), $usershtml, null, qa_post_html_options($question, $defaults)); } } else { $qa_content['title'] = $nonetitle; } if (isset($count) && isset($pagesize)) { $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'), $pagelinkparams); } return $qa_content; }
function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitle, $nonetitle, $navcategories, $categoryid, $categoryqcount, $categorypathprefix, $feedpathprefix, $suggest, $pagelinkparams = null, $categoryparams = null, $dummy = null) { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } require_once QA_INCLUDE_DIR . 'app/format.php'; require_once QA_INCLUDE_DIR . 'app/updates.php'; $userid = qa_get_logged_in_userid(); // Chop down to size, get user information for display if (isset($pagesize)) { $questions = array_slice($questions, 0, $pagesize); } $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions)); // Prepare content for theme $qa_content = qa_content_prepare(true, array_keys(qa_category_path($navcategories, $categoryid))); $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(); if (count($questions)) { $qa_content['title'] = $sometitle; $defaults = qa_post_html_defaults('Q'); if (isset($categorypathprefix)) { $defaults['categorypathprefix'] = $categorypathprefix; } foreach ($questions as $question) { $fields = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, qa_post_html_options($question, $defaults)); if (!empty($fields['raw']['closedbyid'])) { $fields['closed'] = array('state' => qa_lang_html('main/closed')); } $qa_content['q_list']['qs'][] = $fields; } } else { $qa_content['title'] = $nonetitle; } if (isset($userid) && isset($categoryid)) { $favoritemap = qa_get_favorite_non_qs_map(); $categoryisfavorite = @$favoritemap['category'][$navcategories[$categoryid]['backpath']]; $qa_content['favorite'] = qa_favorite_form(QA_ENTITY_CATEGORY, $categoryid, $categoryisfavorite, qa_lang_sub($categoryisfavorite ? 'main/remove_x_favorites' : 'main/add_category_x_favorites', $navcategories[$categoryid]['title'])); } if (isset($count) && isset($pagesize)) { $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'), $pagelinkparams); } if (empty($qa_content['page_links'])) { $qa_content['suggest_next'] = $suggest; } if (qa_using_categories() && count($navcategories) && isset($categorypathprefix)) { $qa_content['navigation']['cat'] = qa_category_navigation($navcategories, $categoryid, $categorypathprefix, $categoryqcount, $categoryparams); } if (isset($feedpathprefix) && (qa_opt('feed_per_category') || !isset($categoryid))) { $qa_content['feed'] = array('url' => qa_path_html(qa_feed_request($feedpathprefix . (isset($categoryid) ? '/' . qa_category_path_request($navcategories, $categoryid) : ''))), 'label' => strip_tags($sometitle)); } return $qa_content; }
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; }
function get_user_activity($handle, $limit = 10) { $userid = qa_handle_to_userid($handle); require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; $identifier = QA_FINAL_EXTERNAL_USERS ? $userid : $handle; list($useraccount, $questions, $answerqs, $commentqs, $editqs) = qa_db_select_with_pending(QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_account_selectspec($handle, false), qa_db_user_recent_qs_selectspec($userid, $identifier, $limit), qa_db_user_recent_a_qs_selectspec($userid, $identifier), qa_db_user_recent_c_qs_selectspec($userid, $identifier), qa_db_user_recent_edit_qs_selectspec($userid, $identifier)); if (!QA_FINAL_EXTERNAL_USERS && !is_array($useraccount)) { // check the user exists return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; } // Get information on user references $questions = qa_any_sort_and_dedupe(array_merge($questions, $answerqs, $commentqs, $editqs)); $questions = array_slice($questions, 0, $limit); $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions), false); $htmldefaults = qa_post_html_defaults('Q'); $htmldefaults['whoview'] = false; $htmldefaults['voteview'] = false; $htmldefaults['avatarsize'] = 0; foreach ($questions as $question) { $qa_content[] = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, array('voteview' => false) + qa_post_html_options($question, $htmldefaults)); } $output = '<div class="user-activities">'; $output .= '<ul>'; if (isset($qa_content)) { foreach ($qa_content as $qs) { $icon = 'icon-time undefined'; $output .= '<li class="activity-item">'; $output .= '<div class="list-right">'; $output .= '<div class="type pull-left ' . $icon . '"></div>'; $output .= '<div class="what"><a class="what-task" href="' . @$qs['url'] . '">' . $qs['what'] . '</a>'; $output .= '<a href="' . $qs['url'] . '">' . $qs['title'] . '</a> </div>'; $output .= '<strong class="when">' . implode(' ', $qs['when']) . '</strong>'; $output .= '</div>'; $output .= '</li>'; } } else { $output .= '<li>' . qa_lang('cleanstrap/no_activity_yet') . '</li>'; } $output .= '</ul>'; $output .= '</div>'; return $output; }
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); } }
$usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions)); // Create list of actual hidden postids and see which ones have dependents $qhiddenpostid = array(); foreach ($questions as $key => $question) { $qhiddenpostid[$key] = isset($question['opostid']) ? $question['opostid'] : $question['postid']; } $dependcounts = qa_db_postids_count_dependents($qhiddenpostid); // Prepare content for theme $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html('admin/recent_hidden_title'); $qa_content['error'] = isset($pageerror) ? $pageerror : qa_admin_page_error(); $qa_content['q_list'] = array('form' => array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('admin/click'))), 'qs' => array()); if (count($questions)) { foreach ($questions as $key => $question) { $elementid = 'p' . $qhiddenpostid[$key]; $htmloptions = qa_post_html_options($question); $htmloptions['voteview'] = false; $htmloptions['tagsview'] = !isset($question['opostid']); $htmloptions['answersview'] = false; $htmloptions['viewsview'] = false; $htmloptions['updateview'] = false; $htmloptions['contentview'] = true; $htmloptions['flagsview'] = true; $htmloptions['elementid'] = $elementid; $htmlfields = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, $htmloptions); if (isset($htmlfields['what_url'])) { // link directly to relevant content $htmlfields['url'] = $htmlfields['what_url']; } $htmlfields['what_2'] = qa_lang_html('main/hidden'); if (@$htmloptions['whenview']) {
} $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')) {
if (!QA_FINAL_EXTERNAL_USERS && !is_array($useraccount)) { // check the user exists return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; } // Get information on user references $questions = qa_any_sort_and_dedupe(array_merge($questions, $answerqs, $commentqs, $editqs)); $questions = array_slice($questions, 0, qa_opt('page_size_activity')); $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions), false); // Prepare content for theme $qa_content = qa_content_prepare(true); if (count($questions)) { $qa_content['title'] = qa_lang_html_sub('profile/recent_activity_by_x', $userhtml); } else { $qa_content['title'] = qa_lang_html_sub('profile/no_posts_by_x', $userhtml); } // Recent activity by this user $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(); $htmldefaults = qa_post_html_defaults('Q'); $htmldefaults['whoview'] = false; $htmldefaults['voteview'] = false; $htmldefaults['avatarsize'] = 0; foreach ($questions as $question) { $qa_content['q_list']['qs'][] = qa_any_to_q_html_fields($question, $loginuserid, qa_cookie_get(), $usershtml, null, array('voteview' => false) + qa_post_html_options($question, $htmldefaults)); } // Sub menu for navigation in user pages $qa_content['navigation']['sub'] = qa_user_sub_navigation($handle, 'activity', isset($loginuserid) && $loginuserid == (QA_FINAL_EXTERNAL_USERS ? $userid : $useraccount['userid'])); return $qa_content; /* Omit PHP closing tag to help avoid accidental output */
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 */
$count = (int) @$userpoints['aposts']; $questions = array_slice($questions, 0, $pagesize); $usershtml = qa_userids_handles_html($questions, false); // Prepare content for theme $qa_content = qa_content_prepare(true); if (count($questions)) { $qa_content['title'] = qa_lang_html_sub('profile/answers_by_x', $userhtml); } else { $qa_content['title'] = qa_lang_html_sub('profile/no_answers_by_x', $userhtml); } // Recent questions by this user $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(); $htmldefaults = qa_post_html_defaults('Q'); $htmldefaults['whoview'] = false; $htmldefaults['avatarsize'] = 0; $htmldefaults['ovoteview'] = true; $htmldefaults['answersview'] = false; foreach ($questions as $question) { $options = qa_post_html_options($question, $htmldefaults); $options['voteview'] = qa_get_vote_view('A', false, false); $qa_content['q_list']['qs'][] = qa_other_to_q_html_fields($question, $loginuserid, qa_cookie_get(), $usershtml, null, $options); } $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next')); // Sub menu for navigation in user pages $ismyuser = isset($loginuserid) && $loginuserid == (QA_FINAL_EXTERNAL_USERS ? $userid : $useraccount['userid']); $qa_content['navigation']['sub'] = qa_user_sub_navigation($handle, 'answers', $ismyuser); return $qa_content; /* Omit PHP closing tag to help avoid accidental output */
function qa_page_q_comment_follow_list($question, $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($question['postid']) . ', ' . 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($question, $parent, $commentfollow, $usershtml, $formrequested); } elseif ($commentfollow['basetype'] == 'Q') { $htmloptions = qa_post_html_options($commentfollow); $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 get_user_activity($handle) { $userid = qa_handle_to_userid($handle); require_once QA_INCLUDE_DIR . 'qa-db-selects.php'; require_once QA_INCLUDE_DIR . 'qa-app-format.php'; $loginuserid = qa_get_logged_in_userid(); $identifier = QA_FINAL_EXTERNAL_USERS ? $userid : $handle; list($useraccount, $questions, $answerqs, $commentqs, $editqs) = qa_db_select_with_pending(QA_FINAL_EXTERNAL_USERS ? null : qa_db_user_account_selectspec($handle, false), qa_db_user_recent_qs_selectspec($loginuserid, $identifier, qa_opt_if_loaded('page_size_activity')), qa_db_user_recent_a_qs_selectspec($loginuserid, $identifier), qa_db_user_recent_c_qs_selectspec($loginuserid, $identifier), qa_db_user_recent_edit_qs_selectspec($loginuserid, $identifier)); if (!QA_FINAL_EXTERNAL_USERS && !is_array($useraccount)) { // check the user exists return include QA_INCLUDE_DIR . 'qa-page-not-found.php'; } // Get information on user references $questions = qa_any_sort_and_dedupe(array_merge($questions, $answerqs, $commentqs, $editqs)); $questions = array_slice($questions, 0, qa_opt('page_size_activity')); $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions), false); $htmldefaults = qa_post_html_defaults('Q'); $htmldefaults['whoview'] = false; $htmldefaults['voteview'] = false; $htmldefaults['avatarsize'] = 0; foreach ($questions as $question) { $qa_content[] = qa_any_to_q_html_fields($question, $loginuserid, qa_cookie_get(), $usershtml, null, array('voteview' => false) + qa_post_html_options($question, $htmldefaults)); } $output = '<div class="widget user-activities">'; $output .= '<h3 class="widget-title">' . ra_name($handle) . '\'s ' . _ra_lang('activities') . '</h3>'; $output .= '<ul class="question-list">'; if (isset($qa_content)) { foreach ($qa_content as $qs) { if ($qs['what'] == 'answered') { $icon = 'icon-chat-3 answered'; } elseif ($qs['what'] == 'asked') { $icon = 'icon-question asked'; } elseif ($qs['what'] == 'commented') { $icon = 'icon-chat-2 commented'; } elseif ($qs['what'] == 'edited' || $qs['what'] == 'answer edited') { $icon = 'icon-edit edited'; } elseif ($qs['what'] == 'closed') { $icon = 'icon-error closed'; } elseif ($qs['what'] == 'answer selected') { $icon = 'icon-checked selected'; } elseif ($qs['what'] == 'recategorized') { $icon = 'icon-folder-close recategorized'; } else { $icon = 'icon-pin undefined'; } $output .= '<li class="activity-item">'; $output .= '<div class="type pull-left ' . $icon . '"></div>'; $output .= '<div class="list-right">'; $output .= '<h5 class="when"><a href="' . @$qs['what_url'] . '">' . $qs['what'] . '</a> ' . implode(' ', $qs['when']) . '</h5>'; $output .= '<h5 class="what"><a href="' . $qs['url'] . '">' . $qs['title'] . '</a></h5>'; $output .= '</div>'; $output .= '</li>'; } } else { $output .= '<li>' . _ra_lang('No activity yet.') . '</li>'; } $output .= '</ul>'; $output .= '</div>'; return $output; }