function process_request($request)
 {
     //	Get list of unanswered open questions
     $userid = qa_get_logged_in_userid();
     $start = qa_get_start();
     $questions_selectspec = $this->qa_db_open_qs_selectspec($userid, $start);
     $questions = qa_db_select_with_pending($questions_selectspec);
     //	Prepare and return the content for the theme
     $questions_found_title = qa_lang_html('open_questions/questions_found_title');
     $no_questions_title = qa_lang_html('open_questions/no_questions_title');
     $count = qa_opt('cache_unaqcount');
     $qa_content = qa_q_list_page_content($questions, qa_opt('page_size_una_qs'), $start, @$count, $questions_found_title, $no_questions_title, null, null, false, null, null, qa_html_suggest_qs_tags(qa_using_tags()), null, null);
     return $qa_content;
 }
 public function process_request($request)
 {
     $requestparts = explode('/', qa_request());
     $slugs = array_slice($requestparts, 1);
     $countslugs = count($slugs);
     $userid = qa_get_logged_in_userid();
     $start = qa_get_start();
     $count = qa_opt_if_loaded('page_size_activity');
     $totalcount = qa_opt('cache_qcount');
     $qspec = qa_db_posts_basic_selectspec($userid, false);
     qa_db_add_selectspec_opost($qspec, 'ra', false, false);
     qa_db_add_selectspec_ousers($qspec, 'rau', 'raup');
     $qspec['source'] .= " JOIN (SELECT questionid, childid FROM ^homepage ORDER BY ^homepage.updated DESC) AS rcaq ON ^posts.postid=rcaq.questionid" . " LEFT JOIN ^posts AS ra ON childid=ra.postid" . (QA_FINAL_EXTERNAL_USERS ? "" : " LEFT JOIN ^users AS rau ON ra.userid=rau.userid") . " LEFT JOIN ^userpoints AS raup ON ra.userid=raup.userid LIMIT #,#";
     array_push($qspec['columns'], 'childid');
     array_push($qspec['arguments'], $start, $count);
     $qspec['sortdesc'] = 'otime';
     $query = 'SELECT ';
     foreach ($qspec['columns'] as $columnas => $columnfrom) {
         $query .= $columnfrom . (is_int($columnas) ? '' : ' AS ' . $columnas) . ', ';
     }
     $query = qa_db_apply_sub(substr($query, 0, -2) . (strlen(@$qspec['source']) ? ' FROM ' . $qspec['source'] : ''), @$qspec['arguments']);
     $results = qa_db_read_all_assoc(qa_db_query_raw($query));
     qa_db_post_select($results, $qspec);
     list($categories, $categoryid) = qa_db_select_with_pending(qa_db_category_nav_selectspec($slugs, false, false, true), $countslugs ? qa_db_slugs_to_category_id_selectspec($slugs) : null);
     $questions = qa_any_sort_and_dedupe($results);
     // $questions=qa_any_sort_and_dedupe(array_merge($recentquestions,$recentanswers));
     $pagesize = qa_opt('page_size_home');
     if ($countslugs) {
         if (!isset($categoryid)) {
             return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
         }
         $categorytitlehtml = qa_html($categories[$categoryid]['title']);
         $sometitle = qa_lang_html_sub('main/recent_qs_as_in_x', $categorytitlehtml);
         $nonetitle = qa_lang_html_sub('main/no_questions_in_x', $categorytitlehtml);
     } else {
         $sometitle = qa_lang_html('main/recent_qs_as_title');
         $nonetitle = qa_lang_html('main/no_questions_found');
     }
     require_once QA_INCLUDE_DIR . 'qa-app-q-list.php';
     $qa_content = qa_q_list_page_content($questions, $pagesize, $start, $totalcount, $sometitle, $nonetitle, $categories, $categoryid, true, qa_opt('eql_homepage_url'), qa_opt('feed_for_qa') ? qa_opt('eql_homepage_url') : null, count($questions) < $pagesize ? qa_html_suggest_ask($categoryid) : qa_html_suggest_qs_tags(qa_using_tags(), qa_category_path_request($categories, $categoryid)), null, null);
     return $qa_content;
 }
Exemplo n.º 3
0
        break;
    case 'upvotes':
        if ($countslugs) {
            $sometitle = qa_lang_html_sub('main/unupvoteda_qs_in_x', $categorytitlehtml);
            $nonetitle = qa_lang_html_sub('main/no_una_questions_in_x', $categorytitlehtml);
        } else {
            $sometitle = qa_lang_html('main/unupvoteda_qs_title');
            $nonetitle = qa_lang_html('main/no_unupvoteda_qs_found');
            $count = qa_opt('cache_unupaqcount');
        }
        break;
    default:
        $feedpathprefix = qa_opt('feed_for_unanswered') ? 'unanswered' : null;
        $linkparams = array();
        if ($countslugs) {
            $sometitle = qa_lang_html_sub('main/unanswered_qs_in_x', $categorytitlehtml);
            $nonetitle = qa_lang_html_sub('main/no_una_questions_in_x', $categorytitlehtml);
        } else {
            $sometitle = qa_lang_html('main/unanswered_qs_title');
            $nonetitle = qa_lang_html('main/no_una_questions_found');
            $count = qa_opt('cache_unaqcount');
        }
        break;
}
//	Prepare and return content for theme
$qa_content = qa_q_list_page_content($questions, qa_opt('page_size_una_qs'), $start, @$count, $sometitle, $nonetitle, QA_ALLOW_UNINDEXED_QUERIES ? $categories : null, QA_ALLOW_UNINDEXED_QUERIES ? $categoryid : null, false, 'unanswered/', $feedpathprefix, qa_html_suggest_qs_tags(qa_using_tags()), $linkparams, $linkparams);
$qa_content['navigation']['sub'] = qa_unanswered_sub_navigation($by, $categoryslugs);
return $qa_content;
/*
	Omit PHP closing tag to help avoid accidental output
*/
Exemplo n.º 4
0
$linkparams = array('sort' => $sort);
switch ($sort) {
    case 'hot':
        $sometitle = $countslugs ? qa_lang_html_sub('main/hot_qs_in_x', $categorytitlehtml) : qa_lang_html('main/hot_qs_title');
        $feedpathprefix = qa_opt('feed_for_hot') ? 'hot' : null;
        break;
    case 'votes':
        $sometitle = $countslugs ? qa_lang_html_sub('main/voted_qs_in_x', $categorytitlehtml) : qa_lang_html('main/voted_qs_title');
        break;
    case 'answers':
        $sometitle = $countslugs ? qa_lang_html_sub('main/answered_qs_in_x', $categorytitlehtml) : qa_lang_html('main/answered_qs_title');
        break;
    case 'views':
        $sometitle = $countslugs ? qa_lang_html_sub('main/viewed_qs_in_x', $categorytitlehtml) : qa_lang_html('main/viewed_qs_title');
        break;
    default:
        $linkparams = array();
        $sometitle = $countslugs ? qa_lang_html_sub('main/recent_qs_in_x', $categorytitlehtml) : qa_lang_html('main/recent_qs_title');
        $categorypathprefix = 'questions/';
        $feedpathprefix = qa_opt('feed_for_questions') ? 'questions' : null;
        break;
}
//	Prepare and return content for theme
$qa_content = qa_q_list_page_content($questions, qa_opt('page_size_qs'), $start, $countslugs ? $categories[$categoryid]['qcount'] : qa_opt('cache_qcount'), $sometitle, $nonetitle, $categories, $categoryid, true, $categorypathprefix, $feedpathprefix, $countslugs ? qa_html_suggest_qs_tags(qa_using_tags()) : qa_html_suggest_ask($categoryid), $linkparams, $linkparams);
if (QA_ALLOW_UNINDEXED_QUERIES || !$countslugs) {
    $qa_content['navigation']['sub'] = qa_qs_sub_navigation($sort, $categoryslugs);
}
return $qa_content;
/*
	Omit PHP closing tag to help avoid accidental output
*/
    function process_request($request)
    {
        //@ini_set('display_errors', 0); // we don't want to show PHP errors inside XML
        if ($request == 'sitemap.xml') {
            $req = '';
        } else {
            $req_str = substr($request, 8, strlen($request) - 12);
            // extract "X-Y-Z" from "sitemap-X-Y-Z.xml"
            $req = explode('-', $req_str);
        }
        $siteurl = qa_opt('site_url');
        header('Content-type: text/xml; charset=utf-8');
        // Index Pages
        // Indexed all XML sitemaps for question's lists
        // example: sitemap.xml
        if ($req == '') {
            $this->sitemap_index_header();
            $q_sitemaps = qa_db_read_one_assoc(qa_db_query_sub("SELECT count(*) as total from ^posts WHERE type='Q'"));
            $count = qa_opt('useo_sitemap_question_count');
            $q_sitemap_count = ceil($q_sitemaps['total'] / $count);
            for ($i = 0; $i < $q_sitemap_count; $i++) {
                $this->sitemap_index_output('sitemap-' . $i . '.xml');
            }
            $this->sitemap_index_footer();
        }
        // Indexed all important XML sitemaps
        // example: sitemap-index.xml
        if (count($req) == 1 && $req[0] == 'index') {
            $this->sitemap_index_header();
            $this->sitemap_index();
            $this->sitemap_index_footer();
        }
        // Indexed all XML sitemaps, including categories question page
        // example: sitemap-index.xml
        if (count($req) == 1 && $req[0] == 'all') {
            $this->sitemap_index_header();
            $this->sitemap_all();
            $this->sitemap_index_footer();
        }
        //	Question pages
        // numbered question sitenaps
        // example: sitemap-1.xml, sitemap-12.xml
        if (count($req) == 1 && strval((int) $req[0]) == $req[0]) {
            $hotstats = qa_db_read_one_assoc(qa_db_query_sub("SELECT MIN(hotness) AS base, MAX(hotness)-MIN(hotness) AS spread FROM ^posts WHERE type='Q'"));
            $count = qa_opt('useo_sitemap_question_count');
            $start = (int) $req[0] * $count;
            $questions = qa_db_read_all_assoc(qa_db_query_sub("SELECT postid, title, hotness FROM ^posts WHERE type='Q' ORDER BY postid LIMIT #,#", $start, $count));
            if (count($questions)) {
                $this->sitemap_header();
                foreach ($questions as $question) {
                    $this->sitemap_output(qa_q_request($question['postid'], $question['title']), 0.1 + 0.9 * ($question['hotness'] - $hotstats['base']) / (1 + $hotstats['spread']));
                }
                $this->sitemap_footer();
            }
        }
        //User pages
        if ($req[0] == 'users' && !QA_FINAL_EXTERNAL_USERS && qa_opt('useo_sitemap_users_enable')) {
            // user's numbered sitemaps
            // example: sitemap-users-1.xml, sitemap-users-12.xml
            if (isset($req[1]) && strval((int) $req[1]) == $req[1] && (int) qa_opt('useo_sitemap_users_count') != 0) {
                $count = qa_opt('useo_sitemap_users_count');
                $start = (int) $req[1] * $count;
                $users = qa_db_read_all_assoc(qa_db_query_sub("SELECT userid, handle FROM ^users ORDER BY userid LIMIT #,#", $start, $count));
                if (count($users)) {
                    $this->sitemap_header();
                    foreach ($users as $user) {
                        $this->sitemap_output('user/' . $user['handle'], 0.25);
                    }
                    $this->sitemap_footer();
                }
            } else {
                // All users sitemap
                // example: sitemap-users.xml
                if (!isset($req[1])) {
                    $users = qa_db_read_all_assoc(qa_db_query_sub("SELECT userid, handle FROM ^users ORDER BY userid"));
                    if (count($users)) {
                        $this->sitemap_header();
                        foreach ($users as $user) {
                            $this->sitemap_output('user/' . $user['handle'], 0.25);
                        }
                        $this->sitemap_footer();
                    }
                }
            }
        }
        //	Tag pages
        if ($req[0] == 'tags' && qa_using_tags() && qa_opt('useo_sitemap_tags_enable')) {
            // link to each tag's page sitemaps
            // example: sitemap-tags-1.xml, sitemap-tags-12.xml
            if (isset($req[1]) && strval((int) $req[1]) == $req[1] && (int) qa_opt('useo_sitemap_tags_count') != 0) {
                $count = qa_opt('useo_sitemap_tags_count');
                $start = (int) $req[1] * $count;
                $tagwords = qa_db_read_all_assoc(qa_db_query_sub("SELECT wordid, word, tagcount FROM ^words WHERE tagcount>0 ORDER BY wordid LIMIT #,#", $start, $count));
                if (count($tagwords)) {
                    $this->sitemap_header();
                    foreach ($tagwords as $tagword) {
                        $this->sitemap_output('tag/' . $tagword['word'], 0.5 / (1 + 1 / $tagword['tagcount']));
                        // priority between 0.25 and 0.5 depending on tag frequency
                    }
                    $this->sitemap_footer();
                }
            } else {
                // link to all tags in sitemaps
                // example: sitemap-tags.xml
                if (!isset($req[1])) {
                    $tagwords = qa_db_read_all_assoc(qa_db_query_sub("SELECT wordid, word, tagcount FROM ^words WHERE tagcount>0 ORDER BY wordid"));
                    if (count($tagwords)) {
                        $this->sitemap_header();
                        foreach ($tagwords as $tagword) {
                            $this->sitemap_output('tag/' . $tagword['word'], 0.5 / (1 + 1 / $tagword['tagcount']));
                            // priority between 0.25 and 0.5 depending on tag frequency
                        }
                        $this->sitemap_footer();
                    }
                }
            }
        }
        //	link to all category pages
        if ($req[0] == 'category' && !isset($req[1]) && qa_using_categories() && qa_opt('useo_sitemap_categories_enable')) {
            $categories = qa_db_read_all_assoc(qa_db_query_sub("SELECT categoryid, backpath FROM ^categories WHERE qcount>0 ORDER BY categoryid"));
            if (count($categories)) {
                $this->sitemap_header();
                foreach ($categories as $category) {
                    $this->sitemap_output('questions/' . implode('/', array_reverse(explode('/', $category['backpath']))), 0.5);
                }
                $this->sitemap_footer();
            }
        }
        //	sitemap for category questions
        if ($req[0] == 'category' && isset($req[1]) && qa_using_categories() && qa_opt('useo_sitemap_categoriy_q_enable')) {
            $hotstats = qa_db_read_one_assoc(qa_db_query_sub("SELECT MIN(hotness) AS base, MAX(hotness)-MIN(hotness) AS spread FROM ^posts WHERE type='Q'"));
            if (count($req) >= 3) {
                //because: "category-x-x-x-x-1" | 1 category + 1 sount + at least 1 category = 3
                // link to questions in a category or sub category
                // example: sitemap-category-RootCat-SubCat-2.xml
                // it's always numbered, "sitemap-category-RootCat-SubCat.xml" is NOT ALLOWED
                $slug_list = array_splice($req, 1, -1);
                $slug = implode("/", array_reverse($slug_list));
                $count = qa_opt('useo_sitemap_categoriy_q_count');
                $start = (int) $req[count($req) - 1] * $count;
                $questions = qa_db_read_all_assoc(qa_db_query_sub('SELECT postid, title, hotness FROM ^posts WHERE ^posts.type=$
						AND categoryid=(SELECT categoryid FROM ^categories WHERE ^categories.backpath=$ LIMIT 1) 
						ORDER BY ^posts.created DESC LIMIT #,#', 'Q', $slug, $start, $count));
            } else {
                // link to all questions in a category
                // example: sitemap-category-RootCat.xml
                $slug = $req[1];
                $questions = qa_db_read_all_assoc(qa_db_query_sub("SELECT postid, title, hotness FROM ^posts WHERE ^posts.type=\$\n\t\t\t\t\t\tAND categoryid=(SELECT categoryid FROM ^categories WHERE ^categories.backpath=\$ LIMIT 1) \n\t\t\t\t\t\tORDER BY ^posts.created DESC", 'Q', $slug));
            }
            if (count($questions)) {
                $this->sitemap_header();
            }
            foreach ($questions as $question) {
                $this->sitemap_output(qa_q_request($question['postid'], $question['title']), 0.1 + 0.9 * ($question['hotness'] - $hotstats['base']) / (1 + $hotstats['spread']));
            }
            $this->sitemap_footer();
        }
        //	Pages in category browser
        if (qa_using_categories() && qa_opt('useo_sitemap_categories_enable')) {
            $this->sitemap_output('categories', 0.5);
            $nextcategoryid = 0;
            $this->sitemap_header();
            while (1) {
                // only find categories with a child
                $categories = qa_db_read_all_assoc(qa_db_query_sub("SELECT parent.categoryid, parent.backpath FROM ^categories AS parent " . "JOIN ^categories AS child ON child.parentid=parent.categoryid WHERE parent.categoryid>=# GROUP BY parent.categoryid LIMIT 100", $nextcategoryid));
                if (!count($categories)) {
                    break;
                }
                foreach ($categories as $category) {
                    $this->sitemap_output('categories/' . implode('/', array_reverse(explode('/', $category['backpath']))), 0.5);
                    $nextcategoryid = max($nextcategoryid, $category['categoryid'] + 1);
                }
            }
            $this->sitemap_footer();
        }
        //	Finish up...
        return null;
    }
Exemplo n.º 6
0
	More about this license: http://www.question2answer.org/license.php
*/
if (!defined('QA_VERSION')) {
    // don't allow this page to be requested directly from browser
    header('Location: ../');
    exit;
}
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
require_once QA_INCLUDE_DIR . 'qa-app-format.php';
require_once QA_INCLUDE_DIR . 'qa-app-q-list.php';
$categoryslugs = qa_request_parts(1);
$countslugs = count($categoryslugs);
$userid = qa_get_logged_in_userid();
//	Get list of comments with related questions, plus category information
list($questions, $categories, $categoryid) = qa_db_select_with_pending(qa_db_recent_c_qs_selectspec($userid, 0, $categoryslugs), qa_db_category_nav_selectspec($categoryslugs, false, false, true), $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null);
if ($countslugs) {
    if (!isset($categoryid)) {
        return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
    }
    $categorytitlehtml = qa_html($categories[$categoryid]['title']);
    $sometitle = qa_lang_html_sub('main/recent_cs_in_x', $categorytitlehtml);
    $nonetitle = qa_lang_html_sub('main/no_comments_in_x', $categorytitlehtml);
} else {
    $sometitle = qa_lang_html('main/recent_cs_title');
    $nonetitle = qa_lang_html('main/no_comments_found');
}
//	Prepare and return content for theme
return qa_q_list_page_content(qa_any_sort_and_dedupe($questions), qa_opt('page_size_activity'), 0, null, $sometitle, $nonetitle, $categories, $categoryid, false, 'comments/', qa_opt('feed_for_activity') ? 'comments' : null, qa_html_suggest_qs_tags(qa_using_tags(), qa_category_path_request($categories, $categoryid)));
/*
	Omit PHP closing tag to help avoid accidental output
*/
function qa_page_q_edit_q_form()
{
    global $qa_content, $question, $inqtitle, $inqcontent, $inqformat, $inqeditor, $inqtags, $qerrors, $innotify, $inemail, $completetags, $categories;
    $content = isset($inqcontent) ? $inqcontent : $question['content'];
    $format = isset($inqformat) ? $inqformat : $question['format'];
    $editorname = isset($inqeditor) ? $inqeditor : qa_opt('editor_for_qs');
    $editor = qa_load_editor($content, $format, $editorname);
    $form = array('style' => 'tall', 'fields' => array('title' => array('label' => qa_lang_html('question/q_title_label'), 'tags' => 'NAME="qtitle"', 'value' => qa_html(isset($inqtitle) ? $inqtitle : $question['title']), 'error' => qa_html(@$qerrors['title'])), 'category' => array('label' => qa_lang_html('question/q_category_label')), 'content' => array_merge($editor->get_field($qa_content, $content, $format, 'qcontent', 12, true), array('label' => qa_lang_html('question/q_content_label'), 'error' => qa_html(@$qerrors['content']))), 'tags' => array('error' => qa_html(@$qerrors['tags']))), 'buttons' => array('save' => array('label' => qa_lang_html('main/save_button')), 'cancel' => array('tags' => 'NAME="docancel"', 'label' => qa_lang_html('main/cancel_button'))), 'hidden' => array('editor' => qa_html($editorname), 'dosaveq' => '1'));
    if (qa_using_categories() && count($categories)) {
        qa_set_up_category_field($qa_content, $form['fields']['category'], 'category', $categories, isset($incategoryid) ? $incategoryid : $question['categoryid'], qa_opt('allow_no_category') || !isset($question['categoryid']), qa_opt('allow_no_sub_category'));
    } else {
        unset($form['fields']['category']);
    }
    if (qa_using_tags()) {
        qa_set_up_tag_field($qa_content, $form['fields']['tags'], 'qtags', isset($inqtags) ? $inqtags : qa_tagstring_to_tags($question['tags']), array(), $completetags, qa_opt('page_size_ask_tags'));
    } else {
        unset($form['fields']['tags']);
    }
    if ($question['isbyuser']) {
        qa_set_up_notify_fields($qa_content, $form['fields'], 'Q', qa_get_logged_in_email(), isset($innotify) ? $innotify : !empty($question['notify']), isset($inemail) ? $inemail : @$question['notify'], @$qerrors['email']);
    }
    return $form;
}
Exemplo n.º 8
0
function qa_post_html_defaults($basetype, $full = false)
{
    require_once QA_INCLUDE_DIR . 'qa-app-users.php';
    return array('tagsview' => $basetype == 'Q' && qa_using_tags(), 'voteview' => qa_get_vote_view($basetype, $full), 'flagsview' => qa_opt('flagging_of_posts') && $full, 'answersview' => $basetype == 'Q', 'viewsview' => $basetype == 'Q' && qa_opt('do_count_q_views') && qa_opt('show_view_counts'), 'whatlink' => qa_opt('show_a_c_links'), 'whenview' => qa_opt('show_when_created'), 'ipview' => !qa_user_permit_error('permit_anon_view_ips'), 'whoview' => true, 'avatarsize' => qa_opt('avatar_q_list_size'), 'pointsview' => qa_opt('show_user_points'), 'pointstitle' => qa_opt('show_user_titles') ? qa_get_points_to_titles() : array(), 'blockwordspreg' => qa_get_block_words_preg(), 'showurllinks' => qa_opt('show_url_links'), 'linksnewwindow' => qa_opt('links_in_new_window'), 'microformats' => $full);
}
Exemplo n.º 9
0
    if (qa_opt('show_home_description')) {
        $qa_content['description'] = qa_html(qa_opt('home_description'));
    }
    $qa_content['custom'] = qa_opt('custom_home_content');
    return $qa_content;
}
//	If we got this far, it's a good old-fashioned Q&A listing page
require_once QA_INCLUDE_DIR . 'app/q-list.php';
qa_set_template('qa');
$questions = qa_any_sort_and_dedupe(array_merge($questions1, $questions2));
$pagesize = qa_opt('page_size_home');
if ($countslugs) {
    if (!isset($categoryid)) {
        return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
    }
    $categorytitlehtml = qa_html($categories[$categoryid]['title']);
    $sometitle = qa_lang_html_sub('main/recent_qs_as_in_x', $categorytitlehtml);
    $nonetitle = qa_lang_html_sub('main/no_questions_in_x', $categorytitlehtml);
} else {
    $sometitle = qa_lang_html('main/recent_qs_as_title');
    $nonetitle = qa_lang_html('main/no_questions_found');
}
//	Prepare and return content for theme for Q&A listing page
$qa_content = qa_q_list_page_content($questions, $pagesize, 0, null, $sometitle, $nonetitle, $categories, $categoryid, true, $explicitqa ? 'qa/' : '', qa_opt('feed_for_qa') ? 'qa' : null, count($questions) < $pagesize ? qa_html_suggest_ask($categoryid) : qa_html_suggest_qs_tags(qa_using_tags(), qa_category_path_request($categories, $categoryid)), null, null);
if (!$explicitqa && !$countslugs && qa_opt('show_home_description')) {
    $qa_content['description'] = qa_html(qa_opt('home_description'));
}
return $qa_content;
/*
	Omit PHP closing tag to help avoid accidental output
*/
Exemplo n.º 10
0
function qa_get_permit_options()
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    $permits = array('permit_view_q_page', 'permit_post_q', 'permit_post_a');
    if (qa_opt('comment_on_qs') || qa_opt('comment_on_as')) {
        $permits[] = 'permit_post_c';
    }
    if (qa_opt('voting_on_qs')) {
        $permits[] = 'permit_vote_q';
    }
    if (qa_opt('voting_on_as')) {
        $permits[] = 'permit_vote_a';
    }
    if (qa_opt('voting_on_qs') || qa_opt('voting_on_as')) {
        $permits[] = 'permit_vote_down';
    }
    if (qa_using_tags() || qa_using_categories()) {
        $permits[] = 'permit_retag_cat';
    }
    array_push($permits, 'permit_edit_q', 'permit_edit_a');
    if (qa_opt('comment_on_qs') || qa_opt('comment_on_as')) {
        $permits[] = 'permit_edit_c';
    }
    if (qa_opt('allow_close_questions')) {
        $permits[] = 'permit_close_q';
    }
    array_push($permits, 'permit_select_a', 'permit_anon_view_ips');
    if (qa_opt('flagging_of_posts')) {
        $permits[] = 'permit_flag';
    }
    $permits[] = 'permit_moderate';
    array_push($permits, 'permit_hide_show', 'permit_delete_hidden');
    return $permits;
}
Exemplo n.º 11
0
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;
}
Exemplo n.º 12
0
 public function process_request($request)
 {
     @ini_set('display_errors', 0);
     // we don't want to show PHP errors inside XML
     header('Content-type: text/xml; charset=utf-8');
     echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
     echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
     //	Question pages
     if (qa_opt('xml_sitemap_show_questions')) {
         $hotstats = qa_db_read_one_assoc(qa_db_query_sub("SELECT MIN(hotness) AS base, MAX(hotness)-MIN(hotness) AS spread FROM ^posts WHERE type='Q'"));
         $nextpostid = 0;
         while (1) {
             $questions = qa_db_read_all_assoc(qa_db_query_sub("SELECT postid, title, hotness FROM ^posts WHERE postid>=# AND type='Q' ORDER BY postid LIMIT 100", $nextpostid));
             if (!count($questions)) {
                 break;
             }
             foreach ($questions as $question) {
                 $this->sitemap_output(qa_q_request($question['postid'], $question['title']), 0.1 + 0.9 * ($question['hotness'] - $hotstats['base']) / (1 + $hotstats['spread']));
                 $nextpostid = max($nextpostid, $question['postid'] + 1);
             }
         }
     }
     //	User pages
     if (!QA_FINAL_EXTERNAL_USERS && qa_opt('xml_sitemap_show_users')) {
         $nextuserid = 0;
         while (1) {
             $users = qa_db_read_all_assoc(qa_db_query_sub("SELECT userid, handle FROM ^users WHERE userid>=# ORDER BY userid LIMIT 100", $nextuserid));
             if (!count($users)) {
                 break;
             }
             foreach ($users as $user) {
                 $this->sitemap_output('user/' . $user['handle'], 0.25);
                 $nextuserid = max($nextuserid, $user['userid'] + 1);
             }
         }
     }
     //	Tag pages
     if (qa_using_tags() && qa_opt('xml_sitemap_show_tag_qs')) {
         $nextwordid = 0;
         while (1) {
             $tagwords = qa_db_read_all_assoc(qa_db_query_sub("SELECT wordid, word, tagcount FROM ^words WHERE wordid>=# AND tagcount>0 ORDER BY wordid LIMIT 100", $nextwordid));
             if (!count($tagwords)) {
                 break;
             }
             foreach ($tagwords as $tagword) {
                 $this->sitemap_output('tag/' . $tagword['word'], 0.5 / (1 + 1 / $tagword['tagcount']));
                 // priority between 0.25 and 0.5 depending on tag frequency
                 $nextwordid = max($nextwordid, $tagword['wordid'] + 1);
             }
         }
     }
     //	Question list for each category
     if (qa_using_categories() && qa_opt('xml_sitemap_show_category_qs')) {
         $nextcategoryid = 0;
         while (1) {
             $categories = qa_db_read_all_assoc(qa_db_query_sub("SELECT categoryid, backpath FROM ^categories WHERE categoryid>=# AND qcount>0 ORDER BY categoryid LIMIT 2", $nextcategoryid));
             if (!count($categories)) {
                 break;
             }
             foreach ($categories as $category) {
                 $this->sitemap_output('questions/' . implode('/', array_reverse(explode('/', $category['backpath']))), 0.5);
                 $nextcategoryid = max($nextcategoryid, $category['categoryid'] + 1);
             }
         }
     }
     //	Pages in category browser
     if (qa_using_categories() && qa_opt('xml_sitemap_show_categories')) {
         $this->sitemap_output('categories', 0.5);
         $nextcategoryid = 0;
         while (1) {
             // only find categories with a child
             $categories = qa_db_read_all_assoc(qa_db_query_sub("SELECT parent.categoryid, parent.backpath FROM ^categories AS parent " . "JOIN ^categories AS child ON child.parentid=parent.categoryid WHERE parent.categoryid>=# GROUP BY parent.categoryid LIMIT 100", $nextcategoryid));
             if (!count($categories)) {
                 break;
             }
             foreach ($categories as $category) {
                 $this->sitemap_output('categories/' . implode('/', array_reverse(explode('/', $category['backpath']))), 0.5);
                 $nextcategoryid = max($nextcategoryid, $category['categoryid'] + 1);
             }
         }
     }
     echo "</urlset>\n";
     return null;
 }
