Newer
Older
<?php
if(!defined('OSTSTAFFINC') || !$thisstaff) die('Access Denied');
?>
<h2><?php echo __('Frequently Asked Questions');?></h2>
<form id="kbSearch" action="kb.php" method="get">
<input id="query" type="search" size="20" name="q" autofocus
value="<?php echo Format::htmlchars($_REQUEST['q']); ?>">
<select name="cid" id="cid">
<option value="">— <?php echo __('All Categories');?> —</option>
$categories = Category::objects()
->annotate(array('faq_count'=>SqlAggregate::COUNT('faqs')))
->filter(array('faq_count__gt'=>0))
->order_by('name');
print $categories;
foreach ($categories as $C) {
echo sprintf('<option value="%d" %s>%s (%d)</option>',
$C->getId(),
($_REQUEST['cid'] && $C->getId()==$_REQUEST['cid']?'selected="selected"':''),
$C->getLocalName(),
$C->faq_count
);
} ?>
<input id="searchSubmit" type="submit" value="<?php echo __('Search');?>">
</div>
<div>
<select name="topicId" style="width:350px;" id="topic-id">
<option value="">— <?php echo __('All Help Topics');?> —</option>
->annotate(array('faq_count'=>SqlAggregate::COUNT('faqs')))
->filter(array('faq_count__gt'=>0))
->all();
usort($topics, function($a, $b) {
return strcmp($a->getFullName(), $b->getFullName());
});
foreach ($topics as $T) {
echo sprintf('<option value="%d" %s>%s (%d)</option>',
$T->getId(),
($_REQUEST['topicId'] && $T->getId()==$_REQUEST['topicId']?'selected="selected"':''),
$T->getFullName(), $T->faq_count);
}
?>
</select>
</div>
</form>
<hr>
<div>
<?php
if($_REQUEST['q'] || $_REQUEST['cid'] || $_REQUEST['topicId']) { //Search.
$faqs = FAQ::objects()
->annotate(array(
'attachment_count'=>SqlAggregate::COUNT('attachments'),
'topic_count'=>SqlAggregate::COUNT('topics')
if ($_REQUEST['cid'])
$faqs->filter(array('category_id'=>$_REQUEST['cid']));
$faqs->filter(array('topics__topic_id'=>$_REQUEST['topicId']));
if ($_REQUEST['q'])
$faqs->filter(Q::ANY(array(
'question__contains'=>$_REQUEST['q'],
'answer__contains'=>$_REQUEST['q'],
'keywords__contains'=>$_REQUEST['q'],
'category__name__contains'=>$_REQUEST['q'],
'category__description__contains'=>$_REQUEST['q'],
)));
echo "<div><strong>".__('Search Results')."</strong></div><div class='clear'></div>";
foreach ($faqs as $F) {
echo sprintf(
'<li><a href="faq.php?id=%d" class="previewfaq">%s</a> - <span>%s</span></li>',
$F->getId(), $F->getLocalQuestion(), $F->getVisibilityDescription());
echo '<strong class="faded">'.__('The search did not match any FAQs.').'</strong>';
$categories = Category::objects()
->annotate(array('faq_count'=>SqlAggregate::COUNT('faqs')))
->all();
if (count($categories)) {
usort($categories, function($a, $b) {
return strcmp($a->getLocalName(), $b->getLocalName());
});
echo '<div>'.__('Click on the category to browse FAQs or manage its existing FAQs.').'</div>
<h4><a class="truncate" style="max-width:600px" href="kb.php?cid=%d">%s (%d)</a> - <span>%s</span></h4>
</li>',$C->getId(),$C->getLocalName(),$C->faq_count,
$C->getVisibilityDescription(),
Format::safe_html($C->getLocalDescriptionWithImages())
);