Ejemplo n.º 1
0
function qa_category_nav_to_browse(&$navigation, $categories, $categoryid, $favoritemap)
{
    foreach ($navigation as $key => $navlink) {
        $category = $categories[$navlink['categoryid']];
        if (!$category['childcount']) {
            unset($navigation[$key]['url']);
        } elseif ($navlink['selected']) {
            $navigation[$key]['state'] = 'open';
            $navigation[$key]['url'] = qa_path_html('categories/' . qa_category_path_request($categories, $category['parentid']));
        } else {
            $navigation[$key]['state'] = 'closed';
        }
        if (@$favoritemap[$navlink['categoryid']]) {
            $navigation[$key]['favorited'] = true;
        }
        $navigation[$key]['note'] = '';
        $navigation[$key]['note'] .= ' - <a href="' . qa_path_html('questions/' . implode('/', array_reverse(explode('/', $category['backpath'])))) . '">' . ($category['qcount'] == 1 ? qa_lang_html_sub('main/1_question', '1', '1') : qa_lang_html_sub('main/x_questions', qa_format_number($category['qcount'], 0, true))) . '</a>';
        if (strlen($category['content'])) {
            $navigation[$key]['note'] .= qa_html(' - ' . $category['content']);
        }
        if (isset($navlink['subnav'])) {
            qa_category_nav_to_browse($navigation[$key]['subnav'], $categories, $categoryid, $favoritemap);
        }
    }
}
Ejemplo n.º 2
0
function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitle, $nonetitle, $navcategories, $categoryid, $categoryqcount, $categorypathprefix, $feedpathprefix, $suggest, $pagelinkparams = null, $categoryparams = null, $dummy = null)
{
    if (qa_to_override(__FUNCTION__)) {
        $args = func_get_args();
        return qa_call_override(__FUNCTION__, $args);
    }
    require_once QA_INCLUDE_DIR . 'app/format.php';
    require_once QA_INCLUDE_DIR . 'app/updates.php';
    $userid = qa_get_logged_in_userid();
    //	Chop down to size, get user information for display
    if (isset($pagesize)) {
        $questions = array_slice($questions, 0, $pagesize);
    }
    $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions));
    //	Prepare content for theme
    $qa_content = qa_content_prepare(true, array_keys(qa_category_path($navcategories, $categoryid)));
    $qa_content['q_list']['form'] = array('tags' => 'method="post" action="' . qa_self_html() . '"', 'hidden' => array('code' => qa_get_form_security_code('vote')));
    $qa_content['q_list']['qs'] = array();
    if (count($questions)) {
        $qa_content['title'] = $sometitle;
        $defaults = qa_post_html_defaults('Q');
        if (isset($categorypathprefix)) {
            $defaults['categorypathprefix'] = $categorypathprefix;
        }
        foreach ($questions as $question) {
            $fields = qa_any_to_q_html_fields($question, $userid, qa_cookie_get(), $usershtml, null, qa_post_html_options($question, $defaults));
            if (!empty($fields['raw']['closedbyid'])) {
                $fields['closed'] = array('state' => qa_lang_html('main/closed'));
            }
            $qa_content['q_list']['qs'][] = $fields;
        }
    } else {
        $qa_content['title'] = $nonetitle;
    }
    if (isset($userid) && isset($categoryid)) {
        $favoritemap = qa_get_favorite_non_qs_map();
        $categoryisfavorite = @$favoritemap['category'][$navcategories[$categoryid]['backpath']];
        $qa_content['favorite'] = qa_favorite_form(QA_ENTITY_CATEGORY, $categoryid, $categoryisfavorite, qa_lang_sub($categoryisfavorite ? 'main/remove_x_favorites' : 'main/add_category_x_favorites', $navcategories[$categoryid]['title']));
    }
    if (isset($count) && isset($pagesize)) {
        $qa_content['page_links'] = qa_html_page_links(qa_request(), $start, $pagesize, $count, qa_opt('pages_prev_next'), $pagelinkparams);
    }
    if (empty($qa_content['page_links'])) {
        $qa_content['suggest_next'] = $suggest;
    }
    if (qa_using_categories() && count($navcategories) && isset($categorypathprefix)) {
        $qa_content['navigation']['cat'] = qa_category_navigation($navcategories, $categoryid, $categorypathprefix, $categoryqcount, $categoryparams);
    }
    if (isset($feedpathprefix) && (qa_opt('feed_per_category') || !isset($categoryid))) {
        $qa_content['feed'] = array('url' => qa_path_html(qa_feed_request($feedpathprefix . (isset($categoryid) ? '/' . qa_category_path_request($navcategories, $categoryid) : ''))), 'label' => strip_tags($sometitle));
    }
    return $qa_content;
}
 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;
 }
