Skip to content
Snippets Groups Projects
Commit fd5bdb66 authored by Jared Hancock's avatar Jared Hancock
Browse files

faq: Revise category listing / search page

parent 4af81806
Branches
Tags
No related merge requests found
...@@ -171,7 +171,7 @@ class Draft extends VerySimpleModel { ...@@ -171,7 +171,7 @@ class Draft extends VerySimpleModel {
*/ */
static function deleteForNamespace($namespace, $staff_id=false) { static function deleteForNamespace($namespace, $staff_id=false) {
$attachments = Attachment::objects() $attachments = Attachment::objects()
->filter(array('draft__namespace__like' => $namespace)); ->filter(array('draft__namespace__startswith' => $namespace));
if ($staff_id) if ($staff_id)
$attachments->filter(array('draft__staff_id' => $staff_id)); $attachments->filter(array('draft__staff_id' => $staff_id));
......
...@@ -110,7 +110,7 @@ implements TemplateVariable { ...@@ -110,7 +110,7 @@ implements TemplateVariable {
} }
function getFullName() { function getFullName() {
return self::getTopicName($this->getId()); return self::getTopicName($this->getId()) ?: $this->topic;
} }
static function getTopicName($id) { static function getTopicName($id) {
......
...@@ -2,51 +2,98 @@ ...@@ -2,51 +2,98 @@
if(!defined('OSTSTAFFINC') || !$thisstaff) die('Access Denied'); if(!defined('OSTSTAFFINC') || !$thisstaff) die('Access Denied');
?> ?>
<h2><?php echo __('Frequently Asked Questions');?></h2>
<form id="kbSearch" action="kb.php" method="get"> <form id="kbSearch" action="kb.php" method="get">
<input type="hidden" name="a" value="search"> <input type="hidden" name="a" value="search">
<div> <input type="hidden" name="cid" value="<?php echo Format::htmlchars($_REQUEST['cid']); ?>"/>
<input id="query" type="search" size="20" name="q" autofocus <input type="hidden" name="topicId" value="<?php echo Format::htmlchars($_REQUEST['topicId']); ?>"/>
value="<?php echo Format::htmlchars($_REQUEST['q']); ?>">
<select name="cid" id="cid"> <div id="basic_search">
<option value="">&mdash; <?php echo __('All Categories');?> &mdash;</option> <div class="attached input">
<?php <input id="query" type="text" size="20" name="q" autofocus
$categories = Category::objects() value="<?php echo Format::htmlchars($_REQUEST['q']); ?>">
->annotate(array('faq_count'=>SqlAggregate::COUNT('faqs'))) <button class="attached button" id="searchSubmit" type="submit">
->filter(array('faq_count__gt'=>0)) <i class="icon icon-search"></i>
->order_by('name'); </button>
foreach ($categories as $C) { </div>
echo sprintf('<option value="%d" %s>%s (%d)</option>',
$C->getId(), <div class="pull-right">
($_REQUEST['cid'] && $C->getId()==$_REQUEST['cid']?'selected="selected"':''), <span class="action-button muted" data-dropdown="#category-dropdown">
$C->getLocalName(), <i class="icon-caret-down pull-right"></i>
$C->faq_count <span>
); <i class="icon icon-filter"></i>
} ?> <?php echo __('Category'); ?>
</select> </span>
<input id="searchSubmit" type="submit" value="<?php echo __('Search');?>"> </span>
</div> <span class="action-button muted" data-dropdown="#topic-dropdown">
<div> <i class="icon-caret-down pull-right"></i>
<select name="topicId" style="width:350px;" id="topic-id"> <span>
<option value="">&mdash; <?php echo __('All Help Topics');?> &mdash;</option> <i class="icon icon-filter"></i>
<?php <?php echo __('Help Topic'); ?>
$topics = Topic::objects() </span>
->annotate(array('faq_count'=>SqlAggregate::COUNT('faqs'))) </span>
->filter(array('faq_count__gt'=>0)) </div>
->all();
usort($topics, function($a, $b) { <div id="category-dropdown" class="action-dropdown anchor-right"
return strcmp($a->getFullName(), $b->getFullName()); onclick="javascript:
}); var form = $(this).closest('form');
foreach ($topics as $T) { form.find('[name=cid]').val($(event.target).data('cid'));
echo sprintf('<option value="%d" %s>%s (%d)</option>', form.submit();">
$T->getId(), <ul class="bleed-left">
($_REQUEST['topicId'] && $T->getId()==$_REQUEST['topicId']?'selected="selected"':''), <?php
$T->getFullName(), $T->faq_count); $total = FAQ::objects()->count();
}
?> $categories = Category::objects()
</select> ->annotate(array('faq_count' => SqlAggregate::COUNT('faqs')))
->filter(array('faq_count__gt' => 0))
->order_by('name')
->all();
array_unshift($categories, new Category(array('id' => 0, 'name' => __('All Categories'), 'faq_count' => $total)));
foreach ($categories as $C) {
$active = $_REQUEST['cid'] == $C->getId(); ?>
<li <?php if ($active) echo 'class="active"'; ?>>
<a href="#" data-cid="<?php echo $C->getId(); ?>">
<i class="icon-fixed-width <?php
if ($active) echo 'icon-hand-right'; ?>"></i>
<?php echo sprintf('%s (%d)',
Format::htmlchars($C->getLocalName()),
$C->faq_count); ?></a>
</li> <?php
} ?>
</ul>
</div>
<div id="topic-dropdown" class="action-dropdown anchor-right"
onclick="javascript:
var form = $(this).closest('form');
form.find('[name=topicId]').val($(event.target).data('topicId'));
form.submit();">
<ul class="bleed-left">
<?php
$topics = Topic::objects()
->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());
});
array_unshift($topics, new Topic(array('id' => 0, 'topic' => __('All Topics'), 'faq_count' => $total)));
foreach ($topics as $T) {
$active = $_REQUEST['topicId'] == $T->getId(); ?>
<li <?php if ($active) echo 'class="active"'; ?>>
<a href="#" data-topic-id="<?php echo $T->getId(); ?>">
<i class="icon-fixed-width <?php
if ($active) echo 'icon-hand-right'; ?>"></i>
<?php echo sprintf('%s (%d)',
Format::htmlchars($T->getFullName()),
$T->faq_count); ?></a>
</li> <?php
} ?>
</ul>
</div>
</div> </div>
</form> </form>
<h2><?php echo __('Frequently Asked Questions');?></h2>
<hr> <hr>
<div> <div>
<?php <?php
......
...@@ -917,7 +917,9 @@ $tcount = $ticket->getThreadEntries($types)->count(); ...@@ -917,7 +917,9 @@ $tcount = $ticket->getThreadEntries($types)->count();
<input type="hidden" name="id" value="<?php echo $ticket->getId(); ?>"> <input type="hidden" name="id" value="<?php echo $ticket->getId(); ?>">
<fieldset class="notes"> <fieldset class="notes">
<label class="fixed-size" for="notes"><?php echo __('Print Notes');?>:</label> <label class="fixed-size" for="notes"><?php echo __('Print Notes');?>:</label>
<label class="inline checkbox">
<input type="checkbox" id="notes" name="notes" value="1"> <?php echo __('Print <b>Internal</b> Notes/Comments');?> <input type="checkbox" id="notes" name="notes" value="1"> <?php echo __('Print <b>Internal</b> Notes/Comments');?>
</label>
</fieldset> </fieldset>
<fieldset> <fieldset>
<label class="fixed-size" for="psize"><?php echo __('Paper Size');?>:</label> <label class="fixed-size" for="psize"><?php echo __('Paper Size');?>:</label>
......
...@@ -1467,48 +1467,13 @@ h2 > i.help-tip { ...@@ -1467,48 +1467,13 @@ h2 > i.help-tip {
} }
#kbSearch { #kbSearch {
padding:10px 0; margin-bottom: 1em;
overflow:hidden;
}
#kbSearch div {
clear:both;
overflow:hidden;
padding:5px 0 2px 3px;
} }
#kbSearch #query { #kbSearch #query {
margin:1px 5px 0 0;
display:inline-block;
float:left;
width:200px; width:200px;
} }
#kbSearch #cid {
margin:0;
display:inline-block;
float:left;
width:200px;
margin-right:5px;
position:relative;
top:2px;
}
#kbSearch #topic-id {
margin:0;
display:inline-block;
float:left;
width:410px;
}
#kbSearch #searchSubmit {
margin:0;
display:inline-block;
float:left;
position:relative;
top:2px;
}
#faq { #faq {
clear: both; clear: both;
margin: 0; margin: 0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment