Commit 046d33db by Scott

Move ask page similar questions into theme

Plus new function q_title_list for generic list of question titles.
parent d89d75ba
......@@ -26,6 +26,8 @@
require_once QA_INCLUDE_DIR.'qa-db-selects.php';
require_once QA_INCLUDE_DIR.'qa-util-string.php';
require_once QA_INCLUDE_DIR.'qa-app-users.php';
require_once QA_INCLUDE_DIR.'qa-app-format.php';
// Collect the information we need from the database
......@@ -46,8 +48,6 @@
// 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']);
......@@ -85,27 +85,21 @@
// Collect and output the list of related questions
if ($doaskcheck) {
require_once QA_INCLUDE_DIR.'qa-app-format.php';
$minscore = qa_match_to_min_score(qa_opt('match_ask_check_qs'));
$maxcount = qa_opt('page_size_ask_check_qs');
$count=0;
$minscore=qa_match_to_min_score(qa_opt('match_ask_check_qs'));
$maxcount=qa_opt('page_size_ask_check_qs');
$relatedquestions = array_slice($relatedquestions, 0, $maxcount);
$limitedquestions = array();
foreach ($relatedquestions as $question) {
if ($question['score']<$minscore)
if ($question['score'] < $minscore)
break;
if (!$count)
echo qa_lang_html('question/ask_same_q').'<br/>';
echo strtr(
'<a href="'.qa_q_path_html($question['postid'], $question['title']).'" target="_blank">'.qa_html($question['title']).'</a><br/>',
"\r\n", ' '
)."\n";
if ((++$count)>=$maxcount)
break;
$limitedquestions[] = $question;
}
$themeclass = qa_load_theme_class(qa_get_site_theme(), 'ajax-asktitle', null, null);
$themeclass->q_ask_similar($limitedquestions, qa_lang_html('question/ask_same_q'));
}
......
......@@ -2209,6 +2209,39 @@
);
}
function q_title_list($q_list, $attrs=null)
/*
Generic function to output a basic list of question links.
*/
{
$this->output('<ul class="qa-q-title-list">');
foreach ($q_list as $q) {
$this->output(
'<li class="qa-q-title-item">',
'<a href="' . qa_q_path_html($q['postid'], $q['title']) . '" ' . $attrs . '>' . qa_html($q['title']) . '</a>',
'</li>'
);
}
$this->output('</ul>');
}
function q_ask_similar($q_list, $pretext='')
/*
Output block of similar questions when asking.
*/
{
if (!count($q_list))
return;
$this->output('<div class="qa-ask-similar">');
if (strlen($pretext) > 0)
$this->output('<p>'.$pretext.'</p>');
$this->q_title_list($q_list, 'target="_blank"');
$this->output('</div>');
}
}
......
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