function qa_favorite_tags_view($tags) { require_once QA_INCLUDE_DIR . 'app/format.php'; $ranking = array('items' => array(), 'rows' => ceil(count($tags) / qa_opt('columns_tags')), 'type' => 'tags'); foreach ($tags as $tag) { $ranking['items'][] = array('label' => qa_tag_html($tag['word'], false, true), 'count' => qa_html(qa_format_number($tag['tagcount'], 0, true))); } return $ranking; }
// 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'; // Get popular tags $populartags = qa_db_select_with_pending(qa_db_popular_tags_selectspec($qa_start)); $tagcount = qa_opt('cache_tagcount'); $pagesize = qa_opt('page_size_tags'); // Prepare content for theme $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html('main/popular_tags'); $qa_content['ranking'] = array('items' => array(), 'rows' => ceil($pagesize / qa_opt('columns_tags')), 'type' => 'tags'); if (count($populartags)) { $output = 0; foreach ($populartags as $word => $count) { $qa_content['ranking']['items'][] = array('label' => qa_tag_html($word), 'count' => number_format($count)); if (++$output >= $pagesize) { break; } } } else { $qa_content['title'] = qa_lang_html('main/no_tags_found'); } $qa_content['page_links'] = qa_html_page_links($qa_request, $qa_start, $pagesize, $tagcount, qa_opt('pages_prev_next')); if (empty($qa_content['page_links'])) { $qa_content['suggest_next'] = qa_html_suggest_ask(); } return $qa_content; /* Omit PHP closing tag to help avoid accidental output */
require_once QA_INCLUDE_DIR . 'qa-app-format.php'; // Get popular tags $start = qa_get_start(); $userid = qa_get_logged_in_userid(); $populartags = qa_db_select_with_pending(qa_db_popular_tags_selectspec($start, qa_opt_if_loaded('page_size_tags'))); $tagcount = qa_opt('cache_tagcount'); $pagesize = qa_opt('page_size_tags'); // Prepare content for theme $qa_content = qa_content_prepare(); $qa_content['title'] = qa_lang_html('main/popular_tags'); $qa_content['ranking'] = array('items' => array(), 'rows' => ceil($pagesize / qa_opt('columns_tags')), 'type' => 'tags'); if (count($populartags)) { $favoritemap = qa_get_favorite_non_qs_map(); $output = 0; foreach ($populartags as $word => $count) { $qa_content['ranking']['items'][] = array('label' => qa_tag_html($word, false, @$favoritemap['tag'][qa_strtolower($word)]), 'count' => number_format($count)); if (++$output >= $pagesize) { break; } } } else { $qa_content['title'] = qa_lang_html('main/no_tags_found'); } $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $tagcount, qa_opt('pages_prev_next')); if (empty($qa_content['page_links'])) { $qa_content['suggest_next'] = qa_html_suggest_ask(); } return $qa_content; /* Omit PHP closing tag to help avoid accidental output */
function qa_post_html_fields($post, $userid, $cookieid, $usershtml, $dummy, $options = array()) { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } require_once QA_INCLUDE_DIR . 'app/updates.php'; if (isset($options['blockwordspreg'])) { require_once QA_INCLUDE_DIR . 'util/string.php'; } $fields = array('raw' => $post); // Useful stuff used throughout function $postid = $post['postid']; $isquestion = $post['basetype'] == 'Q'; $isanswer = $post['basetype'] == 'A'; $isbyuser = qa_post_is_by_user($post, $userid, $cookieid); $anchor = urlencode(qa_anchor($post['basetype'], $postid)); $elementid = isset($options['elementid']) ? $options['elementid'] : $anchor; $microformats = @$options['microformats']; $isselected = @$options['isselected']; $favoritedview = @$options['favoritedview']; $favoritemap = $favoritedview ? qa_get_favorite_non_qs_map() : array(); // High level information $fields['hidden'] = @$post['hidden']; $fields['tags'] = 'id="' . qa_html($elementid) . '"'; $fields['classes'] = $isquestion && $favoritedview && @$post['userfavoriteq'] ? 'qa-q-favorited' : ''; if ($isquestion && isset($post['closedbyid'])) { $fields['classes'] = ltrim($fields['classes'] . ' qa-q-closed'); } if ($microformats) { $fields['classes'] .= ' hentry ' . ($isquestion ? 'question' : ($isanswer ? $isselected ? 'answer answer-selected' : 'answer' : 'comment')); } // Question-specific stuff (title, URL, tags, answer count, category) if ($isquestion) { if (isset($post['title'])) { $fields['url'] = qa_q_path_html($postid, $post['title']); if (isset($options['blockwordspreg'])) { $post['title'] = qa_block_words_replace($post['title'], $options['blockwordspreg']); } $fields['title'] = qa_html($post['title']); if ($microformats) { $fields['title'] = '<span class="entry-title">' . $fields['title'] . '</span>'; } /*if (isset($post['score'])) // useful for setting match thresholds $fields['title'].=' <small>('.$post['score'].')</small>';*/ } if (@$options['tagsview'] && isset($post['tags'])) { $fields['q_tags'] = array(); $tags = qa_tagstring_to_tags($post['tags']); foreach ($tags as $tag) { if (isset($options['blockwordspreg']) && count(qa_block_words_match_all($tag, $options['blockwordspreg']))) { // skip censored tags continue; } $fields['q_tags'][] = qa_tag_html($tag, $microformats, @$favoritemap['tag'][qa_strtolower($tag)]); } } if (@$options['answersview'] && isset($post['acount'])) { $fields['answers_raw'] = $post['acount']; $fields['answers'] = $post['acount'] == 1 ? qa_lang_html_sub_split('main/1_answer', '1', '1') : qa_lang_html_sub_split('main/x_answers', number_format($post['acount'])); $fields['answer_selected'] = isset($post['selchildid']); } if (@$options['viewsview'] && isset($post['views'])) { $fields['views_raw'] = $post['views']; $fields['views'] = $post['views'] == 1 ? qa_lang_html_sub_split('main/1_view', '1', '1') : qa_lang_html_sub_split('main/x_views', number_format($post['views'])); } if (@$options['categoryview'] && isset($post['categoryname']) && isset($post['categorybackpath'])) { $favoriteclass = ''; if (count(@$favoritemap['category'])) { if (@$favoritemap['category'][$post['categorybackpath']]) { $favoriteclass = ' qa-cat-favorited'; } else { foreach ($favoritemap['category'] as $categorybackpath => $dummy) { if (substr('/' . $post['categorybackpath'], -strlen($categorybackpath)) == $categorybackpath) { $favoriteclass = ' qa-cat-parent-favorited'; } } } } $fields['where'] = qa_lang_html_sub_split('main/in_category_x', '<a href="' . qa_path_html(@$options['categorypathprefix'] . implode('/', array_reverse(explode('/', $post['categorybackpath'])))) . '" class="qa-category-link' . $favoriteclass . '">' . qa_html($post['categoryname']) . '</a>'); } } // Answer-specific stuff (selection) if ($isanswer) { $fields['selected'] = $isselected; if ($isselected) { $fields['select_text'] = qa_lang_html('question/select_text'); } } // Post content if (@$options['contentview'] && isset($post['content'])) { $viewer = qa_load_viewer($post['content'], $post['format']); $fields['content'] = $viewer->get_html($post['content'], $post['format'], array('blockwordspreg' => @$options['blockwordspreg'], 'showurllinks' => @$options['showurllinks'], 'linksnewwindow' => @$options['linksnewwindow'])); if ($microformats) { $fields['content'] = '<div class="entry-content">' . $fields['content'] . '</div>'; } $fields['content'] = '<a name="' . qa_html($postid) . '"></a>' . $fields['content']; // this is for backwards compatibility with any existing links using the old style of anchor // that contained the post id only (changed to be valid under W3C specifications) } // Voting stuff if (@$options['voteview']) { $voteview = $options['voteview']; // Calculate raw values and pass through if (@$options['ovoteview'] && isset($post['opostid'])) { $upvotes = (int) @$post['oupvotes']; $downvotes = (int) @$post['odownvotes']; $fields['vote_opostid'] = true; // for voters/flaggers layer } else { $upvotes = (int) @$post['upvotes']; $downvotes = (int) @$post['downvotes']; } $netvotes = (int) ($upvotes - $downvotes); $fields['upvotes_raw'] = $upvotes; $fields['downvotes_raw'] = $downvotes; $fields['netvotes_raw'] = $netvotes; // Create HTML versions... $upvoteshtml = qa_html($upvotes); $downvoteshtml = qa_html($downvotes); if ($netvotes >= 1) { $netvoteshtml = '+' . qa_html($netvotes); } elseif ($netvotes <= -1) { $netvoteshtml = '–' . qa_html(-$netvotes); } else { $netvoteshtml = '0'; } // ...with microformats if appropriate if ($microformats) { $netvoteshtml .= '<span class="votes-up"><span class="value-title" title="' . $upvoteshtml . '"></span></span>' . '<span class="votes-down"><span class="value-title" title="' . $downvoteshtml . '"></span></span>'; $upvoteshtml = '<span class="votes-up">' . $upvoteshtml . '</span>'; $downvoteshtml = '<span class="votes-down">' . $downvoteshtml . '</span>'; } // Pass information on vote viewing // $voteview will be one of: // updown, updown-disabled-page, updown-disabled-level, updown-uponly-level, updown-disabled-approve, updown-uponly-approve // net, net-disabled-page, net-disabled-level, net-uponly-level, net-disabled-approve, net-uponly-approve $fields['vote_view'] = substr($voteview, 0, 6) == 'updown' ? 'updown' : 'net'; $fields['vote_on_page'] = strpos($voteview, '-disabled-page') ? 'disabled' : 'enabled'; $fields['upvotes_view'] = $upvotes == 1 ? qa_lang_html_sub_split('main/1_liked', $upvoteshtml, '1') : qa_lang_html_sub_split('main/x_liked', $upvoteshtml); $fields['downvotes_view'] = $downvotes == 1 ? qa_lang_html_sub_split('main/1_disliked', $downvoteshtml, '1') : qa_lang_html_sub_split('main/x_disliked', $downvoteshtml); $fields['netvotes_view'] = abs($netvotes) == 1 ? qa_lang_html_sub_split('main/1_vote', $netvoteshtml, '1') : qa_lang_html_sub_split('main/x_votes', $netvoteshtml); // Voting buttons $fields['vote_tags'] = 'id="voting_' . qa_html($postid) . '"'; $onclick = 'onclick="return qa_vote_click(this);"'; if ($fields['hidden']) { $fields['vote_state'] = 'disabled'; $fields['vote_up_tags'] = 'title="' . qa_lang_html($isanswer ? 'main/vote_disabled_hidden_a' : 'main/vote_disabled_hidden_q') . '"'; $fields['vote_down_tags'] = $fields['vote_up_tags']; } elseif ($isbyuser) { $fields['vote_state'] = 'disabled'; $fields['vote_up_tags'] = 'title="' . qa_lang_html($isanswer ? 'main/vote_disabled_my_a' : 'main/vote_disabled_my_q') . '"'; $fields['vote_down_tags'] = $fields['vote_up_tags']; } elseif (strpos($voteview, '-disabled-')) { $fields['vote_state'] = @$post['uservote'] > 0 ? 'voted_up_disabled' : (@$post['uservote'] < 0 ? 'voted_down_disabled' : 'disabled'); if (strpos($voteview, '-disabled-page')) { $fields['vote_up_tags'] = 'title="' . qa_lang_html('main/vote_disabled_q_page_only') . '"'; } elseif (strpos($voteview, '-disabled-approve')) { $fields['vote_up_tags'] = 'title="' . qa_lang_html('main/vote_disabled_approve') . '"'; } else { $fields['vote_up_tags'] = 'title="' . qa_lang_html('main/vote_disabled_level') . '"'; } $fields['vote_down_tags'] = $fields['vote_up_tags']; } elseif (@$post['uservote'] > 0) { $fields['vote_state'] = 'voted_up'; $fields['vote_up_tags'] = 'title="' . qa_lang_html('main/voted_up_popup') . '" name="' . qa_html('vote_' . $postid . '_0_' . $elementid) . '" ' . $onclick; $fields['vote_down_tags'] = ' '; } elseif (@$post['uservote'] < 0) { $fields['vote_state'] = 'voted_down'; $fields['vote_up_tags'] = ' '; $fields['vote_down_tags'] = 'title="' . qa_lang_html('main/voted_down_popup') . '" name="' . qa_html('vote_' . $postid . '_0_' . $elementid) . '" ' . $onclick; } else { $fields['vote_up_tags'] = 'title="' . qa_lang_html('main/vote_up_popup') . '" name="' . qa_html('vote_' . $postid . '_1_' . $elementid) . '" ' . $onclick; if (strpos($voteview, '-uponly-level')) { $fields['vote_state'] = 'up_only'; $fields['vote_down_tags'] = 'title="' . qa_lang_html('main/vote_disabled_down') . '"'; } elseif (strpos($voteview, '-uponly-approve')) { $fields['vote_state'] = 'up_only'; $fields['vote_down_tags'] = 'title="' . qa_lang_html('main/vote_disabled_down_approve') . '"'; } else { $fields['vote_state'] = 'enabled'; $fields['vote_down_tags'] = 'title="' . qa_lang_html('main/vote_down_popup') . '" name="' . qa_html('vote_' . $postid . '_-1_' . $elementid) . '" ' . $onclick; } } } // Flag count if (@$options['flagsview'] && @$post['flagcount']) { $fields['flags'] = $post['flagcount'] == 1 ? qa_lang_html_sub_split('main/1_flag', '1', '1') : qa_lang_html_sub_split('main/x_flags', $post['flagcount']); } // Created when and by whom $fields['meta_order'] = qa_lang_html('main/meta_order'); // sets ordering of meta elements which can be language-specific if (@$options['whatview']) { $fields['what'] = qa_lang_html($isquestion ? 'main/asked' : ($isanswer ? 'main/answered' : 'main/commented')); if (@$options['whatlink'] && strlen(@$options['q_request'])) { $fields['what_url'] = $post['basetype'] == 'Q' ? qa_path_html($options['q_request']) : qa_path_html($options['q_request'], array('show' => $postid), null, null, qa_anchor($post['basetype'], $postid)); } } if (isset($post['created']) && @$options['whenview']) { $fields['when'] = qa_when_to_html($post['created'], @$options['fulldatedays']); if ($microformats) { $fields['when']['data'] = '<span class="published"><span class="value-title" title="' . gmdate('Y-m-d\\TH:i:sO', $post['created']) . '">' . $fields['when']['data'] . '</span></span>'; } } if (@$options['whoview']) { $fields['who'] = qa_who_to_html($isbyuser, @$post['userid'], $usershtml, @$options['ipview'] ? @$post['createip'] : null, $microformats, $post['name']); if (isset($post['points'])) { if (@$options['pointsview']) { $fields['who']['points'] = $post['points'] == 1 ? qa_lang_html_sub_split('main/1_point', '1', '1') : qa_lang_html_sub_split('main/x_points', qa_html(number_format($post['points']))); } if (isset($options['pointstitle'])) { $fields['who']['title'] = qa_get_points_title_html($post['points'], $options['pointstitle']); } } if (isset($post['level'])) { $fields['who']['level'] = qa_html(qa_user_level_string($post['level'])); } } if (@$options['avatarsize'] > 0) { if (QA_FINAL_EXTERNAL_USERS) { $fields['avatar'] = qa_get_external_avatar_html($post['userid'], $options['avatarsize'], false); } else { $fields['avatar'] = qa_get_user_avatar_html(@$post['flags'], @$post['email'], @$post['handle'], @$post['avatarblobid'], @$post['avatarwidth'], @$post['avatarheight'], $options['avatarsize']); } } // Updated when and by whom if (@$options['updateview'] && isset($post['updated']) && ($post['updatetype'] != QA_UPDATE_SELECTED || $isselected) && (!isset($post['created']) || $post['hidden'] && $post['updatetype'] == QA_UPDATE_VISIBLE || isset($post['closedbyid']) && $post['updatetype'] == QA_UPDATE_CLOSED || abs($post['updated'] - $post['created']) > 300 || $post['lastuserid'] != $post['userid'])) { switch ($post['updatetype']) { case QA_UPDATE_TYPE: case QA_UPDATE_PARENT: $langstring = 'main/moved'; break; case QA_UPDATE_CATEGORY: $langstring = 'main/recategorized'; break; case QA_UPDATE_VISIBLE: $langstring = $post['hidden'] ? 'main/hidden' : 'main/reshown'; break; case QA_UPDATE_CLOSED: $langstring = isset($post['closedbyid']) ? 'main/closed' : 'main/reopened'; break; case QA_UPDATE_TAGS: $langstring = 'main/retagged'; break; case QA_UPDATE_SELECTED: $langstring = 'main/selected'; break; default: $langstring = 'main/edited'; break; } $fields['what_2'] = qa_lang_html($langstring); if (@$options['whenview']) { $fields['when_2'] = qa_when_to_html($post['updated'], @$options['fulldatedays']); if ($microformats) { $fields['when_2']['data'] = '<span class="updated"><span class="value-title" title="' . gmdate('Y-m-d\\TH:i:sO', $post['updated']) . '">' . $fields['when_2']['data'] . '</span></span>'; } } if (isset($post['lastuserid']) && @$options['whoview']) { $fields['who_2'] = qa_who_to_html(isset($userid) && $post['lastuserid'] == $userid, $post['lastuserid'], $usershtml, @$options['ipview'] ? $post['lastip'] : null, false); } } elseif ($microformats && @$options['whenview']) { // quick fix for incorrect microformats (missing 'updated' class) $fields['when']['data'] = str_replace('<span class="published">', '<span class="published updated">', $fields['when']['data']); } // That's it! return $fields; }
foreach ($questions as $question) { $qa_content['q_list']['qs'][] = qa_post_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, $options); } } // Favorite users if (!QA_FINAL_EXTERNAL_USERS) { $qa_content['ranking_users'] = array('title' => count($users) ? qa_lang_html('main/nav_users') : qa_lang_html('misc/no_favorite_users'), 'items' => array(), 'rows' => ceil(count($users) / qa_opt('columns_users')), 'type' => 'users'); foreach ($users as $user) { $qa_content['ranking_users']['items'][] = array('label' => qa_get_user_avatar_html($user['flags'], $user['email'], $user['handle'], $user['avatarblobid'], $user['avatarwidth'], $user['avatarheight'], qa_opt('avatar_users_size'), true) . ' ' . $usershtml[$user['userid']], 'score' => qa_html(number_format($user['points']))); } } // Favorite tags if (qa_using_tags()) { $qa_content['ranking_tags'] = array('title' => count($tags) ? qa_lang_html('main/nav_tags') : qa_lang_html('misc/no_favorite_tags'), 'items' => array(), 'rows' => ceil(count($tags) / qa_opt('columns_tags')), 'type' => 'tags'); foreach ($tags as $tag) { $qa_content['ranking_tags']['items'][] = array('label' => qa_tag_html($tag['word']), 'count' => number_format($tag['tagcount'])); } } // Favorite categories if (qa_using_categories()) { $qa_content['nav_list_categories'] = array('title' => count($categories) ? qa_lang_html('main/nav_categories') : qa_lang_html('misc/no_favorite_categories'), 'nav' => array(), 'type' => 'nav-cat'); foreach ($categories as $category) { $qa_content['nav_list_categories']['nav'][$category['categoryid']] = array('label' => qa_html($category['title']), 'state' => 'open', 'note' => ' - <A HREF="' . qa_path_html('questions/' . implode('/', array_reverse(explode('/', $category['backpath'])))) . '">' . ($category['qcount'] == 1 ? qa_lang_html_sub('main/1_question', '1', '1') : qa_lang_html_sub('main/x_questions', number_format($category['qcount']))) . '</A>' . (strlen($category['content']) ? qa_html(' - ' . $category['content']) : '')); } } // Sub navigation for account pages and suggestion $qa_content['suggest_next'] = qa_lang_html_sub('misc/suggest_favorites_add', '<SPAN CLASS="qa-favorite-image"> </SPAN>'); if (!QA_FINAL_EXTERNAL_USERS) { $qa_content['navigation']['sub'] = qa_account_sub_navigation(); } return $qa_content;
function qa_favorite_tags_view($tags) { $ranking = array('items' => array(), 'rows' => ceil(count($tags) / qa_opt('columns_tags')), 'type' => 'tags'); foreach ($tags as $tag) { $ranking['items'][] = array('label' => qa_tag_html($tag['word'], false, true), 'count' => number_format($tag['tagcount'])); } return $ranking; }
function qa_post_html_fields($post, $userid, $cookieid, $usershtml, $dummy, $options = array()) { if (isset($options['blockwordspreg'])) { require_once QA_INCLUDE_DIR . 'qa-util-string.php'; } $fields = array(); $fields['raw'] = $post; // Useful stuff used throughout function $postid = $post['postid']; $isquestion = $post['basetype'] == 'Q'; $isanswer = $post['basetype'] == 'A'; $isbyuser = qa_post_is_by_user($post, $userid, $cookieid); $anchor = urlencode(qa_anchor($post['basetype'], $postid)); $microformats = @$options['microformats']; $isselected = @$options['isselected']; // High level information $fields['hidden'] = $post['hidden']; $fields['tags'] = 'ID="' . $anchor . '"'; if ($microformats) { $fields['classes'] = 'hentry ' . ($isquestion ? 'question' : ($isanswer ? $isselected ? 'answer answer-selected' : 'answer' : 'comment')); } // Question-specific stuff (title, URL, tags, answer count, category) if ($isquestion) { if (isset($post['title'])) { if (isset($options['blockwordspreg'])) { $post['title'] = qa_block_words_replace($post['title'], $options['blockwordspreg']); } $fields['title'] = qa_html($post['title']); if ($microformats) { $fields['title'] = '<SPAN CLASS="entry-title">' . $fields['title'] . '</SPAN>'; } $fields['url'] = qa_path_html(qa_q_request($postid, $post['title'])); /*if (isset($post['score'])) // useful for setting match thresholds $fields['title'].=' <SMALL>('.$post['score'].')</SMALL>';*/ } if (@$options['tagsview'] && isset($post['tags'])) { $fields['q_tags'] = array(); $tags = qa_tagstring_to_tags($post['tags']); foreach ($tags as $tag) { if (isset($options['blockwordspreg']) && count(qa_block_words_match_all($tag, $options['blockwordspreg']))) { // skip censored tags continue; } $fields['q_tags'][] = qa_tag_html($tag, $microformats); } } if (@$options['answersview'] && isset($post['acount'])) { $fields['answers_raw'] = $post['acount']; $fields['answers'] = $post['acount'] == 1 ? qa_lang_html_sub_split('main/1_answer', '1', '1') : qa_lang_html_sub_split('main/x_answers', number_format($post['acount'])); $fields['answer_selected'] = isset($post['selchildid']); } if (@$options['viewsview'] && isset($post['views'])) { $fields['views_raw'] = $post['views']; $fields['views'] = $post['views'] == 1 ? qa_lang_html_sub_split('main/1_view', '1', '1') : qa_lang_html_sub_split('main/x_views', number_format($post['views'])); } if (isset($post['categoryname']) && isset($post['categorybackpath'])) { $fields['where'] = qa_lang_html_sub_split('main/in_category_x', '<A HREF="' . qa_path_html(@$options['categorypathprefix'] . implode('/', array_reverse(explode('/', $post['categorybackpath'])))) . '" CLASS="qa-category-link">' . qa_html($post['categoryname']) . '</A>'); } } // Answer-specific stuff (selection) if ($isanswer) { $fields['selected'] = $isselected; if ($isselected) { $fields['select_text'] = qa_lang_html('question/select_text'); } } // Post content if (!empty($post['content'])) { $viewer = qa_load_viewer($post['content'], $post['format']); $fields['content'] = $viewer->get_html($post['content'], $post['format'], array('blockwordspreg' => @$options['blockwordspreg'], 'showurllinks' => @$options['showurllinks'], 'linksnewwindow' => @$options['linksnewwindow'])); if ($microformats) { $fields['content'] = '<SPAN CLASS="entry-content">' . $fields['content'] . '</SPAN>'; } $fields['content'] = '<A NAME="' . qa_html($postid) . '"></A>' . $fields['content']; // this is for backwards compatibility with any existing links using the old style of anchor // that contained the post id only (changed to be valid under W3C specifications) } // Voting stuff if (@$options['voteview']) { $voteview = $options['voteview']; // Calculate raw values and pass through $upvotes = (int) @$post['upvotes']; $downvotes = (int) @$post['downvotes']; $netvotes = (int) ($upvotes - $downvotes); $fields['upvotes_raw'] = $upvotes; $fields['downvotes_raw'] = $downvotes; $fields['netvotes_raw'] = $netvotes; // Create HTML versions... $upvoteshtml = qa_html($upvotes); $downvoteshtml = qa_html($downvotes); if ($netvotes >= 1) { $netvoteshtml = '+' . qa_html($netvotes); } elseif ($netvotes <= -1) { $netvoteshtml = '–' . qa_html(-$netvotes); } else { $netvoteshtml = '0'; } // ...with microformats if appropriate if ($microformats) { $netvoteshtml .= '<SPAN CLASS="votes-up"><SPAN CLASS="value-title" TITLE="' . $upvoteshtml . '"></SPAN></SPAN>' . '<SPAN CLASS="votes-down"><SPAN CLASS="value-title" TITLE="' . $downvoteshtml . '"></SPAN></SPAN>'; $upvoteshtml = '<SPAN CLASS="votes-up">' . $upvoteshtml . '</SPAN>'; $downvoteshtml = '<SPAN CLASS="votes-down">' . $downvoteshtml . '</SPAN>'; } // Pass information on vote viewing // $voteview will be one of: updown, net, updown-disabled-level, net-disabled-level, updown-disabled-page, net-disabled-page $fields['vote_view'] = substr($voteview, 0, 6) == 'updown' ? 'updown' : 'net'; $fields['upvotes_view'] = $upvotes == 1 ? qa_lang_html_sub_split('main/1_liked', $upvoteshtml, '1') : qa_lang_html_sub_split('main/x_liked', $upvoteshtml); $fields['downvotes_view'] = $downvotes == 1 ? qa_lang_html_sub_split('main/1_disliked', $downvoteshtml, '1') : qa_lang_html_sub_split('main/x_disliked', $downvoteshtml); $fields['netvotes_view'] = abs($netvotes) == 1 ? qa_lang_html_sub_split('main/1_vote', $netvoteshtml, '1') : qa_lang_html_sub_split('main/x_votes', $netvoteshtml); // Voting buttons $fields['vote_tags'] = 'ID="voting_' . qa_html($postid) . '"'; $onclick = 'onClick="return qa_vote_click(this);"'; if ($fields['hidden']) { $fields['vote_state'] = 'disabled'; $fields['vote_up_tags'] = 'TITLE="' . qa_lang_html($isanswer ? 'main/vote_disabled_hidden_a' : 'main/vote_disabled_hidden_q') . '"'; $fields['vote_down_tags'] = $fields['vote_up_tags']; } elseif ($isbyuser) { $fields['vote_state'] = 'disabled'; $fields['vote_up_tags'] = 'TITLE="' . qa_lang_html($isanswer ? 'main/vote_disabled_my_a' : 'main/vote_disabled_my_q') . '"'; $fields['vote_down_tags'] = $fields['vote_up_tags']; } elseif (strpos($voteview, '-disabled-')) { $fields['vote_state'] = @$post['uservote'] > 0 ? 'voted_up_disabled' : (@$post['uservote'] < 0 ? 'voted_down_disabled' : 'disabled'); if (strpos($voteview, '-disabled-page')) { $fields['vote_up_tags'] = 'TITLE="' . qa_lang_html('main/vote_disabled_q_page_only') . '"'; } else { $fields['vote_up_tags'] = 'TITLE="' . qa_lang_html('main/vote_disabled_level') . '"'; } $fields['vote_down_tags'] = $fields['vote_up_tags']; } elseif (@$post['uservote'] > 0) { $fields['vote_state'] = 'voted_up'; $fields['vote_up_tags'] = 'TITLE="' . qa_lang_html('main/voted_up_popup') . '" NAME="' . qa_html('vote_' . $postid . '_0_' . $anchor) . '"' . $onclick; $fields['vote_down_tags'] = ' '; } elseif (@$post['uservote'] < 0) { $fields['vote_state'] = 'voted_down'; $fields['vote_up_tags'] = ' '; $fields['vote_down_tags'] = 'TITLE="' . qa_lang_html('main/voted_down_popup') . '" NAME="' . qa_html('vote_' . $postid . '_0_' . $anchor) . '" ' . $onclick; } else { $fields['vote_state'] = 'enabled'; $fields['vote_up_tags'] = 'TITLE="' . qa_lang_html('main/vote_up_popup') . '" NAME="' . qa_html('vote_' . $postid . '_1_' . $anchor) . '" ' . $onclick; $fields['vote_down_tags'] = 'TITLE="' . qa_lang_html('main/vote_down_popup') . '" NAME="' . qa_html('vote_' . $postid . '_-1_' . $anchor) . '" ' . $onclick; } } // Flag count if (@$options['flagsview'] && @$post['flagcount']) { $fields['flags'] = $post['flagcount'] == 1 ? qa_lang_html_sub_split('main/1_flag', '1', '1') : qa_lang_html_sub_split('main/x_flags', $post['flagcount']); } // Created when and by whom $fields['meta_order'] = qa_lang_html('main/meta_order'); // sets ordering of meta elements which can be language-specific $fields['what'] = qa_lang_html($isquestion ? 'main/asked' : ($isanswer ? 'main/answered' : 'main/commented')); if (@$options['whatlink'] && !$isquestion) { $fields['what_url'] = '#' . qa_html(urlencode($anchor)); } if (isset($post['created']) && @$options['whenview']) { $whenhtml = qa_html(qa_time_to_string(qa_opt('db_time') - $post['created'])); if ($microformats) { $whenhtml = '<SPAN CLASS="published"><SPAN CLASS="value-title" TITLE="' . gmdate('Y-m-d\\TH:i:sO', $post['created']) . '"></SPAN>' . $whenhtml . '</SPAN>'; } $fields['when'] = qa_lang_html_sub_split('main/x_ago', $whenhtml); } if (@$options['whoview']) { $fields['who'] = qa_who_to_html($isbyuser, @$post['userid'], $usershtml, @$options['ipview'] ? @$post['createip'] : null, $microformats); if (isset($post['points'])) { if (@$options['pointsview']) { $fields['who']['points'] = $post['points'] == 1 ? qa_lang_html_sub_split('main/1_point', '1', '1') : qa_lang_html_sub_split('main/x_points', qa_html(number_format($post['points']))); } if (isset($options['pointstitle'])) { $fields['who']['title'] = qa_get_points_title_html($post['points'], $options['pointstitle']); } } if (isset($post['level'])) { $fields['who']['level'] = qa_html(qa_user_level_string($post['level'])); } } if (!QA_FINAL_EXTERNAL_USERS && @$options['avatarsize'] > 0) { $fields['avatar'] = qa_get_user_avatar_html($post['flags'], $post['email'], $post['handle'], $post['avatarblobid'], $post['avatarwidth'], $post['avatarheight'], $options['avatarsize']); } // Updated when and by whom if (isset($post['updated']) && (!isset($post['created']) || $post['hidden'] || abs($post['updated'] - $post['created']) > 300 || $post['lastuserid'] != $post['userid'])) { if (@$options['whenview']) { $whenhtml = qa_html(qa_time_to_string(qa_opt('db_time') - $post['updated'])); if ($microformats) { $whenhtml = '<SPAN CLASS="updated"><SPAN CLASS="value-title" TITLE="' . gmdate('Y-m-d\\TH:i:sO', $post['updated']) . '"></SPAN>' . $whenhtml . '</SPAN>'; } $fields['when_2'] = qa_lang_html_sub_split($fields['hidden'] ? 'question/hidden_x_ago' : 'question/edited_x_ago', $whenhtml); } else { $fields['when_2']['prefix'] = qa_lang_html($fields['hidden'] ? 'question/hidden' : 'main/edited'); } if ($fields['hidden'] && $post['flagcount'] && !isset($post['lastuserid'])) { } else { $fields['who_2'] = qa_who_to_html(isset($userid) && $post['lastuserid'] == $userid, $post['lastuserid'], $usershtml, @$options['ipview'] ? $post['lastip'] : null, false); } } // That's it! return $fields; }