Ejemplo n.º 4
0
function qa_q_list_page_content($questions, $pagesize, $start, $count, $sometitle, $nonetitle, $navcategories, $categoryid, $categoryqcount, $categorypathprefix, $feedpathprefix, $suggest, $pagelinkparams = array())
{
    require_once QA_INCLUDE_DIR . 'qa-app-format.php';
    global $qa_login_userid, $qa_cookieid, $qa_request;
    // get globals from qa-page.php
    //	Chop down to size, get user information for display
    if (isset($pagesize)) {
        $questions = array_slice($questions, 0, $pagesize);
    }
    $usershtml = qa_userids_handles_html(qa_any_get_userids_handles($questions));
    //	Prepare content for theme
    $qa_content = qa_content_prepare(true, array_keys(qa_category_path($navcategories, $categoryid)));
    $qa_content['q_list']['form'] = array('tags' => 'METHOD="POST" ACTION="' . qa_self_html() . '"');
    $qa_content['q_list']['qs'] = array();
    if (count($questions)) {
        $qa_content['title'] = $sometitle;
        $options = qa_post_html_defaults('Q');
        if (isset($categorypathprefix)) {
            $options['categorypathprefix'] = $categorypathprefix;
        }
        foreach ($questions as $question) {
            $qa_content['q_list']['qs'][] = qa_any_to_q_html_fields($question, $qa_login_userid, $qa_cookieid, $usershtml, null, $options);
        }
    } else {
        $qa_content['title'] = $nonetitle;
    }
    if (isset($count) && isset($pagesize)) {
        $qa_content['page_links'] = qa_html_page_links($qa_request, $start, $pagesize, $count, qa_opt('pages_prev_next'), $pagelinkparams);
    }
    if (empty($qa_content['page_links'])) {
        $qa_content['suggest_next'] = $suggest;
    }
    if (qa_using_categories() && count($navcategories) && isset($categorypathprefix)) {
        $qa_content['navigation']['cat'] = qa_category_navigation($navcategories, $categoryid, $categorypathprefix, $categoryqcount);
    }
    if (isset($feedpathprefix) && (qa_opt('feed_per_category') || !isset($categoryid))) {
        $qa_content['feed'] = array('url' => qa_path_html(qa_feed_request($feedpathprefix . (isset($categoryid) ? '/' . qa_category_path_request($navcategories, $categoryid) : ''))), 'label' => strip_tags($sometitle));
    }
    return $qa_content;
}
Ejemplo n.º 5
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
*/
Ejemplo 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
*/
Ejemplo n.º 7
0
     $childdepth = qa_db_category_child_depth($editcategory['categoryid']);
     qa_set_up_category_field($qa_content, $qa_content['form']['fields']['parent'], 'parent', isset($incategories) ? $incategories : $categories, isset($inparentid) ? $inparentid : @$editcategory['parentid'], true, true, QA_CATEGORY_DEPTH - 1 - $childdepth, @$editcategory['categoryid']);
     $qa_content['form']['fields']['parent']['options'][''] = qa_lang_html('admin/category_top_level');
     @($qa_content['form']['fields']['parent']['note'] .= qa_lang_html_sub('admin/category_max_depth_x', QA_CATEGORY_DEPTH));
 } elseif (isset($editcategory['categoryid'])) {
     // existing category
     if ($hassubcategory) {
         $qa_content['form']['fields']['name']['note'] = qa_lang_html('admin/category_no_delete_subs');
         unset($qa_content['form']['fields']['delete']);
         unset($qa_content['form']['fields']['reassign']);
     } else {
         $qa_content['form']['fields']['delete'] = array('tags' => 'name="dodelete" id="dodelete"', 'label' => '<span id="reassign_shown">' . qa_lang_html('admin/delete_category_reassign') . '</span>' . '<span id="reassign_hidden" style="display:none;">' . qa_lang_html('admin/delete_category') . '</span>', 'value' => 0, 'type' => 'checkbox');
         $qa_content['form']['fields']['reassign'] = array('id' => 'reassign_display', 'tags' => 'name="reassign"');
         qa_set_up_category_field($qa_content, $qa_content['form']['fields']['reassign'], 'reassign', $categories, $editcategory['parentid'], true, true, null, $editcategory['categoryid']);
     }
     $qa_content['form']['fields']['questions'] = array('label' => qa_lang_html('admin/total_qs'), 'type' => 'static', 'value' => '<a href="' . qa_path_html('questions/' . qa_category_path_request($categories, $editcategory['categoryid'])) . '">' . ($editcategory['qcount'] == 1 ? qa_lang_html_sub('main/1_question', '1', '1') : qa_lang_html_sub('main/x_questions', number_format($editcategory['qcount']))) . '</a>');
     if ($hassubcategory && !qa_opt('allow_no_sub_category')) {
         $nosubcount = qa_db_count_categoryid_qs($editcategory['categoryid']);
         if ($nosubcount) {
             $qa_content['form']['fields']['questions']['error'] = strtr(qa_lang_html('admin/category_no_sub_error'), array('^q' => number_format($nosubcount), '^1' => '<a href="' . qa_path_html(qa_request(), array('edit' => $editcategory['categoryid'], 'missing' => 1)) . '">', '^2' => '</a>'));
         }
     }
     qa_set_display_rules($qa_content, array('position_display' => '!dodelete', 'slug_display' => '!dodelete', 'content_display' => '!dodelete', 'parent_display' => '!dodelete', 'children_display' => '!dodelete', 'reassign_display' => 'dodelete', 'reassign_shown' => 'dodelete', 'reassign_hidden' => '!dodelete'));
 } else {
     // new category
     unset($qa_content['form']['fields']['delete']);
     unset($qa_content['form']['fields']['reassign']);
     unset($qa_content['form']['fields']['slug']);
     unset($qa_content['form']['fields']['questions']);
     $qa_content['focusid'] = 'name';
 }