Exemplo n.º 13
0
 function process_request($request)
 {
     @ini_set('display_errors', 0);
     // we don't want to show PHP errors inside XML
     $siteurl = qa_opt('site_url');
     header('Content-type: text/xml; charset=utf-8');
     echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
     echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
     //	Question pages
     $nextpostid = 0;
     while (1) {
         $questions = qa_db_read_all_assoc(qa_db_query_sub("SELECT postid, BINARY title AS title, upvotes, downvotes FROM ^posts WHERE postid>=# AND type='Q' ORDER BY postid LIMIT 100", $nextpostid));
         if (!count($questions)) {
             break;
         }
         foreach ($questions as $question) {
             $priority = 0.5;
             // between 0 and 1 depending on up/down votes (0.5 if net votes are zero)
             $netvotes = $question['upvotes'] - $question['downvotes'];
             if ($netvotes != 0) {
                 $absvotes = abs($netvotes);
                 $signvotes = $netvotes / $absvotes;
                 $priority += $signvotes * 0.5 / (1 + 1 / $absvotes);
             }
             echo "\t<url>\n" . "\t\t<loc>" . qa_path_html(qa_q_request($question['postid'], $question['title']), null, $siteurl) . "</loc>\n" . "\t\t<priority>" . $priority . "</priority>\n" . "\t</url>\n";
             $nextpostid = max($nextpostid, $question['postid'] + 1);
         }
     }
     //	Tag pages
     if (qa_using_tags()) {
         $nextwordid = 0;
         while (1) {
             $tagwords = qa_db_read_all_assoc(qa_db_query_sub("SELECT wordid, BINARY word AS word, tagcount FROM ^words WHERE wordid>=# AND tagcount>0 ORDER BY wordid LIMIT 100", $nextwordid));
             if (!count($tagwords)) {
                 break;
             }
             foreach ($tagwords as $tagword) {
                 $priority = 0.5 / (1 + 1 / $tagword['tagcount']);
                 // between 0.25 and 0.5 depending on tag frequency
                 echo "\t<url>\n" . "\t\t<loc>" . qa_path_html('tag/' . $tagword['word'], null, $siteurl) . "</loc>\n" . "\t\t<priority>" . $priority . "</priority>\n" . "\t</url>\n";
                 $nextwordid = max($nextwordid, $tagword['wordid'] + 1);
             }
         }
     }
     //	User pages
     if (!QA_FINAL_EXTERNAL_USERS) {
         $nextuserid = 0;
         while (1) {
             $users = qa_db_read_all_assoc(qa_db_query_sub("SELECT userid, BINARY handle AS handle FROM ^users WHERE userid>=# ORDER BY userid LIMIT 100", $nextuserid));
             if (!count($users)) {
                 break;
             }
             foreach ($users as $user) {
                 $priority = 0.25;
                 echo "\t<url>\n" . "\t\t<loc>" . qa_path_html('user/' . $user['handle'], null, $siteurl) . "</loc>\n" . "\t\t<priority>" . $priority . "</priority>\n" . "\t</url>\n";
                 $nextuserid = max($nextuserid, $user['userid'] + 1);
             }
         }
     }
     echo "</urlset>\n";
     return null;
 }
