function qa_other_to_q_html_fields($question, $userid, $cookieid, $usershtml, $dummy, $options) { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } require_once QA_INCLUDE_DIR . 'app/updates.php'; $fields = qa_post_html_fields($question, $userid, $cookieid, $usershtml, null, $options); switch ($question['obasetype'] . '-' . @$question['oupdatetype']) { case 'Q-': $langstring = 'main/asked'; break; case 'Q-' . QA_UPDATE_VISIBLE: if (@$question['opersonal']) { $langstring = $question['hidden'] ? 'misc/your_q_hidden' : 'misc/your_q_reshown'; } else { $langstring = $question['hidden'] ? 'main/hidden' : 'main/reshown'; } break; case 'Q-' . QA_UPDATE_CLOSED: if (@$question['opersonal']) { $langstring = isset($question['closedbyid']) ? 'misc/your_q_closed' : 'misc/your_q_reopened'; } else { $langstring = isset($question['closedbyid']) ? 'main/closed' : 'main/reopened'; } break; case 'Q-' . QA_UPDATE_TAGS: $langstring = @$question['opersonal'] ? 'misc/your_q_retagged' : 'main/retagged'; break; case 'Q-' . QA_UPDATE_CATEGORY: $langstring = @$question['opersonal'] ? 'misc/your_q_recategorized' : 'main/recategorized'; break; case 'A-': $langstring = @$question['opersonal'] ? 'misc/your_q_answered' : 'main/answered'; break; case 'A-' . QA_UPDATE_SELECTED: $langstring = @$question['opersonal'] ? 'misc/your_a_selected' : 'main/answer_selected'; break; case 'A-' . QA_UPDATE_VISIBLE: if (@$question['opersonal']) { $langstring = $question['ohidden'] ? 'misc/your_a_hidden' : 'misc/your_a_reshown'; } else { $langstring = $question['ohidden'] ? 'main/hidden' : 'main/answer_reshown'; } break; case 'A-' . QA_UPDATE_CONTENT: $langstring = @$question['opersonal'] ? 'misc/your_a_edited' : 'main/answer_edited'; break; case 'Q-' . QA_UPDATE_FOLLOWS: $langstring = @$question['opersonal'] ? 'misc/your_a_questioned' : 'main/asked_related_q'; break; case 'C-': $langstring = 'main/commented'; break; case 'C-' . QA_UPDATE_C_FOR_Q: $langstring = @$question['opersonal'] ? 'misc/your_q_commented' : 'main/commented'; break; case 'C-' . QA_UPDATE_C_FOR_A: $langstring = @$question['opersonal'] ? 'misc/your_a_commented' : 'main/commented'; break; case 'C-' . QA_UPDATE_FOLLOWS: $langstring = @$question['opersonal'] ? 'misc/your_c_followed' : 'main/commented'; break; case 'C-' . QA_UPDATE_TYPE: $langstring = @$question['opersonal'] ? 'misc/your_c_moved' : 'main/comment_moved'; break; case 'C-' . QA_UPDATE_VISIBLE: if (@$question['opersonal']) { $langstring = $question['ohidden'] ? 'misc/your_c_hidden' : 'misc/your_c_reshown'; } else { $langstring = $question['ohidden'] ? 'main/hidden' : 'main/comment_reshown'; } break; case 'C-' . QA_UPDATE_CONTENT: $langstring = @$question['opersonal'] ? 'misc/your_c_edited' : 'main/comment_edited'; break; case 'Q-' . QA_UPDATE_CONTENT: default: $langstring = @$question['opersonal'] ? 'misc/your_q_edited' : 'main/edited'; break; } $fields['what'] = qa_lang_html($langstring); if (@$question['opersonal']) { $fields['what_your'] = true; } if ($question['obasetype'] != 'Q' || @$question['oupdatetype'] == QA_UPDATE_FOLLOWS) { $fields['what_url'] = qa_q_path_html($question['postid'], $question['title'], false, $question['obasetype'], $question['opostid']); } if (@$options['contentview'] && !empty($question['ocontent'])) { $viewer = qa_load_viewer($question['ocontent'], $question['oformat']); $fields['content'] = $viewer->get_html($question['ocontent'], $question['oformat'], array('blockwordspreg' => @$options['blockwordspreg'], 'showurllinks' => @$options['showurllinks'], 'linksnewwindow' => @$options['linksnewwindow'])); } if (@$options['whenview']) { $fields['when'] = qa_when_to_html($question['otime'], @$options['fulldatedays']); } if (@$options['whoview']) { $isbyuser = qa_post_is_by_user(array('userid' => $question['ouserid'], 'cookieid' => @$question['ocookieid']), $userid, $cookieid); $fields['who'] = qa_who_to_html($isbyuser, $question['ouserid'], $usershtml, @$options['ipview'] ? @$question['oip'] : null, false, @$question['oname']); if (isset($question['opoints'])) { if (@$options['pointsview']) { $fields['who']['points'] = $question['opoints'] == 1 ? qa_lang_html_sub_split('main/1_point', '1', '1') : qa_lang_html_sub_split('main/x_points', qa_html(number_format($question['opoints']))); } if (isset($options['pointstitle'])) { $fields['who']['title'] = qa_get_points_title_html($question['opoints'], $options['pointstitle']); } } if (isset($question['olevel'])) { $fields['who']['level'] = qa_html(qa_user_level_string($question['olevel'])); } } unset($fields['flags']); if (@$options['flagsview'] && @$question['oflagcount']) { $fields['flags'] = $question['oflagcount'] == 1 ? qa_lang_html_sub_split('main/1_flag', '1', '1') : qa_lang_html_sub_split('main/x_flags', $question['oflagcount']); } unset($fields['avatar']); if (@$options['avatarsize'] > 0) { if (QA_FINAL_EXTERNAL_USERS) { $fields['avatar'] = qa_get_external_avatar_html($question['ouserid'], $options['avatarsize'], false); } else { $fields['avatar'] = qa_get_user_avatar_html($question['oflags'], $question['oemail'], $question['ohandle'], $question['oavatarblobid'], $question['oavatarwidth'], $question['oavatarheight'], $options['avatarsize']); } } return $fields; }
} elseif ($formtype == 'c_edit' && @$commentsfollows[$formpostid]['parentid'] == $answerid) { // ...being edited $a_view['c_form'] = qa_page_q_edit_c_form($qa_content, 'c' . $formpostid, $commentsfollows[$formpostid], @$ceditin[$formpostid], @$cediterrors[$formpostid]); $jumptoanchor = 'c' . $formpostid; $commentsall = $answerid; } $a_view['c_list'] = qa_page_q_comment_follow_list($question, $answer, $commentsfollows, $commentsall == $answerid, $usershtml, $formrequested, $formpostid); // ...for viewing // Add the answer to the list $qa_content['a_list']['as'][] = $a_view; } } if ($question['basetype'] == 'Q') { $qa_content['a_list']['title_tags'] = 'id="a_list_title"'; if ($countfortitle > 0) { $split = $countfortitle == 1 ? qa_lang_html_sub_split('question/1_answer_title', '1', '1') : qa_lang_html_sub_split('question/x_answers_title', $countfortitle); if ($microdata) { $split['data'] = '<span itemprop="answerCount">' . $split['data'] . '</span>'; } $qa_content['a_list']['title'] = $split['prefix'] . $split['data'] . $split['suffix']; } else { $qa_content['a_list']['title_tags'] .= ' style="display:none;" '; } } if (!$formrequested) { $qa_content['page_links'] = qa_html_page_links(qa_request(), $pagestart, $pagesize, $countforpages, qa_opt('pages_prev_next'), array(), false, 'a_list_title'); } // Some generally useful stuff if (qa_using_categories() && count($categories)) { $qa_content['navigation']['cat'] = qa_category_navigation($categories, $question['categoryid']); }
function qa_content_prepare($voting = false, $categoryids = null) { if (qa_to_override(__FUNCTION__)) { $args = func_get_args(); return qa_call_override(__FUNCTION__, $args); } global $qa_template, $qa_page_error_html; if (QA_DEBUG_PERFORMANCE) { global $qa_usage; $qa_usage->mark('control'); } $request = qa_request(); $requestlower = qa_request(); $navpages = qa_db_get_pending_result('navpages'); $widgets = qa_db_get_pending_result('widgets'); if (isset($categoryids) && !is_array($categoryids)) { // accept old-style parameter $categoryids = array($categoryids); } $lastcategoryid = count($categoryids) ? end($categoryids) : null; $charset = 'utf-8'; $qa_content = array('content_type' => 'text/html; charset=' . $charset, 'charset' => $charset, 'direction' => qa_opt('site_text_direction'), 'site_title' => qa_html(qa_opt('site_title')), 'head_lines' => array(), 'navigation' => array('user' => array(), 'main' => array(), 'footer' => array('feedback' => array('url' => qa_path_html('feedback'), 'label' => qa_lang_html('main/nav_feedback')))), 'sidebar' => qa_opt('show_custom_sidebar') ? qa_opt('custom_sidebar') : null, 'sidepanel' => qa_opt('show_custom_sidepanel') ? qa_opt('custom_sidepanel') : null, 'widgets' => array()); if (qa_opt('show_custom_in_head')) { $qa_content['head_lines'][] = qa_opt('custom_in_head'); } if (qa_opt('show_custom_header')) { $qa_content['body_header'] = qa_opt('custom_header'); } if (qa_opt('show_custom_footer')) { $qa_content['body_footer'] = qa_opt('custom_footer'); } if (isset($categoryids)) { $qa_content['categoryids'] = $categoryids; } foreach ($navpages as $page) { if ($page['nav'] == 'B') { qa_navigation_add_page($qa_content['navigation']['main'], $page); } } if (qa_opt('nav_home') && qa_opt('show_custom_home')) { $qa_content['navigation']['main']['$'] = array('url' => qa_path_html(''), 'label' => qa_lang_html('main/nav_home')); } if (qa_opt('nav_activity')) { $qa_content['navigation']['main']['activity'] = array('url' => qa_path_html('activity'), 'label' => qa_lang_html('main/nav_activity')); } $hascustomhome = qa_has_custom_home(); if (qa_opt($hascustomhome ? 'nav_qa_not_home' : 'nav_qa_is_home')) { $qa_content['navigation']['main'][$hascustomhome ? 'qa' : '$'] = array('url' => qa_path_html($hascustomhome ? 'qa' : ''), 'label' => qa_lang_html('main/nav_qa')); } if (qa_opt('nav_questions')) { $qa_content['navigation']['main']['questions'] = array('url' => qa_path_html('questions'), 'label' => qa_lang_html('main/nav_qs')); } if (qa_opt('nav_hot')) { $qa_content['navigation']['main']['hot'] = array('url' => qa_path_html('hot'), 'label' => qa_lang_html('main/nav_hot')); } if (qa_opt('nav_unanswered')) { $qa_content['navigation']['main']['unanswered'] = array('url' => qa_path_html('unanswered'), 'label' => qa_lang_html('main/nav_unanswered')); } if (qa_using_tags() && qa_opt('nav_tags')) { $qa_content['navigation']['main']['tag'] = array('url' => qa_path_html('tags'), 'label' => qa_lang_html('main/nav_tags'), 'selected_on' => array('tags$', 'tag/')); } if (qa_using_categories() && qa_opt('nav_categories')) { $qa_content['navigation']['main']['categories'] = array('url' => qa_path_html('categories'), 'label' => qa_lang_html('main/nav_categories'), 'selected_on' => array('categories$', 'categories/')); } if (qa_opt('nav_users')) { $qa_content['navigation']['main']['user'] = array('url' => qa_path_html('users'), 'label' => qa_lang_html('main/nav_users'), 'selected_on' => array('users$', 'users/', 'user/')); } // Only the 'level' permission error prevents the menu option being shown - others reported on qa-page-ask.php if (qa_opt('nav_ask') && qa_user_maximum_permit_error('permit_post_q') != 'level') { $qa_content['navigation']['main']['ask'] = array('url' => qa_path_html('ask', qa_using_categories() && strlen($lastcategoryid) ? array('cat' => $lastcategoryid) : null), 'label' => qa_lang_html('main/nav_ask')); } if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN || !qa_user_maximum_permit_error('permit_moderate') || !qa_user_maximum_permit_error('permit_hide_show') || !qa_user_maximum_permit_error('permit_delete_hidden')) { $qa_content['navigation']['main']['admin'] = array('url' => qa_path_html('admin'), 'label' => qa_lang_html('main/nav_admin'), 'selected_on' => array('admin/')); } $qa_content['search'] = array('form_tags' => 'method="get" action="' . qa_path_html('search') . '"', 'form_extra' => qa_path_form_html('search'), 'title' => qa_lang_html('main/search_title'), 'field_tags' => 'name="q"', 'button_label' => qa_lang_html('main/search_button')); if (!qa_opt('feedback_enabled')) { unset($qa_content['navigation']['footer']['feedback']); } foreach ($navpages as $page) { if ($page['nav'] == 'M' || $page['nav'] == 'O' || $page['nav'] == 'F') { qa_navigation_add_page($qa_content['navigation'][$page['nav'] == 'F' ? 'footer' : 'main'], $page); } } $regioncodes = array('F' => 'full', 'M' => 'main', 'S' => 'side'); $placecodes = array('T' => 'top', 'H' => 'high', 'L' => 'low', 'B' => 'bottom'); foreach ($widgets as $widget) { if (is_numeric(strpos(',' . $widget['tags'] . ',', ',' . $qa_template . ',')) || is_numeric(strpos(',' . $widget['tags'] . ',', ',all,'))) { // see if it has been selected for display on this template $region = @$regioncodes[substr($widget['place'], 0, 1)]; $place = @$placecodes[substr($widget['place'], 1, 2)]; if (isset($region) && isset($place)) { // check region/place codes recognized $module = qa_load_module('widget', $widget['title']); if (isset($module) && method_exists($module, 'allow_template') && $module->allow_template(substr($qa_template, 0, 7) == 'custom-' ? 'custom' : $qa_template) && method_exists($module, 'allow_region') && $module->allow_region($region) && method_exists($module, 'output_widget')) { $qa_content['widgets'][$region][$place][] = $module; } // if module loaded and happy to be displayed here, tell theme about it } } } $logoshow = qa_opt('logo_show'); $logourl = qa_opt('logo_url'); $logowidth = qa_opt('logo_width'); $logoheight = qa_opt('logo_height'); if ($logoshow) { $qa_content['logo'] = '<a href="' . qa_path_html('') . '" class="qa-logo-link" title="' . qa_html(qa_opt('site_title')) . '">' . '<img src="' . qa_html(is_numeric(strpos($logourl, '://')) ? $logourl : qa_path_to_root() . $logourl) . '"' . ($logowidth ? ' width="' . $logowidth . '"' : '') . ($logoheight ? ' height="' . $logoheight . '"' : '') . ' border="0" alt="' . qa_html(qa_opt('site_title')) . '"/></a>'; } else { $qa_content['logo'] = '<a href="' . qa_path_html('') . '" class="qa-logo-link">' . qa_html(qa_opt('site_title')) . '</a>'; } $topath = qa_get('to'); // lets user switch between login and register without losing destination page $userlinks = qa_get_login_links(qa_path_to_root(), isset($topath) ? $topath : qa_path($request, $_GET, '')); $qa_content['navigation']['user'] = array(); if (qa_is_logged_in()) { $qa_content['loggedin'] = qa_lang_html_sub_split('main/logged_in_x', QA_FINAL_EXTERNAL_USERS ? qa_get_logged_in_user_html(qa_get_logged_in_user_cache(), qa_path_to_root(), false) : qa_get_one_user_html(qa_get_logged_in_handle(), false)); $qa_content['navigation']['user']['updates'] = array('url' => qa_path_html('updates'), 'label' => qa_lang_html('main/nav_updates')); if (!empty($userlinks['logout'])) { $qa_content['navigation']['user']['logout'] = array('url' => qa_html(@$userlinks['logout']), 'label' => qa_lang_html('main/nav_logout')); } if (!QA_FINAL_EXTERNAL_USERS) { $source = qa_get_logged_in_source(); if (strlen($source)) { $loginmodules = qa_load_modules_with('login', 'match_source'); foreach ($loginmodules as $module) { if ($module->match_source($source) && method_exists($module, 'logout_html')) { ob_start(); $module->logout_html(qa_path('logout', array(), qa_opt('site_url'))); $qa_content['navigation']['user']['logout'] = array('label' => ob_get_clean()); } } } } $notices = qa_db_get_pending_result('notices'); foreach ($notices as $notice) { $qa_content['notices'][] = qa_notice_form($notice['noticeid'], qa_viewer_html($notice['content'], $notice['format']), $notice); } } else { require_once QA_INCLUDE_DIR . 'util/string.php'; if (!QA_FINAL_EXTERNAL_USERS) { $loginmodules = qa_load_modules_with('login', 'login_html'); foreach ($loginmodules as $tryname => $module) { ob_start(); $module->login_html(isset($topath) ? qa_opt('site_url') . $topath : qa_path($request, $_GET, qa_opt('site_url')), 'menu'); $label = ob_get_clean(); if (strlen($label)) { $qa_content['navigation']['user'][implode('-', qa_string_to_words($tryname))] = array('label' => $label); } } } if (!empty($userlinks['login'])) { $qa_content['navigation']['user']['login'] = array('url' => qa_html(@$userlinks['login']), 'label' => qa_lang_html('main/nav_login')); } if (!empty($userlinks['register'])) { $qa_content['navigation']['user']['register'] = array('url' => qa_html(@$userlinks['register']), 'label' => qa_lang_html('main/nav_register')); } } if (QA_FINAL_EXTERNAL_USERS || !qa_is_logged_in()) { if (qa_opt('show_notice_visitor') && !isset($topath) && !isset($_COOKIE['qa_noticed'])) { $qa_content['notices'][] = qa_notice_form('visitor', qa_opt('notice_visitor')); } } else { setcookie('qa_noticed', 1, time() + 86400 * 3650, '/', QA_COOKIE_DOMAIN); // don't show first-time notice if a user has logged in if (qa_opt('show_notice_welcome') && qa_get_logged_in_flags() & QA_USER_FLAGS_WELCOME_NOTICE) { if ($requestlower != 'confirm' && $requestlower != 'account') { // let people finish registering in peace $qa_content['notices'][] = qa_notice_form('welcome', qa_opt('notice_welcome')); } } } $qa_content['script_rel'] = array('qa-content/jquery-1.11.2.min.js'); $qa_content['script_rel'][] = 'qa-content/qa-page.js?' . QA_VERSION; if ($voting) { $qa_content['error'] = @$qa_page_error_html; } $qa_content['script_var'] = array('qa_root' => qa_path_to_root(), 'qa_request' => $request); return $qa_content; }
function get_full_post($post, $options, $usershtml) { $fields['raw'] = $post; $userid = qa_get_logged_in_userid(); $cookieid = qa_cookie_get(); $fields['netvotes_raw'] = (int) $post['netvotes']; $postid = $post['postid']; $isquestion = $post['basetype'] == 'Q'; $isanswer = $post['basetype'] == 'A'; $isbyuser = @$post['userid'] == $userid; $anchor = urlencode(qa_anchor($post['basetype'], $postid)); $elementid = isset($options['elementid']) ? $options['elementid'] : $anchor; $microformats = false; $isselected = @$options['isselected']; // content if (@$options['contentview'] && !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 ($post['hidden']) { $fields['vote_state'] = 'disabled'; } elseif ($isbyuser) { $fields['vote_state'] = 'disabled'; } elseif (@$post['uservote'] > 0) { $fields['vote_state'] = 'voted_up'; } elseif (@$post['uservote'] < 0) { $fields['vote_state'] = 'voted_down'; } else { if (strpos($options['voteview'], '-uponly-level')) { $fields['vote_state'] = 'up_only'; } else { $fields['vote_state'] = 'enabled'; } } // 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'] && !$isquestion) { $fields['what_url'] = qa_path_html(qa_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 (@$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'])); } } $isselected = @$options['isselected']; // Updated when and by whom if (isset($post['opostid'])) { // updated meta switch ($post['obasetype'] . '-' . @$post['oupdatetype']) { case 'Q-': $langstring = 'main/asked'; break; case 'Q-' . QA_UPDATE_VISIBLE: $langstring = $post['hidden'] ? 'main/hidden' : 'main/reshown'; break; case 'Q-' . QA_UPDATE_CLOSED: $langstring = isset($post['closedbyid']) ? 'main/closed' : 'main/reopened'; break; case 'Q-' . QA_UPDATE_TAGS: $langstring = 'main/retagged'; break; case 'Q-' . QA_UPDATE_CATEGORY: $langstring = 'main/recategorized'; break; case 'A-': $langstring = 'main/answered'; break; case 'A-' . QA_UPDATE_SELECTED: $langstring = 'main/answer_selected'; break; case 'A-' . QA_UPDATE_VISIBLE: $langstring = $post['ohidden'] ? 'main/hidden' : 'main/answer_reshown'; break; case 'A-' . QA_UPDATE_CONTENT: $langstring = 'main/answer_edited'; break; case 'Q-' . QA_UPDATE_FOLLOWS: $langstring = 'main/asked_related_q'; break; case 'C-': $langstring = 'main/commented'; break; case 'C-' . QA_UPDATE_TYPE: $langstring = 'main/comment_moved'; break; case 'C-' . QA_UPDATE_VISIBLE: $langstring = $post['ohidden'] ? 'main/hidden' : 'main/comment_reshown'; break; case 'C-' . QA_UPDATE_CONTENT: $langstring = 'main/comment_edited'; break; case 'Q-' . QA_UPDATE_CONTENT: default: $langstring = 'main/edited'; break; } $fields['what_2'] = qa_lang_html($langstring); if ($post['obasetype'] != 'Q' || @$post['oupdatetype'] == QA_UPDATE_FOLLOWS) { $fields['what_2_url'] = qa_q_path_html($post['postid'], $post['title'], false, $post['obasetype'], $post['opostid']); } if (@$options['contentview'] && !empty($post['ocontent'])) { $viewer = qa_load_viewer($post['ocontent'], $post['oformat']); $fields['content_2'] = $viewer->get_html($post['ocontent'], $post['oformat'], array('blockwordspreg' => @$options['blockwordspreg'], 'showurllinks' => @$options['showurllinks'], 'linksnewwindow' => @$options['linksnewwindow'])); } if (@$options['whenview']) { $fields['when_2'] = qa_when_to_html($post['otime'], @$options['fulldatedays']); } if (@$options['whoview']) { $isbyuser = qa_post_is_by_user(array('userid' => $post['ouserid'], 'cookieid' => @$post['ocookieid']), $userid, $cookieid); $fields['who_2'] = qa_who_to_html($isbyuser, $post['ouserid'], $usershtml, @$options['ipview'] ? @$post['oip'] : null, false); if (isset($post['opoints'])) { if (@$options['pointsview']) { $fields['who_2']['points'] = $post['opoints'] == 1 ? qa_lang_html_sub_split('main/1_point', '1', '1') : qa_lang_html_sub_split('main/x_points', qa_html(number_format($post['opoints']))); } if (isset($options['pointstitle'])) { $fields['who_2']['title'] = qa_get_points_title_html($post['opoints'], $options['pointstitle']); } } if (isset($post['olevel'])) { $fields['who_2']['level'] = qa_html(qa_user_level_string($post['olevel'])); } } } else { 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 (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); } } } $fields['avatar'] = $this->get_post_avatar($post); return $fields; }
function qa_content_prepare($voting = false, $categoryids = null) { global $qa_root_url_relative, $qa_request, $qa_template, $qa_login_userid, $qa_vote_error_html, $qa_nav_pages_cached, $qa_widgets_cached, $QA_CONST_ROUTING; if (QA_DEBUG_PERFORMANCE) { qa_usage_mark('control'); } if (isset($categoryids) && !is_array($categoryids)) { // accept old-style parameter $categoryids = array($categoryids); } $lastcategoryid = count($categoryids) ? end($categoryids) : null; $qa_content = array('content_type' => 'text/html; charset=utf-8', 'site_title' => qa_html(qa_opt('site_title')), 'head_lines' => array(), 'navigation' => array('user' => array(), 'main' => array(), 'footer' => array('feedback' => array('url' => qa_path_html('feedback'), 'label' => qa_lang_html('main/nav_feedback')))), 'sidebar' => qa_opt('show_custom_sidebar') ? qa_opt('custom_sidebar') : null, 'sidepanel' => qa_opt('show_custom_sidepanel') ? qa_opt('custom_sidepanel') : null, 'widgets' => array()); if (qa_opt('show_custom_in_head')) { $qa_content['head_lines'][] = qa_opt('custom_in_head'); } if (qa_opt('show_custom_header')) { $qa_content['body_header'] = qa_opt('custom_header'); } if (qa_opt('show_custom_footer')) { $qa_content['body_footer'] = qa_opt('custom_footer'); } if (isset($categoryids)) { $qa_content['categoryids'] = $categoryids; } foreach ($qa_nav_pages_cached as $page) { if ($page['nav'] == 'B') { qa_navigation_add_page($qa_content['navigation']['main'], $page); } } if (qa_opt('nav_home') && qa_opt('show_custom_home')) { $qa_content['navigation']['main']['$'] = array('url' => qa_path_html(''), 'label' => qa_lang_html('main/nav_home')); } if (qa_opt('nav_activity')) { $qa_content['navigation']['main']['activity'] = array('url' => qa_path_html('activity'), 'label' => qa_lang_html('main/nav_activity')); } $hascustomhome = qa_has_custom_home(); if (qa_opt($hascustomhome ? 'nav_qa_not_home' : 'nav_qa_is_home')) { $qa_content['navigation']['main'][$hascustomhome ? 'qa' : '$'] = array('url' => qa_path_html($hascustomhome ? 'qa' : ''), 'label' => qa_lang_html('main/nav_qa')); } if (qa_opt('nav_questions')) { $qa_content['navigation']['main']['questions'] = array('url' => qa_path_html('questions'), 'label' => qa_lang_html('main/nav_qs')); } if (qa_opt('nav_hot')) { $qa_content['navigation']['main']['hot'] = array('url' => qa_path_html('hot'), 'label' => qa_lang_html('main/nav_hot')); } if (qa_opt('nav_unanswered')) { $qa_content['navigation']['main']['unanswered'] = array('url' => qa_path_html('unanswered'), 'label' => qa_lang_html('main/nav_unanswered')); } if (qa_using_tags() && qa_opt('nav_tags')) { $qa_content['navigation']['main']['tag'] = array('url' => qa_path_html('tags'), 'label' => qa_lang_html('main/nav_tags')); } if (qa_using_categories() && qa_opt('nav_categories')) { $qa_content['navigation']['main']['categories'] = array('url' => qa_path_html('categories'), 'label' => qa_lang_html('main/nav_categories')); } if (qa_opt('nav_users')) { $qa_content['navigation']['main']['user'] = array('url' => qa_path_html('users'), 'label' => qa_lang_html('main/nav_users')); } if (qa_user_permit_error('permit_post_q') != 'level') { $qa_content['navigation']['main']['ask'] = array('url' => qa_path_html('ask', qa_using_categories() && strlen($lastcategoryid) ? array('cat' => $lastcategoryid) : null), 'label' => qa_lang_html('main/nav_ask')); } if (qa_get_logged_in_level() >= QA_USER_LEVEL_ADMIN) { $qa_content['navigation']['main']['admin'] = array('url' => qa_path_html(isset($_COOKIE['qa_admin_last']) && isset($QA_CONST_ROUTING[$_COOKIE['qa_admin_last']]) ? $_COOKIE['qa_admin_last'] : 'admin'), 'label' => qa_lang_html('main/nav_admin')); } $qa_content['search'] = array('form_tags' => 'METHOD="GET" ACTION="' . qa_path_html('search') . '"', 'form_extra' => qa_path_form_html('search'), 'title' => qa_lang_html('main/search_title'), 'field_tags' => 'NAME="q"', 'button_label' => qa_lang_html('main/search_button')); if (!qa_opt('feedback_enabled')) { unset($qa_content['navigation']['footer']['feedback']); } foreach ($qa_nav_pages_cached as $page) { if ($page['nav'] == 'M' || $page['nav'] == 'O' || $page['nav'] == 'F') { qa_navigation_add_page($qa_content['navigation'][$page['nav'] == 'F' ? 'footer' : 'main'], $page); } } $regioncodes = array('F' => 'full', 'M' => 'main', 'S' => 'side'); $placecodes = array('T' => 'top', 'H' => 'high', 'L' => 'low', 'B' => 'bottom'); foreach ($qa_widgets_cached as $widget) { if (is_numeric(strpos(',' . $widget['tags'] . ',', ',' . $qa_template . ',')) || is_numeric(strpos(',' . $widget['tags'] . ',', ',all,'))) { // see if it has been selected for display on this template $region = @$regioncodes[substr($widget['place'], 0, 1)]; $place = @$placecodes[substr($widget['place'], 1, 2)]; if (isset($region) && isset($place)) { // check region/place codes recognized $module = qa_load_module('widget', $widget['title']); if (isset($module) && method_exists($module, 'allow_template') && $module->allow_template($qa_template) && method_exists($module, 'allow_region') && $module->allow_region($region) && method_exists($module, 'output_widget')) { $qa_content['widgets'][$region][$place][] = $module; } // if module loaded and happy to be displayed here, tell theme about it } } } $logoshow = qa_opt('logo_show'); $logourl = qa_opt('logo_url'); $logowidth = qa_opt('logo_width'); $logoheight = qa_opt('logo_height'); if ($logoshow) { $qa_content['logo'] = '<A HREF="' . qa_path_html('') . '" CLASS="qa-logo-link" TITLE="' . qa_html(qa_opt('site_title')) . '">' . '<IMG SRC="' . qa_html(is_numeric(strpos($logourl, '://')) ? $logourl : $qa_root_url_relative . $logourl) . '"' . ($logowidth ? ' WIDTH="' . $logowidth . '"' : '') . ($logoheight ? ' HEIGHT="' . $logoheight . '"' : '') . ' BORDER="0"/></A>'; } else { $qa_content['logo'] = '<A HREF="' . qa_path_html('') . '" CLASS="qa-logo-link">' . qa_html(qa_opt('site_title')) . '</A>'; } $topath = qa_get('to'); // lets user switch between login and register without losing destination page $userlinks = qa_get_login_links($qa_root_url_relative, isset($topath) ? $topath : qa_path($qa_request, $_GET, '')); $qa_content['navigation']['user'] = array(); if (isset($qa_login_userid)) { $qa_content['loggedin'] = qa_lang_html_sub_split('main/logged_in_x', QA_FINAL_EXTERNAL_USERS ? qa_get_logged_in_user_html(qa_get_logged_in_user_cache(), $qa_root_url_relative, false) : qa_get_one_user_html(qa_get_logged_in_handle(), false)); if (!QA_FINAL_EXTERNAL_USERS) { $qa_content['navigation']['user']['account'] = array('url' => qa_path_html('account'), 'label' => qa_lang_html('main/nav_account')); } if (!empty($userlinks['logout'])) { $qa_content['navigation']['user']['logout'] = array('url' => qa_html(@$userlinks['logout']), 'label' => qa_lang_html('main/nav_logout')); } if (!QA_FINAL_EXTERNAL_USERS) { $source = qa_get_logged_in_source(); if (strlen($source)) { $modulenames = qa_list_modules('login'); foreach ($modulenames as $tryname) { $module = qa_load_module('login', $tryname); if (method_exists($module, 'match_source') && $module->match_source($source) && method_exists($module, 'logout_html')) { ob_start(); $module->logout_html(qa_path('logout', array(), qa_opt('site_url'))); $qa_content['navigation']['user']['logout'] = array('label' => ob_get_clean()); } } } } } else { $modulenames = qa_list_modules('login'); foreach ($modulenames as $tryname) { $module = qa_load_module('login', $tryname); if (method_exists($module, 'login_html')) { ob_start(); $module->login_html(isset($topath) ? qa_opt('site_url') . $topath : qa_path($qa_request, $_GET, qa_opt('site_url')), 'menu'); $qa_content['navigation']['user'][$tryname] = array('label' => ob_get_clean()); } } if (!empty($userlinks['login'])) { $qa_content['navigation']['user']['login'] = array('url' => qa_html(@$userlinks['login']), 'label' => qa_lang_html('main/nav_login')); } if (!empty($userlinks['register'])) { $qa_content['navigation']['user']['register'] = array('url' => qa_html(@$userlinks['register']), 'label' => qa_lang_html('main/nav_register')); } } $qa_content['script_rel'] = array('qa-content/jquery-1.6.1.min.js'); if ($voting) { $qa_content['error'] = @$qa_vote_error_html; $qa_content['script_rel'][] = 'qa-content/qa-votes.js?' . QA_VERSION; } $qa_content['script_var'] = array('qa_root' => $qa_root_url_relative, 'qa_request' => $qa_request); return $qa_content; }
function qa_other_to_q_html_fields($question, $userid, $cookieid, $usershtml, $dummy, $options) { $fields = qa_post_html_fields($question, $userid, $cookieid, $usershtml, null, $options); switch ($question['obasetype']) { case 'Q': $fields['what'] = @$question['oedited'] ? qa_lang_html('main/edited') : null; break; case 'A': $fields['what'] = @$question['oedited'] ? qa_lang_html('main/answer_edited') : qa_lang_html('main/answered'); break; case 'C': $fields['what'] = @$question['oedited'] ? qa_lang_html('main/comment_edited') : qa_lang_html('main/commented'); break; } if ($question['obasetype'] != 'Q') { $fields['what_url'] = $fields['url'] . '#' . qa_html(urlencode(qa_anchor($question['obasetype'], $question['opostid']))); } if (@$options['whenview']) { $fields['when'] = qa_lang_html_sub_split('main/x_ago', qa_html(qa_time_to_string(qa_opt('db_time') - $question['otime']))); } if (@$options['whoview']) { $isbyuser = qa_post_is_by_user(array('userid' => $question['ouserid'], 'cookieid' => $question['ocookieid']), $userid, $cookieid); $fields['who'] = qa_who_to_html($isbyuser, $question['ouserid'], $usershtml, @$options['ipview'] ? $question['oip'] : null, false); if (isset($question['opoints'])) { if (@$options['pointsview']) { $fields['who']['points'] = $question['opoints'] == 1 ? qa_lang_html_sub_split('main/1_point', '1', '1') : qa_lang_html_sub_split('main/x_points', qa_html(number_format($question['opoints']))); } if (isset($options['pointstitle'])) { $fields['who']['title'] = qa_get_points_title_html($question['opoints'], $options['pointstitle']); } } if (isset($question['olevel'])) { $fields['who']['level'] = qa_html(qa_user_level_string($question['olevel'])); } } unset($fields['flags']); if (@$options['flagsview'] && @$post['oflagcount']) { $fields['flags'] = $post['oflagcount'] == 1 ? qa_lang_html_sub_split('main/1_flag', '1', '1') : qa_lang_html_sub_split('main/x_flags', $post['oflagcount']); } unset($fields['avatar']); if (!QA_FINAL_EXTERNAL_USERS && @$options['avatarsize'] > 0) { $fields['avatar'] = qa_get_user_avatar_html($question['oflags'], $question['oemail'], $question['ohandle'], $question['oavatarblobid'], $question['oavatarwidth'], $question['oavatarheight'], $options['avatarsize']); } return $fields; }