Ejemplo n.º 8
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
*/
Ejemplo n.º 9
0
function qa_book_plugin_createBook($return = false)
{
    $book = qa_opt('book_plugin_template');
    // static replacements
    $book = str_replace('[css]', qa_opt('book_plugin_css'), $book);
    $book = str_replace('[front]', qa_opt('book_plugin_template_front'), $book);
    $book = str_replace('[back]', qa_opt('book_plugin_template_back'), $book);
    $iscats = qa_opt('book_plugin_cats');
    // categories
    if ($iscats) {
        $cats = qa_db_read_all_assoc(qa_db_query_sub('SELECT * FROM ^categories' . (qa_opt('book_plugin_catex') ? ' WHERE categoryid NOT IN (' . qa_opt('book_plugin_catex') . ')' : '')));
        $navcats = array();
        foreach ($cats as $cat) {
            $navcats[$cat['categoryid']] = $cat;
        }
    } else {
        $cats = array(false);
    }
    // intro
    $intro = qa_lang('book/intro');
    $intro = str_replace('[sort_questions]', qa_lang('book/' . (qa_opt('book_plugin_sort_q') == 0 ? 'sort_upvotes' : 'sort_date')), $intro);
    $intro = str_replace('[sort_categories]', $iscats ? qa_lang('book/sort_categories') : '', $intro);
    $intro = str_replace('[restrict_questions]', qa_opt('book_plugin_req_qv') ? qa_lang_sub('book/restrict_q_x_votes', qa_opt('book_plugin_req_qv_no')) : qa_lang('book/all_questions'), $intro);
    $rq = array();
    if (qa_opt('book_plugin_req_sel')) {
        $rq[] = qa_lang('book/restrict_selected');
    }
    if (qa_opt('book_plugin_req_abest')) {
        $rq[] = qa_lang('book/restrict_best_a');
    }
    if (qa_opt('book_plugin_req_av')) {
        $rq[] = qa_lang_sub('book/restrict_a_x_votes', qa_opt('book_plugin_req_av_no'));
    }
    if (empty($rq)) {
        $intro = str_replace('[restrict_answers]', '', $intro);
    } else {
        $rqs = qa_lang('book/restrict_answers_clause_' . count($rq));
        foreach ($rq as $i => $v) {
            $rqs = str_replace('(' . ($i + 1) . ')', $v, $rqs);
        }
        $intro = str_replace('[restrict_answers]', $rqs, $intro);
    }
    $book = str_replace('[intro]', $intro, $book);
    $tocout = '';
    $qout = '';
    foreach ($cats as $cat) {
        $incsql = '';
        $sortsql = '';
        $toc = '';
        $qhtml = '';
        if (qa_opt('book_plugin_sort_q') == 0) {
            $sortsql = 'ORDER BY qs.netvotes DESC, qs.created ASC';
        } else {
            $sortsql = 'ORDER BY qs.created ASC';
        }
        if (qa_opt('book_plugin_req_sel')) {
            $incsql .= ' AND qs.selchildid=ans.postid';
        }
        if (qa_opt('book_plugin_req_abest')) {
            $sortsql .= ', ans.netvotes DESC';
        }
        // get all, limit later with break
        if (qa_opt('book_plugin_req_qv')) {
            $incsql .= ' AND qs.netvotes >= ' . (int) qa_opt('book_plugin_req_qv_no');
        }
        if (qa_opt('book_plugin_req_av')) {
            $incsql .= ' AND ans.netvotes >= ' . (int) qa_opt('book_plugin_req_av_no');
        }
        $selectspec = "SELECT qs.postid AS postid, BINARY qs.title AS title, BINARY qs.content AS content, qs.format AS format, qs.netvotes AS netvotes, BINARY ans.content AS acontent, ans.format AS aformat, ans.userid AS auserid, ans.netvotes AS anetvotes FROM ^posts AS qs, ^posts AS ans WHERE qs.type='Q' AND ans.type='A' AND ans.parentid=qs.postid" . ($iscats ? " AND qs.categoryid=" . $cat['categoryid'] . " " : "") . $incsql . " " . $sortsql;
        $qs = qa_db_read_all_assoc(qa_db_query_sub($selectspec));
        if (empty($qs)) {
            // no questions in this category
            continue;
        }
        $q2 = array();
        foreach ($qs as $q) {
            // group by questions
            $q2['q' . $q['postid']][] = $q;
        }
        foreach ($q2 as $qs) {
            // toc entry
            $toc .= str_replace('[qlink]', '<a href="#question' . $qs[0]['postid'] . '">' . $qs[0]['title'] . '</a>', qa_opt('book_plugin_template_toc'));
            // answer html
            $as = '';
            $nv = false;
            foreach ($qs as $idx => $q) {
                if (qa_opt('book_plugin_req_abest') && qa_opt('book_plugin_req_abest_max') && $idx >= qa_opt('book_plugin_req_abest_max')) {
                    break;
                }
                if ($nv !== false && qa_opt('book_plugin_req_abest') && $nv != $q['anetvotes']) {
                    // best answers only
                    break;
                }
                $acontent = '';
                if (!empty($q['acontent'])) {
                    $viewer = qa_load_viewer($q['acontent'], $q['aformat']);
                    $acontent = $viewer->get_html($q['acontent'], $q['aformat'], array());
                }
                $a = str_replace('[answer]', $acontent, qa_opt('book_plugin_template_answer'));
                $a = str_replace('[answerer]', qa_get_user_name($q['auserid']), $a);
                $as .= $a;
                $nv = $q['anetvotes'];
            }
            // question html
            $qcontent = '';
            if (!empty($q['content'])) {
                $viewer = qa_load_viewer($q['content'], $q['format']);
                $qcontent = $viewer->get_html($q['content'], $q['format'], array());
            }
            $oneq = str_replace('[question-title]', $q['title'], qa_opt('book_plugin_template_question'));
            $oneq = str_replace('[qanchor]', 'question' . $q['postid'], $oneq);
            $oneq = str_replace('[qurl]', qa_html(qa_q_request($q['postid'], $q['title'])), $oneq);
            $oneq = str_replace('[question]', $qcontent, $oneq);
            // output with answers
            $qhtml .= str_replace('[answers]', $as, $oneq);
        }
        if ($iscats) {
            $tocout .= '<li><a href="#cat' . $cat['categoryid'] . '" class="toc-cat">' . $cat['title'] . '</a><ul class="toc-ul">' . $toc . '</ul></li>';
            // todo fix category link
            $catout = str_replace('[cat-url]', qa_path_html('questions/' . qa_category_path_request($navcats, $cat['categoryid'])), qa_opt('book_plugin_template_category'));
            $catout = str_replace('[cat-anchor]', 'cat' . $cat['categoryid'], $catout);
            $catout = str_replace('[cat-title]', $cat['title'], $catout);
            $catout = str_replace('[questions]', $qhtml, $catout);
            $qout .= $catout;
        } else {
            $tocout .= '<ul class="toc-ul">' . $toc . '</ul>';
            $catout = str_replace('[questions]', $qhtml, qa_opt('book_plugin_template_questions'));
            $qout .= $catout;
        }
    }
    if ($iscats) {
        $tocout = '<ul class="toc-ul">' . $tocout . '</ul>';
    }
    // add toc and questions
    $book = str_replace('[toc]', $tocout, $book);
    $book = str_replace('[categories]', $qout, $book);
    // misc subs
    $book = str_replace('[site-title]', qa_opt('site_title'), $book);
    $book = str_replace('[site-url]', qa_opt('site_url'), $book);
    $book = str_replace('[date]', date('M j, Y'), $book);
    qa_opt('book_plugin_refresh_last', time());
    error_log('Q2A Book Created on ' . date('M j, Y \\a\\t H\\:i\\:s'));
    if ($return) {
        return $book;
    }
    file_put_contents(qa_opt('book_plugin_loc'), $book);
    if (qa_opt('book_plugin_pdf')) {
        qa_book_plugin_create_pdf();
    }
    return 'Book Created';
    //return 'Error creating '.qa_opt('book_plugin_loc').'; check the error log.';
}
Ejemplo n.º 10
0
    $qa_content = qa_content_prepare();
    $level = qa_get_logged_in_level();
    if (!qa_permit_value_error($custompage['permit'], $userid, $level, qa_get_logged_in_flags()) || !isset($custompage['permit'])) {
        $qa_content['title'] = qa_html($custompage['heading']);
        $qa_content['custom'] = $custompage['content'];
        if ($level >= QA_USER_LEVEL_ADMIN) {
            $qa_content['navigation']['sub'] = array('admin/pages' => array('label' => qa_lang('admin/edit_custom_page'), 'url' => qa_path_html('admin/pages', array('edit' => $custompage['pageid']))));
        }
    } else {
        $qa_content['error'] = qa_lang_html('users/no_permission');
    }
    return $qa_content;
}
//	Then, see if we should redirect because the 'qa' page is the same as the home page
if ($explicitqa && !qa_is_http_post() && !qa_has_custom_home()) {
    qa_redirect(qa_category_path_request($categories, $categoryid), $_GET);
}
//	Then, if there's a slug that matches no category, check page modules provided by plugins
if (!$explicitqa && $countslugs && !isset($categoryid)) {
    $pagemodules = qa_load_modules_with('page', 'match_request');
    $request = qa_request();
    foreach ($pagemodules as $pagemodule) {
        if ($pagemodule->match_request($request)) {
            qa_set_template('plugin');
            return $pagemodule->process_request($request);
        }
    }
}
//	Then, check whether we are showing a custom home page
if (!$explicitqa && !$countslugs && qa_opt('show_custom_home')) {
    qa_set_template('custom');