Exemplo n.º 14
0
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.
	
	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
	GNU General Public License for more details.

	More about this license: http://www.question2answer.org/license.php
*/
require_once QA_INCLUDE_DIR . 'qa-db-selects.php';
require_once QA_INCLUDE_DIR . 'qa-util-string.php';
//	Collect the information we need from the database
$intitle = qa_post_text('title');
$doaskcheck = qa_opt('do_ask_check_qs');
$doexampletags = qa_using_tags() && qa_opt('do_example_tags');
if ($doaskcheck || $doexampletags) {
    $countqs = max($doexampletags ? QA_DB_RETRIEVE_ASK_TAG_QS : 0, $doaskcheck ? qa_opt('page_size_ask_check_qs') : 0);
    $relatedquestions = qa_db_select_with_pending(qa_db_search_posts_selectspec(null, qa_string_to_words($intitle), null, null, null, null, 0, false, $countqs));
}
//	Collect example tags if appropriate
if ($doexampletags) {
    require_once QA_INCLUDE_DIR . 'qa-app-format.php';
    $tagweight = array();
    foreach ($relatedquestions as $question) {
        $tags = qa_tagstring_to_tags($question['tags']);
        foreach ($tags as $tag) {
            @($tagweight[$tag] += exp($question['score']));
        }
    }
    arsort($tagweight, SORT_NUMERIC);
function qa_page_q_edit_q_submit($question, $answers, $commentsfollows, $closepost, &$in, &$errors)
{
    $in = array();
    if ($question['editable']) {
        $in['title'] = qa_post_text('q_title');
        qa_get_post_content('q_editor', 'q_content', $in['editor'], $in['content'], $in['format'], $in['text']);
        $in['extra'] = qa_opt('extra_field_active') ? qa_post_text('q_extra') : null;
    }
    if ($question['retagcatable']) {
        if (qa_using_tags()) {
            $in['tags'] = qa_get_tags_field_value('q_tags');
        }
        if (qa_using_categories()) {
            $in['categoryid'] = qa_get_category_field_value('q_category');
        }
    }
    if ($question['isbyuser']) {
        $in['notify'] = qa_post_text('q_notify') ? true : false;
        $in['email'] = qa_post_text('q_email');
    }
    // here the $in array only contains values for parts of the form that were displayed, so those are only ones checked by filters
    $errors = array();
    $filtermodules = qa_load_modules_with('filter', 'filter_question');
    foreach ($filtermodules as $filtermodule) {
        $oldin = $in;
        $filtermodule->filter_question($in, $errors, $question);
        if ($question['editable']) {
            qa_update_post_text($in, $oldin);
        }
    }
    if (empty($errors)) {
        $userid = qa_get_logged_in_userid();
        $handle = qa_get_logged_in_handle();
        $cookieid = qa_cookie_get();
        // now we fill in the missing values in the $in array, so that we have everything we need for qa_question_set_content()
        // we do things in this way to avoid any risk of a validation failure on elements the user can't see (e.g. due to admin setting changes)
        if (!$question['editable']) {
            $in['title'] = $question['title'];
            $in['content'] = $question['content'];
            $in['format'] = $question['format'];
            $in['text'] = qa_viewer_text($in['content'], $in['format']);
            $in['extra'] = $question['extra'];
        }
        if (!isset($in['tags'])) {
            $in['tags'] = qa_tagstring_to_tags($question['tags']);
        }
        if (!array_key_exists('categoryid', $in)) {
            $in['categoryid'] = $question['categoryid'];
        }
        $setnotify = $question['isbyuser'] ? qa_combine_notify_email($question['userid'], $in['notify'], $in['email']) : $question['notify'];
        qa_question_set_content($question, $in['title'], $in['content'], $in['format'], $in['text'], qa_tags_to_tagstring($in['tags']), $setnotify, $userid, $handle, $cookieid, $in['extra']);
        if (qa_using_categories() && strcmp($in['categoryid'], $question['categoryid'])) {
            qa_question_set_category($question, $in['categoryid'], $userid, $handle, $cookieid, $answers, $commentsfollows, $closepost);
        }
        return true;
    }
    return false;
}
Exemplo n.º 16
0
	More about this license: http://www.question2answer.org/license.php
*/
if (!defined('QA_VERSION')) {
    // don't allow this page to be requested directly from browser
    header('Location: ../');
    exit;
}
require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR . 'app/q-list.php';
$categoryslugs = qa_request_parts(1);
$countslugs = count($categoryslugs);
$userid = qa_get_logged_in_userid();
//	Get lists of recent activity in all its forms, plus category information
list($questions1, $questions2, $questions3, $questions4, $categories, $categoryid) = qa_db_select_with_pending(qa_db_qs_selectspec($userid, 'created', 0, $categoryslugs, null, false, false, qa_opt_if_loaded('page_size_activity')), qa_db_recent_a_qs_selectspec($userid, 0, $categoryslugs), qa_db_recent_c_qs_selectspec($userid, 0, $categoryslugs), qa_db_recent_edit_qs_selectspec($userid, 0, $categoryslugs), qa_db_category_nav_selectspec($categoryslugs, false, false, true), $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null);
if ($countslugs) {
    if (!isset($categoryid)) {
        return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
    }
    $categorytitlehtml = qa_html($categories[$categoryid]['title']);
    $sometitle = qa_lang_html_sub('main/recent_activity_in_x', $categorytitlehtml);
    $nonetitle = qa_lang_html_sub('main/no_questions_in_x', $categorytitlehtml);
} else {
    $sometitle = qa_lang_html('main/recent_activity_title');
    $nonetitle = qa_lang_html('main/no_questions_found');
}
//	Prepare and return content for theme
return qa_q_list_page_content(qa_any_sort_and_dedupe(array_merge($questions1, $questions2, $questions3, $questions4)), qa_opt('page_size_activity'), 0, null, $sometitle, $nonetitle, $categories, $categoryid, true, 'activity/', qa_opt('feed_for_activity') ? 'activity' : null, qa_html_suggest_qs_tags(qa_using_tags(), qa_category_path_request($categories, $categoryid)), null, null);
/*
	Omit PHP closing tag to help avoid accidental output
*/
Exemplo n.º 17
0
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;
}
    }
    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')) {
        $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'])) {
        $qa_content['suggest_next'] = qa_html_suggest_qs_tags(qa_using_tags());
    }
} else {
    $qa_content['error'] = qa_lang_html('main/search_explanation');
}
return $qa_content;
/*
	Omit PHP closing tag to help avoid accidental output
*/
}
//	Check admin privileges (do late to allow one DB query)
if (!qa_admin_check_privileges($qa_content)) {
    return $qa_content;
}
//	Define an array of navigation settings we can change, option name => language key
$hascustomhome = qa_has_custom_home();
$navoptions = array('nav_home' => 'main/nav_home', 'nav_activity' => 'main/nav_activity', $hascustomhome ? 'nav_qa_not_home' : 'nav_qa_is_home' => $hascustomhome ? 'main/nav_qa' : 'admin/nav_qa_is_home', 'nav_questions' => 'main/nav_qs', 'nav_hot' => 'main/nav_hot', 'nav_unanswered' => 'main/nav_unanswered', 'nav_tags' => 'main/nav_tags', 'nav_categories' => 'main/nav_categories', 'nav_users' => 'main/nav_users', 'nav_ask' => 'main/nav_ask');
$navpaths = array('nav_home' => '', 'nav_activity' => 'activity', 'nav_qa_not_home' => 'qa', 'nav_qa_is_home' => '', 'nav_questions' => 'questions', 'nav_hot' => 'hot', 'nav_unanswered' => 'unanswered', 'nav_tags' => 'tags', 'nav_categories' => 'categories', 'nav_users' => 'users', 'nav_ask' => 'ask');
if (!qa_opt('show_custom_home')) {
    unset($navoptions['nav_home']);
}
if (!qa_using_categories()) {
    unset($navoptions['nav_categories']);
}
if (!qa_using_tags()) {
    unset($navoptions['nav_tags']);
}
//	Process saving an old or new page
$securityexpired = false;
if (qa_clicked('docancel')) {
    $editpage = null;
} elseif (qa_clicked('dosaveoptions') || qa_clicked('doaddpage') || qa_clicked('doaddlink')) {
    if (!qa_check_form_security_code('admin/pages', qa_post_text('code'))) {
        $securityexpired = true;
    } else {
        foreach ($navoptions as $optionname => $langkey) {
            qa_set_option($optionname, (int) qa_post_text('option_' . $optionname));
        }
    }
} elseif (qa_clicked('dosavepage')) {
function qa_page_q_edit_q_submit($question, $answers, $commentsfollows, $closepost, &$in, &$errors)
{
    $in = array();
    if ($question['editable']) {
        $in['title'] = qa_post_text('q_title');
        qa_get_post_content('q_editor', 'q_content', $in['editor'], $in['content'], $in['format'], $in['text']);
        $in['extra'] = qa_opt('extra_field_active') ? qa_post_text('q_extra') : null;
    }
    if ($question['retagcatable']) {
        if (qa_using_tags()) {
            $in['tags'] = qa_get_tags_field_value('q_tags');
        }
        if (qa_using_categories()) {
            $in['categoryid'] = qa_get_category_field_value('q_category');
        }
    }
    if (array_key_exists('categoryid', $in)) {
        // need to check if we can move it to that category, and if we need moderation
        $categories = qa_db_select_with_pending(qa_db_category_nav_selectspec($in['categoryid'], true));
        $categoryids = array_keys(qa_category_path($categories, $in['categoryid']));
        $userlevel = qa_user_level_for_categories($categoryids);
    } else {
        $userlevel = null;
    }
    if ($question['isbyuser']) {
        $in['name'] = qa_post_text('q_name');
        $in['notify'] = qa_post_text('q_notify') ? true : false;
        $in['email'] = qa_post_text('q_email');
    }
    if (!qa_user_post_permit_error('permit_edit_silent', $question)) {
        $in['silent'] = qa_post_text('q_silent');
    }
    // here the $in array only contains values for parts of the form that were displayed, so those are only ones checked by filters
    $errors = array();
    if (!qa_check_form_security_code('edit-' . $question['postid'], qa_post_text('code'))) {
        $errors['page'] = qa_lang_html('misc/form_security_again');
    } else {
        $in['queued'] = qa_opt('moderate_edited_again') && qa_user_moderation_reason($userlevel);
        $filtermodules = qa_load_modules_with('filter', 'filter_question');
        foreach ($filtermodules as $filtermodule) {
            $oldin = $in;
            $filtermodule->filter_question($in, $errors, $question);
            if ($question['editable']) {
                qa_update_post_text($in, $oldin);
            }
        }
        if (array_key_exists('categoryid', $in) && strcmp($in['categoryid'], $question['categoryid'])) {
            if (qa_user_permit_error('permit_post_q', null, $userlevel)) {
                $errors['categoryid'] = qa_lang_html('question/category_ask_not_allowed');
            }
        }
        if (empty($errors)) {
            $userid = qa_get_logged_in_userid();
            $handle = qa_get_logged_in_handle();
            $cookieid = qa_cookie_get();
            // now we fill in the missing values in the $in array, so that we have everything we need for qa_question_set_content()
            // we do things in this way to avoid any risk of a validation failure on elements the user can't see (e.g. due to admin setting changes)
            if (!$question['editable']) {
                $in['title'] = $question['title'];
                $in['content'] = $question['content'];
                $in['format'] = $question['format'];
                $in['text'] = qa_viewer_text($in['content'], $in['format']);
                $in['extra'] = $question['extra'];
            }
            if (!isset($in['tags'])) {
                $in['tags'] = qa_tagstring_to_tags($question['tags']);
            }
            if (!array_key_exists('categoryid', $in)) {
                $in['categoryid'] = $question['categoryid'];
            }
            if (!isset($in['silent'])) {
                $in['silent'] = false;
            }
            $setnotify = $question['isbyuser'] ? qa_combine_notify_email($question['userid'], $in['notify'], $in['email']) : $question['notify'];
            qa_question_set_content($question, $in['title'], $in['content'], $in['format'], $in['text'], qa_tags_to_tagstring($in['tags']), $setnotify, $userid, $handle, $cookieid, $in['extra'], @$in['name'], $in['queued'], $in['silent']);
            if (qa_using_categories() && strcmp($in['categoryid'], $question['categoryid'])) {
                qa_question_set_category($question, $in['categoryid'], $userid, $handle, $cookieid, $answers, $commentsfollows, $closepost, $in['silent']);
            }
            return true;
        }
    }
    return false;
}
     } else {
         $authorhtml = '';
     }
     if (strlen(@$metadata['version']) && strlen(@$metadata['update'])) {
         $elementid = 'version_check_' . $optionname;
         $updatehtml = '(<span id="' . $elementid . '">...</span>)';
         $qa_content['script_onloads'][] = array("qa_version_check(" . qa_js($metadata['update']) . ", 'Theme Version', " . qa_js($metadata['version'], true) . ", 'Theme URI', " . qa_js($elementid) . ");");
     } else {
         $updatehtml = '';
     }
     $optionfield['suffix'] = $namehtml . ' ' . $authorhtml . ' ' . $updatehtml;
     break;
 case 'tags_or_categories':
     qa_optionfield_make_select($optionfield, array('' => qa_lang_html('admin/no_classification'), 't' => qa_lang_html('admin/tags'), 'c' => qa_lang_html('admin/categories'), 'tc' => qa_lang_html('admin/tags_and_categories')), $value, 'tc');
     $optionfield['error'] = '';
     if (qa_opt('cache_tagcount') && !qa_using_tags()) {
         $optionfield['error'] .= qa_lang_html('admin/tags_not_shown') . ' ';
     }
     if (!qa_using_categories()) {
         foreach ($categories as $category) {
             if ($category['qcount']) {
                 $optionfield['error'] .= qa_lang_html('admin/categories_not_shown');
                 break;
             }
         }
     }
     break;
 case 'smtp_secure':
     qa_optionfield_make_select($optionfield, array('' => qa_lang_html('options/smtp_secure_none'), 'ssl' => 'SSL', 'tls' => 'TLS'), $value, '');
     break;
 case 'custom_sidebar':
