Commit b0af268c by Scott

Coding style (question list pages)

parent d20bc5f0
...@@ -20,66 +20,61 @@ ...@@ -20,66 +20,61 @@
More about this license: http://www.question2answer.org/license.php 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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR.'app/q-list.php'; require_once QA_INCLUDE_DIR . 'app/q-list.php';
$categoryslugs=qa_request_parts(1); $categoryslugs = qa_request_parts(1);
$countslugs=count($categoryslugs); $countslugs = count($categoryslugs);
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
// Get lists of recent activity in all its forms, plus category information // Get lists of recent activity in all its forms, plus category information
list($questions1, $questions2, $questions3, $questions4, $categories, $categoryid)=qa_db_select_with_pending( 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_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_a_qs_selectspec($userid, 0, $categoryslugs),
qa_db_recent_c_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_recent_edit_qs_selectspec($userid, 0, $categoryslugs),
qa_db_category_nav_selectspec($categoryslugs, false, false, true), qa_db_category_nav_selectspec($categoryslugs, false, false, true),
$countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null
); );
if ($countslugs) { if ($countslugs) {
if (!isset($categoryid)) if (!isset($categoryid))
return include QA_INCLUDE_DIR.'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
$categorytitlehtml=qa_html($categories[$categoryid]['title']); $categorytitlehtml = qa_html($categories[$categoryid]['title']);
$sometitle=qa_lang_html_sub('main/recent_activity_in_x', $categorytitlehtml); $sometitle = qa_lang_html_sub('main/recent_activity_in_x', $categorytitlehtml);
$nonetitle=qa_lang_html_sub('main/no_questions_in_x', $categorytitlehtml); $nonetitle = qa_lang_html_sub('main/no_questions_in_x', $categorytitlehtml);
} else { } else {
$sometitle=qa_lang_html('main/recent_activity_title'); $sometitle = qa_lang_html('main/recent_activity_title');
$nonetitle=qa_lang_html('main/no_questions_found'); $nonetitle = qa_lang_html('main/no_questions_found');
} }
// Prepare and return content for theme // Prepare and return content for theme
return qa_q_list_page_content( return qa_q_list_page_content(
qa_any_sort_and_dedupe(array_merge($questions1, $questions2, $questions3, $questions4)), // questions qa_any_sort_and_dedupe(array_merge($questions1, $questions2, $questions3, $questions4)), // questions
qa_opt('page_size_activity'), // questions per page qa_opt('page_size_activity'), // questions per page
0, // start offset 0, // start offset
null, // total count (null to hide page links) null, // total count (null to hide page links)
$sometitle, // title if some questions $sometitle, // title if some questions
$nonetitle, // title if no questions $nonetitle, // title if no questions
$categories, // categories for navigation $categories, // categories for navigation
$categoryid, // selected category id $categoryid, // selected category id
true, // show question counts in category navigation true, // show question counts in category navigation
'activity/', // prefix for links in category navigation 'activity/', // prefix for links in category navigation
qa_opt('feed_for_activity') ? 'activity' : null, // prefix for RSS feed paths (null to hide) qa_opt('feed_for_activity') ? 'activity' : null, // prefix for RSS feed paths (null to hide)
qa_html_suggest_qs_tags(qa_using_tags(), qa_category_path_request($categories, $categoryid)), // suggest what to do next qa_html_suggest_qs_tags(qa_using_tags(), qa_category_path_request($categories, $categoryid)), // suggest what to do next
null, // page link params null, // page link params
null // category nav params null // category nav params
); );
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,61 +20,56 @@ ...@@ -20,61 +20,56 @@
More about this license: http://www.question2answer.org/license.php 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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR.'app/q-list.php'; require_once QA_INCLUDE_DIR . 'app/q-list.php';
$categoryslugs=qa_request_parts(1); $categoryslugs = qa_request_parts(1);
$countslugs=count($categoryslugs); $countslugs = count($categoryslugs);
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
// Get list of answers with related questions, plus category information // Get list of answers with related questions, plus category information
list($questions, $categories, $categoryid)=qa_db_select_with_pending( list($questions, $categories, $categoryid) = qa_db_select_with_pending(
qa_db_recent_a_qs_selectspec($userid, 0, $categoryslugs), qa_db_recent_a_qs_selectspec($userid, 0, $categoryslugs),
qa_db_category_nav_selectspec($categoryslugs, false, false, true), qa_db_category_nav_selectspec($categoryslugs, false, false, true),
$countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null
); );
if ($countslugs) { if ($countslugs) {
if (!isset($categoryid)) if (!isset($categoryid))
return include QA_INCLUDE_DIR.'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
$categorytitlehtml=qa_html($categories[$categoryid]['title']); $categorytitlehtml = qa_html($categories[$categoryid]['title']);
$sometitle=qa_lang_html_sub('main/recent_as_in_x', $categorytitlehtml); $sometitle = qa_lang_html_sub('main/recent_as_in_x', $categorytitlehtml);
$nonetitle=qa_lang_html_sub('main/no_answers_in_x', $categorytitlehtml); $nonetitle = qa_lang_html_sub('main/no_answers_in_x', $categorytitlehtml);
} else { } else {
$sometitle=qa_lang_html('main/recent_as_title'); $sometitle = qa_lang_html('main/recent_as_title');
$nonetitle=qa_lang_html('main/no_answers_found'); $nonetitle = qa_lang_html('main/no_answers_found');
} }
// Prepare and return content for theme // Prepare and return content for theme
return qa_q_list_page_content( return qa_q_list_page_content(
qa_any_sort_and_dedupe($questions), // questions qa_any_sort_and_dedupe($questions), // questions
qa_opt('page_size_activity'), // questions per page qa_opt('page_size_activity'), // questions per page
0, // start offset 0, // start offset
null, // total count (null to hide page links) null, // total count (null to hide page links)
$sometitle, // title if some questions $sometitle, // title if some questions
$nonetitle, // title if no questions $nonetitle, // title if no questions
$categories, // categories for navigation $categories, // categories for navigation
$categoryid, // selected category id $categoryid, // selected category id
false, // show question counts in category navigation false, // show question counts in category navigation
'answers/', // prefix for links in category navigation 'answers/', // prefix for links in category navigation
qa_opt('feed_for_activity') ? 'answers' : null, // prefix for RSS feed paths (null to hide) qa_opt('feed_for_activity') ? 'answers' : null, // prefix for RSS feed paths (null to hide)
qa_html_suggest_qs_tags(qa_using_tags(), qa_category_path_request($categories, $categoryid)) // suggest what to do next qa_html_suggest_qs_tags(qa_using_tags(), qa_category_path_request($categories, $categoryid)) // suggest what to do next
); );
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,60 +20,55 @@ ...@@ -20,60 +20,55 @@
More about this license: http://www.question2answer.org/license.php 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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR.'app/q-list.php'; require_once QA_INCLUDE_DIR . 'app/q-list.php';
$categoryslugs=qa_request_parts(1); $categoryslugs = qa_request_parts(1);
$countslugs=count($categoryslugs); $countslugs = count($categoryslugs);
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
// Get list of comments with related questions, plus category information // Get list of comments with related questions, plus category information
list($questions, $categories, $categoryid)=qa_db_select_with_pending( list($questions, $categories, $categoryid) = qa_db_select_with_pending(
qa_db_recent_c_qs_selectspec($userid, 0, $categoryslugs), qa_db_recent_c_qs_selectspec($userid, 0, $categoryslugs),
qa_db_category_nav_selectspec($categoryslugs, false, false, true), qa_db_category_nav_selectspec($categoryslugs, false, false, true),
$countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null
); );
if ($countslugs) { if ($countslugs) {
if (!isset($categoryid)) if (!isset($categoryid))
return include QA_INCLUDE_DIR.'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
$categorytitlehtml=qa_html($categories[$categoryid]['title']); $categorytitlehtml = qa_html($categories[$categoryid]['title']);
$sometitle=qa_lang_html_sub('main/recent_cs_in_x', $categorytitlehtml); $sometitle = qa_lang_html_sub('main/recent_cs_in_x', $categorytitlehtml);
$nonetitle=qa_lang_html_sub('main/no_comments_in_x', $categorytitlehtml); $nonetitle = qa_lang_html_sub('main/no_comments_in_x', $categorytitlehtml);
} else { } else {
$sometitle=qa_lang_html('main/recent_cs_title'); $sometitle = qa_lang_html('main/recent_cs_title');
$nonetitle=qa_lang_html('main/no_comments_found'); $nonetitle = qa_lang_html('main/no_comments_found');
} }
// Prepare and return content for theme // Prepare and return content for theme
return qa_q_list_page_content( return qa_q_list_page_content(
qa_any_sort_and_dedupe($questions), // questions qa_any_sort_and_dedupe($questions), // questions
qa_opt('page_size_activity'), // questions per page qa_opt('page_size_activity'), // questions per page
0, // start offset 0, // start offset
null, // total count (null to hide page links) null, // total count (null to hide page links)
$sometitle, // title if some questions $sometitle, // title if some questions
$nonetitle, // title if no questions $nonetitle, // title if no questions
$categories, // categories for navigation $categories, // categories for navigation
$categoryid, // selected category id $categoryid, // selected category id
false, // show question counts in category navigation false, // show question counts in category navigation
'comments/', // prefix for links in category navigation 'comments/', // prefix for links in category navigation
qa_opt('feed_for_activity') ? 'comments' : null, // prefix for RSS feed paths (null to hide) qa_opt('feed_for_activity') ? 'comments' : null, // prefix for RSS feed paths (null to hide)
qa_html_suggest_qs_tags(qa_using_tags(), qa_category_path_request($categories, $categoryid)) // suggest what to do next qa_html_suggest_qs_tags(qa_using_tags(), qa_category_path_request($categories, $categoryid)) // suggest what to do next
); );
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,151 +20,147 @@ ...@@ -20,151 +20,147 @@
More about this license: http://www.question2answer.org/license.php 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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
// Determine whether path begins with qa or not (question and answer listing can be accessed either way) // Determine whether path begins with qa or not (question and answer listing can be accessed either way)
$requestparts=explode('/', qa_request()); $requestparts = explode('/', qa_request());
$explicitqa=(strtolower($requestparts[0])=='qa'); $explicitqa = (strtolower($requestparts[0]) == 'qa');
if ($explicitqa) if ($explicitqa)
$slugs=array_slice($requestparts, 1); $slugs = array_slice($requestparts, 1);
elseif (strlen($requestparts[0])) elseif (strlen($requestparts[0]))
$slugs=$requestparts; $slugs = $requestparts;
else else
$slugs=array(); $slugs = array();
$countslugs=count($slugs); $countslugs = count($slugs);
// Get list of questions, other bits of information that might be useful // Get list of questions, other bits of information that might be useful
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
list($questions1, $questions2, $categories, $categoryid, $custompage)=qa_db_select_with_pending( list($questions1, $questions2, $categories, $categoryid, $custompage) = qa_db_select_with_pending(
qa_db_qs_selectspec($userid, 'created', 0, $slugs, null, false, false, qa_opt_if_loaded('page_size_activity')), qa_db_qs_selectspec($userid, 'created', 0, $slugs, null, false, false, qa_opt_if_loaded('page_size_activity')),
qa_db_recent_a_qs_selectspec($userid, 0, $slugs), qa_db_recent_a_qs_selectspec($userid, 0, $slugs),
qa_db_category_nav_selectspec($slugs, false, false, true), qa_db_category_nav_selectspec($slugs, false, false, true),
$countslugs ? qa_db_slugs_to_category_id_selectspec($slugs) : null, $countslugs ? qa_db_slugs_to_category_id_selectspec($slugs) : null,
(($countslugs==1) && !$explicitqa) ? qa_db_page_full_selectspec($slugs[0], false) : null (($countslugs == 1) && !$explicitqa) ? qa_db_page_full_selectspec($slugs[0], false) : null
); );
// First, if this matches a custom page, return immediately with that page's content // First, if this matches a custom page, return immediately with that page's content
if ( isset($custompage) && !($custompage['flags']&QA_PAGE_FLAGS_EXTERNAL) ) { if (isset($custompage) && !($custompage['flags'] & QA_PAGE_FLAGS_EXTERNAL)) {
qa_set_template('custom-'.$custompage['pageid']); qa_set_template('custom-' . $custompage['pageid']);
$qa_content=qa_content_prepare(); $qa_content = qa_content_prepare();
$level=qa_get_logged_in_level(); $level = qa_get_logged_in_level();
if ( (!qa_permit_value_error($custompage['permit'], $userid, $level, qa_get_logged_in_flags())) || !isset($custompage['permit']) ) { 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['title'] = qa_html($custompage['heading']);
$qa_content['custom']=$custompage['content']; $qa_content['custom'] = $custompage['content'];
if ($level>=QA_USER_LEVEL_ADMIN) { if ($level >= QA_USER_LEVEL_ADMIN) {
$qa_content['navigation']['sub']=array( $qa_content['navigation']['sub'] = array(
'admin/pages' => array( 'admin/pages' => array(
'label' => qa_lang('admin/edit_custom_page'), 'label' => qa_lang('admin/edit_custom_page'),
'url' => qa_path_html('admin/pages', array('edit' => $custompage['pageid'])), 'url' => qa_path_html('admin/pages', array('edit' => $custompage['pageid'])),
), ),
); );
} }
} else } else
$qa_content['error']=qa_lang_html('users/no_permission'); $qa_content['error'] = qa_lang_html('users/no_permission');
return $qa_content; return $qa_content;
} }
// Then, see if we should redirect because the 'qa' page is the same as the home page // 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()) if ($explicitqa && (!qa_is_http_post()) && !qa_has_custom_home())
qa_redirect(qa_category_path_request($categories, $categoryid), $_GET); 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 // Then, if there's a slug that matches no category, check page modules provided by plugins
if ( (!$explicitqa) && $countslugs && !isset($categoryid) ) { if ((!$explicitqa) && $countslugs && !isset($categoryid)) {
$pagemodules=qa_load_modules_with('page', 'match_request'); $pagemodules = qa_load_modules_with('page', 'match_request');
$request=qa_request(); $request = qa_request();
foreach ($pagemodules as $pagemodule) foreach ($pagemodules as $pagemodule) {
if ($pagemodule->match_request($request)) { if ($pagemodule->match_request($request)) {
$tmpl = isset($custompage['pageid']) ? 'custom-'.$custompage['pageid'] : 'custom'; $tmpl = isset($custompage['pageid']) ? 'custom-' . $custompage['pageid'] : 'custom';
qa_set_template($tmpl); qa_set_template($tmpl);
return $pagemodule->process_request($request); return $pagemodule->process_request($request);
} }
} }
}
// Then, check whether we are showing a custom home page // Then, check whether we are showing a custom home page
if ( (!$explicitqa) && (!$countslugs) && qa_opt('show_custom_home') ) { if ((!$explicitqa) && (!$countslugs) && qa_opt('show_custom_home')) {
qa_set_template('custom'); qa_set_template('custom');
$qa_content=qa_content_prepare(); $qa_content = qa_content_prepare();
$qa_content['title']=qa_html(qa_opt('custom_home_heading')); $qa_content['title'] = qa_html(qa_opt('custom_home_heading'));
$qa_content['custom']=qa_opt('custom_home_content'); $qa_content['custom'] = qa_opt('custom_home_content');
return $qa_content; return $qa_content;
} }
// If we got this far, it's a good old-fashioned Q&A listing page // If we got this far, it's a good old-fashioned Q&A listing page
require_once QA_INCLUDE_DIR.'app/q-list.php'; require_once QA_INCLUDE_DIR . 'app/q-list.php';
qa_set_template('qa'); qa_set_template('qa');
$questions=qa_any_sort_and_dedupe(array_merge($questions1, $questions2)); $questions = qa_any_sort_and_dedupe(array_merge($questions1, $questions2));
$pagesize=qa_opt('page_size_home'); $pagesize = qa_opt('page_size_home');
if ($countslugs) { if ($countslugs) {
if (!isset($categoryid)) if (!isset($categoryid))
return include QA_INCLUDE_DIR.'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
$categorytitlehtml=qa_html($categories[$categoryid]['title']); $categorytitlehtml = qa_html($categories[$categoryid]['title']);
$sometitle=qa_lang_html_sub('main/recent_qs_as_in_x', $categorytitlehtml); $sometitle = qa_lang_html_sub('main/recent_qs_as_in_x', $categorytitlehtml);
$nonetitle=qa_lang_html_sub('main/no_questions_in_x', $categorytitlehtml); $nonetitle = qa_lang_html_sub('main/no_questions_in_x', $categorytitlehtml);
} else { } else {
$sometitle=qa_lang_html('main/recent_qs_as_title'); $sometitle = qa_lang_html('main/recent_qs_as_title');
$nonetitle=qa_lang_html('main/no_questions_found'); $nonetitle = qa_lang_html('main/no_questions_found');
} }
// Prepare and return content for theme for Q&A listing page // Prepare and return content for theme for Q&A listing page
$qa_content=qa_q_list_page_content( $qa_content = qa_q_list_page_content(
$questions, // questions $questions, // questions
$pagesize, // questions per page $pagesize, // questions per page
0, // start offset 0, // start offset
null, // total count (null to hide page links) null, // total count (null to hide page links)
$sometitle, // title if some questions $sometitle, // title if some questions
$nonetitle, // title if no questions $nonetitle, // title if no questions
$categories, // categories for navigation $categories, // categories for navigation
$categoryid, // selected category id $categoryid, // selected category id
true, // show question counts in category navigation true, // show question counts in category navigation
$explicitqa ? 'qa/' : '', // prefix for links in category navigation $explicitqa ? 'qa/' : '', // prefix for links in category navigation
qa_opt('feed_for_qa') ? 'qa' : null, // prefix for RSS feed paths (null to hide) qa_opt('feed_for_qa') ? 'qa' : null, // prefix for RSS feed paths (null to hide)
(count($questions)<$pagesize) // suggest what to do next (count($questions) < $pagesize) // suggest what to do next
? qa_html_suggest_ask($categoryid) ? qa_html_suggest_ask($categoryid)
: qa_html_suggest_qs_tags(qa_using_tags(), qa_category_path_request($categories, $categoryid)), : qa_html_suggest_qs_tags(qa_using_tags(), qa_category_path_request($categories, $categoryid)),
null, // page link params null, // page link params
null // category nav params null // category nav params
); );
return $qa_content; return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,61 +20,56 @@ ...@@ -20,61 +20,56 @@
More about this license: http://www.question2answer.org/license.php 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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/q-list.php'; require_once QA_INCLUDE_DIR . 'app/q-list.php';
// Get list of hottest questions, allow per-category if QA_ALLOW_UNINDEXED_QUERIES set in qa-config.php // Get list of hottest questions, allow per-category if QA_ALLOW_UNINDEXED_QUERIES set in qa-config.php
$categoryslugs=QA_ALLOW_UNINDEXED_QUERIES ? qa_request_parts(1) : null; $categoryslugs = QA_ALLOW_UNINDEXED_QUERIES ? qa_request_parts(1) : null;
$countslugs=@count($categoryslugs); $countslugs = @count($categoryslugs);
$start=qa_get_start(); $start = qa_get_start();
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
list($questions, $categories, $categoryid)=qa_db_select_with_pending( list($questions, $categories, $categoryid) = qa_db_select_with_pending(
qa_db_qs_selectspec($userid, 'hotness', $start, $categoryslugs, null, false, false, qa_opt_if_loaded('page_size_hot_qs')), qa_db_qs_selectspec($userid, 'hotness', $start, $categoryslugs, null, false, false, qa_opt_if_loaded('page_size_hot_qs')),
qa_db_category_nav_selectspec($categoryslugs, false, false, true), qa_db_category_nav_selectspec($categoryslugs, false, false, true),
$countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null
); );
if ($countslugs) { if ($countslugs) {
if (!isset($categoryid)) if (!isset($categoryid))
return include QA_INCLUDE_DIR.'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
$categorytitlehtml=qa_html($categories[$categoryid]['title']); $categorytitlehtml = qa_html($categories[$categoryid]['title']);
$sometitle=qa_lang_html_sub('main/hot_qs_in_x', $categorytitlehtml); $sometitle = qa_lang_html_sub('main/hot_qs_in_x', $categorytitlehtml);
$nonetitle=qa_lang_html_sub('main/no_questions_in_x', $categorytitlehtml); $nonetitle = qa_lang_html_sub('main/no_questions_in_x', $categorytitlehtml);
} else { } else {
$sometitle=qa_lang_html('main/hot_qs_title'); $sometitle = qa_lang_html('main/hot_qs_title');
$nonetitle=qa_lang_html('main/no_questions_found'); $nonetitle = qa_lang_html('main/no_questions_found');
} }
// Prepare and return content for theme // Prepare and return content for theme
return qa_q_list_page_content( return qa_q_list_page_content(
$questions, // questions $questions, // questions
qa_opt('page_size_hot_qs'), // questions per page qa_opt('page_size_hot_qs'), // questions per page
$start, // start offset $start, // start offset
$countslugs ? $categories[$categoryid]['qcount'] : qa_opt('cache_qcount'), // total count $countslugs ? $categories[$categoryid]['qcount'] : qa_opt('cache_qcount'), // total count
$sometitle, // title if some questions $sometitle, // title if some questions
$nonetitle, // title if no questions $nonetitle, // title if no questions
QA_ALLOW_UNINDEXED_QUERIES ? $categories : null, // categories for navigation QA_ALLOW_UNINDEXED_QUERIES ? $categories : null, // categories for navigation
$categoryid, // selected category id $categoryid, // selected category id
true, // show question counts in category navigation true, // show question counts in category navigation
QA_ALLOW_UNINDEXED_QUERIES ? 'hot/' : null, // prefix for links in category navigation (null if no navigation) QA_ALLOW_UNINDEXED_QUERIES ? 'hot/' : null, // prefix for links in category navigation (null if no navigation)
qa_opt('feed_for_hot') ? 'hot' : null, // prefix for RSS feed paths (null to hide) qa_opt('feed_for_hot') ? 'hot' : null, // prefix for RSS feed paths (null to hide)
qa_html_suggest_ask() // suggest what to do next qa_html_suggest_ask() // suggest what to do next
); );
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,121 +20,118 @@ ...@@ -20,121 +20,118 @@
More about this license: http://www.question2answer.org/license.php 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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR.'app/q-list.php'; require_once QA_INCLUDE_DIR . 'app/q-list.php';
$categoryslugs=qa_request_parts(1); $categoryslugs = qa_request_parts(1);
$countslugs=count($categoryslugs); $countslugs = count($categoryslugs);
$sort=($countslugs && !QA_ALLOW_UNINDEXED_QUERIES) ? null : qa_get('sort'); $sort = ($countslugs && !QA_ALLOW_UNINDEXED_QUERIES) ? null : qa_get('sort');
$start=qa_get_start(); $start = qa_get_start();
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
// Get list of questions, plus category information // Get list of questions, plus category information
switch ($sort) { switch ($sort) {
case 'hot': case 'hot':
$selectsort='hotness'; $selectsort = 'hotness';
break; break;
case 'votes': case 'votes':
$selectsort='netvotes'; $selectsort = 'netvotes';
break; break;
case 'answers': case 'answers':
$selectsort='acount'; $selectsort = 'acount';
break; break;
case 'views': case 'views':
$selectsort='views'; $selectsort = 'views';
break; break;
default: default:
$selectsort='created'; $selectsort = 'created';
break; break;
} }
list($questions, $categories, $categoryid)=qa_db_select_with_pending( list($questions, $categories, $categoryid) = qa_db_select_with_pending(
qa_db_qs_selectspec($userid, $selectsort, $start, $categoryslugs, null, false, false, qa_opt_if_loaded('page_size_qs')), qa_db_qs_selectspec($userid, $selectsort, $start, $categoryslugs, null, false, false, qa_opt_if_loaded('page_size_qs')),
qa_db_category_nav_selectspec($categoryslugs, false, false, true), qa_db_category_nav_selectspec($categoryslugs, false, false, true),
$countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null
); );
if ($countslugs) { if ($countslugs) {
if (!isset($categoryid)) if (!isset($categoryid))
return include QA_INCLUDE_DIR.'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
$categorytitlehtml=qa_html($categories[$categoryid]['title']); $categorytitlehtml = qa_html($categories[$categoryid]['title']);
$nonetitle=qa_lang_html_sub('main/no_questions_in_x', $categorytitlehtml); $nonetitle = qa_lang_html_sub('main/no_questions_in_x', $categorytitlehtml);
} else } else {
$nonetitle=qa_lang_html('main/no_questions_found'); $nonetitle = qa_lang_html('main/no_questions_found');
}
$categorypathprefix=QA_ALLOW_UNINDEXED_QUERIES ? 'questions/' : null; // this default is applied if sorted not by recent $categorypathprefix = QA_ALLOW_UNINDEXED_QUERIES ? 'questions/' : null; // this default is applied if sorted not by recent
$feedpathprefix=null; $feedpathprefix = null;
$linkparams=array('sort' => $sort); $linkparams = array('sort' => $sort);
switch ($sort) { switch ($sort) {
case 'hot': case 'hot':
$sometitle=$countslugs ? qa_lang_html_sub('main/hot_qs_in_x', $categorytitlehtml) : qa_lang_html('main/hot_qs_title'); $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; $feedpathprefix = qa_opt('feed_for_hot') ? 'hot' : null;
break; break;
case 'votes': case 'votes':
$sometitle=$countslugs ? qa_lang_html_sub('main/voted_qs_in_x', $categorytitlehtml) : qa_lang_html('main/voted_qs_title'); $sometitle = $countslugs ? qa_lang_html_sub('main/voted_qs_in_x', $categorytitlehtml) : qa_lang_html('main/voted_qs_title');
break; break;
case 'answers': case 'answers':
$sometitle=$countslugs ? qa_lang_html_sub('main/answered_qs_in_x', $categorytitlehtml) : qa_lang_html('main/answered_qs_title'); $sometitle = $countslugs ? qa_lang_html_sub('main/answered_qs_in_x', $categorytitlehtml) : qa_lang_html('main/answered_qs_title');
break; break;
case 'views': case 'views':
$sometitle=$countslugs ? qa_lang_html_sub('main/viewed_qs_in_x', $categorytitlehtml) : qa_lang_html('main/viewed_qs_title'); $sometitle = $countslugs ? qa_lang_html_sub('main/viewed_qs_in_x', $categorytitlehtml) : qa_lang_html('main/viewed_qs_title');
break; break;
default: default:
$linkparams=array(); $linkparams = array();
$sometitle=$countslugs ? qa_lang_html_sub('main/recent_qs_in_x', $categorytitlehtml) : qa_lang_html('main/recent_qs_title'); $sometitle = $countslugs ? qa_lang_html_sub('main/recent_qs_in_x', $categorytitlehtml) : qa_lang_html('main/recent_qs_title');
$categorypathprefix='questions/'; $categorypathprefix = 'questions/';
$feedpathprefix=qa_opt('feed_for_questions') ? 'questions' : null; $feedpathprefix = qa_opt('feed_for_questions') ? 'questions' : null;
break; break;
} }
// Prepare and return content for theme // Prepare and return content for theme
$qa_content=qa_q_list_page_content( $qa_content = qa_q_list_page_content(
$questions, // questions $questions, // questions
qa_opt('page_size_qs'), // questions per page qa_opt('page_size_qs'), // questions per page
$start, // start offset $start, // start offset
$countslugs ? $categories[$categoryid]['qcount'] : qa_opt('cache_qcount'), // total count $countslugs ? $categories[$categoryid]['qcount'] : qa_opt('cache_qcount'), // total count
$sometitle, // title if some questions $sometitle, // title if some questions
$nonetitle, // title if no questions $nonetitle, // title if no questions
$categories, // categories for navigation $categories, // categories for navigation
$categoryid, // selected category id $categoryid, // selected category id
true, // show question counts in category navigation true, // show question counts in category navigation
$categorypathprefix, // prefix for links in category navigation $categorypathprefix, // prefix for links in category navigation
$feedpathprefix, // prefix for RSS feed paths $feedpathprefix, // prefix for RSS feed paths
$countslugs ? qa_html_suggest_qs_tags(qa_using_tags()) : qa_html_suggest_ask($categoryid), // suggest what to do next $countslugs ? qa_html_suggest_qs_tags(qa_using_tags()) : qa_html_suggest_ask($categoryid), // suggest what to do next
$linkparams, // extra parameters for page links $linkparams, // extra parameters for page links
$linkparams // category nav params $linkparams // category nav params
); );
if (QA_ALLOW_UNINDEXED_QUERIES || !$countslugs) if (QA_ALLOW_UNINDEXED_QUERIES || !$countslugs) {
$qa_content['navigation']['sub']=qa_qs_sub_navigation($sort, $categoryslugs); $qa_content['navigation']['sub'] = qa_qs_sub_navigation($sort, $categoryslugs);
}
return $qa_content;
return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
...@@ -20,125 +20,120 @@ ...@@ -20,125 +20,120 @@
More about this license: http://www.question2answer.org/license.php 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 if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
header('Location: ../'); header('Location: ../');
exit; exit;
} }
require_once QA_INCLUDE_DIR.'db/selects.php'; require_once QA_INCLUDE_DIR . 'db/selects.php';
require_once QA_INCLUDE_DIR.'app/format.php'; require_once QA_INCLUDE_DIR . 'app/format.php';
require_once QA_INCLUDE_DIR.'app/q-list.php'; require_once QA_INCLUDE_DIR . 'app/q-list.php';
// Get list of unanswered questions, allow per-category if QA_ALLOW_UNINDEXED_QUERIES set in qa-config.php // Get list of unanswered questions, allow per-category if QA_ALLOW_UNINDEXED_QUERIES set in qa-config.php
if (QA_ALLOW_UNINDEXED_QUERIES) if (QA_ALLOW_UNINDEXED_QUERIES)
$categoryslugs=qa_request_parts(1); $categoryslugs = qa_request_parts(1);
else else
$categoryslugs=null; $categoryslugs = null;
$countslugs=@count($categoryslugs); $countslugs = @count($categoryslugs);
$by=qa_get('by'); $by = qa_get('by');
$start=qa_get_start(); $start = qa_get_start();
$userid=qa_get_logged_in_userid(); $userid = qa_get_logged_in_userid();
switch ($by) { switch ($by) {
case 'selected': case 'selected':
$selectby='selchildid'; $selectby = 'selchildid';
break; break;
case 'upvotes': case 'upvotes':
$selectby='amaxvote'; $selectby = 'amaxvote';
break; break;
default: default:
$selectby='acount'; $selectby = 'acount';
break; break;
} }
list($questions, $categories, $categoryid)=qa_db_select_with_pending( list($questions, $categories, $categoryid) = qa_db_select_with_pending(
qa_db_unanswered_qs_selectspec($userid, $selectby, $start, $categoryslugs, false, false, qa_opt_if_loaded('page_size_una_qs')), qa_db_unanswered_qs_selectspec($userid, $selectby, $start, $categoryslugs, false, false, qa_opt_if_loaded('page_size_una_qs')),
QA_ALLOW_UNINDEXED_QUERIES ? qa_db_category_nav_selectspec($categoryslugs, false, false, true) : null, QA_ALLOW_UNINDEXED_QUERIES ? qa_db_category_nav_selectspec($categoryslugs, false, false, true) : null,
$countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null $countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null
); );
if ($countslugs) { if ($countslugs) {
if (!isset($categoryid)) if (!isset($categoryid))
return include QA_INCLUDE_DIR.'qa-page-not-found.php'; return include QA_INCLUDE_DIR . 'qa-page-not-found.php';
$categorytitlehtml=qa_html($categories[$categoryid]['title']); $categorytitlehtml = qa_html($categories[$categoryid]['title']);
} }
$feedpathprefix=null; $feedpathprefix = null;
$linkparams=array('by' => $by); $linkparams = array('by' => $by);
switch ($by) { switch ($by) {
case 'selected': case 'selected':
if ($countslugs) { if ($countslugs) {
$sometitle=qa_lang_html_sub('main/unselected_qs_in_x', $categorytitlehtml); $sometitle = qa_lang_html_sub('main/unselected_qs_in_x', $categorytitlehtml);
$nonetitle=qa_lang_html_sub('main/no_una_questions_in_x', $categorytitlehtml); $nonetitle = qa_lang_html_sub('main/no_una_questions_in_x', $categorytitlehtml);
} else { } else {
$sometitle=qa_lang_html('main/unselected_qs_title'); $sometitle = qa_lang_html('main/unselected_qs_title');
$nonetitle=qa_lang_html('main/no_unselected_qs_found'); $nonetitle = qa_lang_html('main/no_unselected_qs_found');
$count=qa_opt('cache_unselqcount'); $count = qa_opt('cache_unselqcount');
} }
break; break;
case 'upvotes': case 'upvotes':
if ($countslugs) { if ($countslugs) {
$sometitle=qa_lang_html_sub('main/unupvoteda_qs_in_x', $categorytitlehtml); $sometitle = qa_lang_html_sub('main/unupvoteda_qs_in_x', $categorytitlehtml);
$nonetitle=qa_lang_html_sub('main/no_una_questions_in_x', $categorytitlehtml); $nonetitle = qa_lang_html_sub('main/no_una_questions_in_x', $categorytitlehtml);
} else { } else {
$sometitle=qa_lang_html('main/unupvoteda_qs_title'); $sometitle = qa_lang_html('main/unupvoteda_qs_title');
$nonetitle=qa_lang_html('main/no_unupvoteda_qs_found'); $nonetitle = qa_lang_html('main/no_unupvoteda_qs_found');
$count=qa_opt('cache_unupaqcount'); $count = qa_opt('cache_unupaqcount');
} }
break; break;
default: default:
$feedpathprefix=qa_opt('feed_for_unanswered') ? 'unanswered' : null; $feedpathprefix = qa_opt('feed_for_unanswered') ? 'unanswered' : null;
$linkparams=array(); $linkparams = array();
if ($countslugs) { if ($countslugs) {
$sometitle=qa_lang_html_sub('main/unanswered_qs_in_x', $categorytitlehtml); $sometitle = qa_lang_html_sub('main/unanswered_qs_in_x', $categorytitlehtml);
$nonetitle=qa_lang_html_sub('main/no_una_questions_in_x', $categorytitlehtml); $nonetitle = qa_lang_html_sub('main/no_una_questions_in_x', $categorytitlehtml);
} else { } else {
$sometitle=qa_lang_html('main/unanswered_qs_title'); $sometitle = qa_lang_html('main/unanswered_qs_title');
$nonetitle=qa_lang_html('main/no_una_questions_found'); $nonetitle = qa_lang_html('main/no_una_questions_found');
$count=qa_opt('cache_unaqcount'); $count = qa_opt('cache_unaqcount');
} }
break; break;
} }
// Prepare and return content for theme // Prepare and return content for theme
$qa_content=qa_q_list_page_content( $qa_content = qa_q_list_page_content(
$questions, // questions $questions, // questions
qa_opt('page_size_una_qs'), // questions per page qa_opt('page_size_una_qs'), // questions per page
$start, // start offset $start, // start offset
@$count, // total count @$count, // total count
$sometitle, // title if some questions $sometitle, // title if some questions
$nonetitle, // title if no questions $nonetitle, // title if no questions
QA_ALLOW_UNINDEXED_QUERIES ? $categories : null, // categories for navigation (null if not shown on this page) QA_ALLOW_UNINDEXED_QUERIES ? $categories : null, // categories for navigation (null if not shown on this page)
QA_ALLOW_UNINDEXED_QUERIES ? $categoryid : null, // selected category id (null if not relevant) QA_ALLOW_UNINDEXED_QUERIES ? $categoryid : null, // selected category id (null if not relevant)
false, // show question counts in category navigation false, // show question counts in category navigation
QA_ALLOW_UNINDEXED_QUERIES ? 'unanswered/' : null, // prefix for links in category navigation (null if no navigation) QA_ALLOW_UNINDEXED_QUERIES ? 'unanswered/' : null, // prefix for links in category navigation (null if no navigation)
$feedpathprefix, // prefix for RSS feed paths (null to hide) $feedpathprefix, // prefix for RSS feed paths (null to hide)
qa_html_suggest_qs_tags(qa_using_tags()), // suggest what to do next qa_html_suggest_qs_tags(qa_using_tags()), // suggest what to do next
$linkparams, // extra parameters for page links $linkparams, // extra parameters for page links
$linkparams // category nav params $linkparams // category nav params
); );
$qa_content['navigation']['sub']=qa_unanswered_sub_navigation($by, $categoryslugs); $qa_content['navigation']['sub'] = qa_unanswered_sub_navigation($by, $categoryslugs);
return $qa_content; return $qa_content;
/*
Omit PHP closing tag to help avoid accidental output
*/
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment