qa-page-unanswered.php 4.63 KB
Newer Older
Gideon Greenspan committed
1 2 3 4 5 6 7
<?php

/*
	Question2Answer (c) Gideon Greenspan

	http://www.question2answer.org/

Scott Vivian committed
8

Gideon Greenspan committed
9 10
	File: qa-include/qa-page-unanswered.php
	Version: See define()s at top of qa-include/qa-base.php
Gideon Greenspan committed
11
	Description: Controller for page listing recent questions without upvoted/selected/any answers
Gideon Greenspan committed
12 13 14 15 16 17


	This program is free software; you can redistribute it and/or
	modify it under the terms of the GNU General Public License
	as published by the Free Software Foundation; either version 2
	of the License, or (at your option) any later version.
Scott Vivian committed
18

Gideon Greenspan committed
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
	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
*/

	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';
Scott Vivian committed
35

Gideon Greenspan committed
36 37 38 39 40 41 42 43 44 45 46 47

//	Get list of unanswered questions, allow per-category if QA_ALLOW_UNINDEXED_QUERIES set in qa-config.php

	if (QA_ALLOW_UNINDEXED_QUERIES)
		$categoryslugs=qa_request_parts(1);
	else
		$categoryslugs=null;

	$countslugs=@count($categoryslugs);
	$by=qa_get('by');
	$start=qa_get_start();
	$userid=qa_get_logged_in_userid();
Scott Vivian committed
48

Gideon Greenspan committed
49 50 51 52
	switch ($by) {
		case 'selected':
			$selectby='selchildid';
			break;
Scott Vivian committed
53

Gideon Greenspan committed
54 55 56
		case 'upvotes':
			$selectby='amaxvote';
			break;
Scott Vivian committed
57

Gideon Greenspan committed
58 59 60 61
		default:
			$selectby='acount';
			break;
	}
Scott Vivian committed
62

Gideon Greenspan committed
63
	list($questions, $categories, $categoryid)=qa_db_select_with_pending(
Gideon Greenspan committed
64 65 66 67
		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,
		$countslugs ? qa_db_slugs_to_category_id_selectspec($categoryslugs) : null
	);
Scott Vivian committed
68

Gideon Greenspan committed
69 70 71
	if ($countslugs) {
		if (!isset($categoryid))
			return include QA_INCLUDE_DIR.'qa-page-not-found.php';
Scott Vivian committed
72

Gideon Greenspan committed
73 74
		$categorytitlehtml=qa_html($categories[$categoryid]['title']);
	}
Scott Vivian committed
75

Gideon Greenspan committed
76 77
	$feedpathprefix=null;
	$linkparams=array('by' => $by);
Scott Vivian committed
78

Gideon Greenspan committed
79 80 81 82 83
	switch ($by) {
		case 'selected':
			if ($countslugs) {
				$sometitle=qa_lang_html_sub('main/unselected_qs_in_x', $categorytitlehtml);
				$nonetitle=qa_lang_html_sub('main/no_una_questions_in_x', $categorytitlehtml);
Scott Vivian committed
84

Gideon Greenspan committed
85 86 87 88 89 90
			} else {
				$sometitle=qa_lang_html('main/unselected_qs_title');
				$nonetitle=qa_lang_html('main/no_unselected_qs_found');
				$count=qa_opt('cache_unselqcount');
			}
			break;
Scott Vivian committed
91

Gideon Greenspan committed
92 93 94 95
		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);
Scott Vivian committed
96

Gideon Greenspan committed
97 98 99 100 101 102
			} else {
				$sometitle=qa_lang_html('main/unupvoteda_qs_title');
				$nonetitle=qa_lang_html('main/no_unupvoteda_qs_found');
				$count=qa_opt('cache_unupaqcount');
			}
			break;
Scott Vivian committed
103

Gideon Greenspan committed
104 105 106 107 108 109 110
		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);
Scott Vivian committed
111

Gideon Greenspan committed
112 113 114 115 116 117 118
			} else {
				$sometitle=qa_lang_html('main/unanswered_qs_title');
				$nonetitle=qa_lang_html('main/no_una_questions_found');
				$count=qa_opt('cache_unaqcount');
			}
			break;
	}
Scott Vivian committed
119 120


Gideon Greenspan committed
121 122 123 124 125 126 127 128 129
//	Prepare and return content for theme

	$qa_content=qa_q_list_page_content(
		$questions, // questions
		qa_opt('page_size_una_qs'), // questions per page
		$start, // start offset
		@$count, // total count
		$sometitle, // title if some questions
		$nonetitle, // title if no questions
Gideon Greenspan committed
130 131 132 133
		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)
		false, // show question counts in category navigation
		QA_ALLOW_UNINDEXED_QUERIES ? 'unanswered/' : null, // prefix for links in category navigation (null if no navigation)
Gideon Greenspan committed
134 135 136 137 138
		$feedpathprefix, // prefix for RSS feed paths (null to hide)
		qa_html_suggest_qs_tags(qa_using_tags()), // suggest what to do next
		$linkparams, // extra parameters for page links
		$linkparams // category nav params
	);
Scott Vivian committed
139

Gideon Greenspan committed
140
	$qa_content['navigation']['sub']=qa_unanswered_sub_navigation($by, $categoryslugs);
Scott Vivian committed
141 142


Gideon Greenspan committed
143 144 145 146 147 148
	return $qa_content;


/*
	Omit PHP closing tag to help avoid accidental output
*/