Exemplo n.º 22
0
    qa_array_insert($qa_content['form']['fields'], 'title', array('follows' => $field));
}
if (qa_using_categories() && count($categories)) {
    $field = array('label' => qa_lang_html('question/q_category_label'), 'error' => qa_html(@$errors['categoryid']));
    qa_set_up_category_field($qa_content, $field, 'category', $categories, $in['categoryid'], true, qa_opt('allow_no_sub_category'));
    if (!qa_opt('allow_no_category')) {
        // don't auto-select a category even though one is required
        $field['options'][''] = '';
    }
    qa_array_insert($qa_content['form']['fields'], 'content', array('category' => $field));
}
if (qa_opt('extra_field_active')) {
    $field = array('label' => qa_html(qa_opt('extra_field_prompt')), 'tags' => 'name="extra"', 'value' => qa_html(@$in['extra']), 'error' => qa_html(@$errors['extra']));
    qa_array_insert($qa_content['form']['fields'], null, array('extra' => $field));
}
if (qa_using_tags()) {
    $field = array('error' => qa_html(@$errors['tags']));
    qa_set_up_tag_field($qa_content, $field, 'tags', isset($in['tags']) ? $in['tags'] : array(), array(), qa_opt('do_complete_tags') ? array_keys($completetags) : array(), qa_opt('page_size_ask_tags'));
    qa_array_insert($qa_content['form']['fields'], null, array('tags' => $field));
}
if (!isset($userid)) {
    qa_set_up_name_field($qa_content, $qa_content['form']['fields'], @$in['name']);
}
qa_set_up_notify_fields($qa_content, $qa_content['form']['fields'], 'Q', qa_get_logged_in_email(), isset($in['notify']) ? $in['notify'] : qa_opt('notify_users_default'), @$in['email'], @$errors['email']);
if ($captchareason) {
    require_once 'qa-app-captcha.php';
    qa_set_up_captcha_field($qa_content, $qa_content['form']['fields'], @$errors, qa_captcha_reason_note($captchareason));
}
$qa_content['focusid'] = 'title';
return $qa_content;
/*
Exemplo n.º 23
0
function qa_page_q_question_view($question, $parentquestion, $closepost, $usershtml, $formrequested)
{
    $questionid = $question['postid'];
    $userid = qa_get_logged_in_userid();
    $cookieid = qa_cookie_get();
    $htmloptions = qa_post_html_defaults('Q', true);
    $htmloptions['answersview'] = false;
    // answer count is displayed separately so don't show it here
    $htmloptions['avatarsize'] = qa_opt('avatar_q_page_q_size');
    $q_view = qa_post_html_fields($question, $userid, $cookieid, $usershtml, null, $htmloptions);
    $q_view['main_form_tags'] = 'METHOD="POST" ACTION="' . qa_self_html() . '"';
    //	Buttons for operating on the question
    if (!$formrequested) {
        // don't show if another form is currently being shown on page
        $clicksuffix = ' onClick="qa_show_waiting_after(this, false);"';
        // add to operations that write to database
        $buttons = array();
        if ($question['editbutton']) {
            $buttons['edit'] = array('tags' => 'NAME="q_doedit"', 'label' => qa_lang_html('question/edit_button'), 'popup' => qa_lang_html('question/edit_q_popup'));
        }
        $hascategories = qa_using_categories();
        if ($question['retagcatbutton']) {
            $buttons['retagcat'] = array('tags' => 'NAME="q_doedit"', 'label' => qa_lang_html($hascategories ? 'question/recat_button' : 'question/retag_button'), 'popup' => qa_lang_html($hascategories ? qa_using_tags() ? 'question/retag_cat_popup' : 'question/recat_popup' : 'question/retag_popup'));
        }
        if ($question['flagbutton']) {
            $buttons['flag'] = array('tags' => 'NAME="q_doflag"' . $clicksuffix, 'label' => qa_lang_html($question['flagtohide'] ? 'question/flag_hide_button' : 'question/flag_button'), 'popup' => qa_lang_html('question/flag_q_popup'));
        }
        if ($question['unflaggable']) {
            $buttons['unflag'] = array('tags' => 'NAME="q_dounflag"' . $clicksuffix, 'label' => qa_lang_html('question/unflag_button'), 'popup' => qa_lang_html('question/unflag_popup'));
        }
        if ($question['clearflaggable']) {
            $buttons['clearflags'] = array('tags' => 'NAME="q_doclearflags"' . $clicksuffix, 'label' => qa_lang_html('question/clear_flags_button'), 'popup' => qa_lang_html('question/clear_flags_popup'));
        }
        if ($question['closeable']) {
            $buttons['close'] = array('tags' => 'NAME="q_doclose"', 'label' => qa_lang_html('question/close_button'), 'popup' => qa_lang_html('question/close_q_popup'));
        }
        if ($question['reopenable']) {
            $buttons['reopen'] = array('tags' => 'NAME="q_doreopen"' . $clicksuffix, 'label' => qa_lang_html('question/reopen_button'));
        }
        if ($question['moderatable']) {
            $buttons['approve'] = array('tags' => 'NAME="q_doapprove"' . $clicksuffix, 'label' => qa_lang_html('question/approve_button'));
            $buttons['reject'] = array('tags' => 'NAME="q_doreject"' . $clicksuffix, 'label' => qa_lang_html('question/reject_button'));
        }
        if ($question['hideable']) {
            $buttons['hide'] = array('tags' => 'NAME="q_dohide"' . $clicksuffix, 'label' => qa_lang_html('question/hide_button'), 'popup' => qa_lang_html('question/hide_q_popup'));
        }
        if ($question['reshowable']) {
            $buttons['reshow'] = array('tags' => 'NAME="q_doreshow"' . $clicksuffix, 'label' => qa_lang_html('question/reshow_button'));
        }
        if ($question['deleteable']) {
            $buttons['delete'] = array('tags' => 'NAME="q_dodelete"' . $clicksuffix, 'label' => qa_lang_html('question/delete_button'), 'popup' => qa_lang_html('question/delete_q_popup'));
        }
        if ($question['claimable']) {
            $buttons['claim'] = array('tags' => 'NAME="q_doclaim"' . $clicksuffix, 'label' => qa_lang_html('question/claim_button'));
        }
        if ($question['answerbutton']) {
            // don't show if shown by default
            $buttons['answer'] = array('tags' => 'NAME="q_doanswer" ID="q_doanswer" onClick="return qa_toggle_element(\'anew\')"', 'label' => qa_lang_html('question/answer_button'), 'popup' => qa_lang_html('question/answer_q_popup'));
        }
        if ($question['commentbutton']) {
            $buttons['comment'] = array('tags' => 'NAME="q_docomment" onClick="return qa_toggle_element(\'c' . $questionid . '\')"', 'label' => qa_lang_html('question/comment_button'), 'popup' => qa_lang_html('question/comment_q_popup'));
        }
        $q_view['form'] = array('style' => 'light', 'buttons' => $buttons, 'hidden' => array('qa_click' => ''));
    }
    //	Information about the question of the answer that this question follows on from (or a question directly)
    if (isset($parentquestion)) {
        $q_view['follows'] = array('label' => qa_lang_html($question['parentid'] == $parentquestion['postid'] ? 'question/follows_q' : 'question/follows_a'), 'title' => qa_html(qa_block_words_replace($parentquestion['title'], qa_get_block_words_preg())), 'url' => qa_q_path_html($parentquestion['postid'], $parentquestion['title'], false, $question['parentid'] == $parentquestion['postid'] ? 'Q' : 'A', $question['parentid']));
    }
    //	Information about the question that this question is a duplicate of (if appropriate)
    if (isset($closepost)) {
        if ($closepost['basetype'] == 'Q') {
            $q_view['closed'] = array('label' => qa_lang_html('question/closed_as_duplicate'), 'content' => qa_html(qa_block_words_replace($closepost['title'], qa_get_block_words_preg())), 'url' => qa_q_path_html($closepost['postid'], $closepost['title']));
        } elseif ($closepost['type'] == 'NOTE') {
            $viewer = qa_load_viewer($closepost['content'], $closepost['format']);
            $q_view['closed'] = array('label' => qa_lang_html('question/closed_with_note'), 'content' => $viewer->get_html($closepost['content'], $closepost['format'], array('blockwordspreg' => qa_get_block_words_preg())));
        }
    }
    //	Extra value display
    if (strlen(@$question['extra']) && qa_opt('extra_field_active') && qa_opt('extra_field_display')) {
        $q_view['extra'] = array('label' => qa_html(qa_opt('extra_field_label')), 'content' => qa_html(qa_block_words_replace($question['extra'], qa_get_block_words_preg())));
    }
    return $q_view;
}