Browse Source

Closes #277 Add visual indicator for stickied KB articles

merge-requests/2/head
Mike Koch 7 years ago
parent
commit
41fe2bc6f5
  1. 24
      inc/knowledgebase_functions.inc.php
  2. 31
      knowledgebase.php

24
inc/knowledgebase_functions.inc.php

@ -99,7 +99,7 @@ function hesk_kbTopArticles($how_many, $index = 1)
<tr>
<?php
/* Get list of articles from the database */
$res = hesk_dbQuery("SELECT `t1`.`id`,`t1`.`subject`,`t1`.`views` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` AS `t1`
$res = hesk_dbQuery("SELECT `t1`.`id`,`t1`.`subject`,`t1`.`views`,`t1`.`sticky` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` AS `t1`
LEFT JOIN `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` AS `t2` ON `t1`.`catid` = `t2`.`id`
WHERE `t1`.`type`='0' AND `t2`.`type`='0'
ORDER BY `t1`.`sticky` DESC, `t1`.`views` DESC, `t1`.`art_order` ASC LIMIT ".intval($how_many));
@ -116,7 +116,7 @@ function hesk_kbTopArticles($how_many, $index = 1)
<tbody>
<?php
/* Get list of articles from the database */
$res = hesk_dbQuery("SELECT `t1`.`id`,`t1`.`subject`,`t1`.`dt`, `t1`.`views` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` AS `t1`
$res = hesk_dbQuery("SELECT `t1`.`id`,`t1`.`subject`,`t1`.`dt`, `t1`.`views`,`t1`.`sticky` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` AS `t1`
LEFT JOIN `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_categories` AS `t2` ON `t1`.`catid` = `t2`.`id`
WHERE `t1`.`type`='0' AND `t2`.`type`='0'
ORDER BY `t1`.`sticky` DESC, `t1`.`views` DESC, `t1`.`art_order` ASC LIMIT ".intval($how_many));
@ -138,10 +138,18 @@ function hesk_kbTopArticles($how_many, $index = 1)
}
while ($article = hesk_dbFetchAssoc($res))
{
$icon = 'fa fa-file';
$style = '';
if ($article['sticky']) {
$icon = 'glyphicon glyphicon-pushpin';
$style = 'style="color: #FF0000"';
}
echo '
<tr>
<td class="col-xs-8 col-sm-9" '.$colspan.'>
<i class="fa fa-file"></i> <a href="knowledgebase.php?article='.$article['id'].'">'.$article['subject'].'</a>
<i class="'.$icon.'" '.$style.'></i> <a href="knowledgebase.php?article='.$article['id'].'">'.$article['subject'].'</a>
</td>
';
if ($hesk_settings['kb_views']) {
@ -246,10 +254,18 @@ function hesk_kbLatestArticles($how_many, $index = 1)
$colspan = $hesk_settings['kb_date'] ? '' : 'colspan="2"';
while ($article = hesk_dbFetchAssoc($res))
{
$icon = 'fa fa-file';
$style = '';
if ($article['sticky']) {
$icon = 'glyphicon glyphicon-pushpin';
$style = 'style="color: #FF0000"';
}
echo '
<tr>
<td class="col-xs-9" '.$colspan.'>
<i class="fa fa-file"></i> <a href="knowledgebase.php?article='.$article['id'].'">'.$article['subject'].'</a>
<i class="'.$icon.'" '.$style.'></i> <a href="knowledgebase.php?article='.$article['id'].'">'.$article['subject'].'</a>
</td>';
if ($hesk_settings['kb_date']) {
echo '<td class="col-xs-3">' . hesk_date($article['dt'], true) . '</td>';

31
knowledgebase.php

@ -486,15 +486,22 @@ function hesk_show_kb_category($catid, $is_search = 0) {
/* Print most popular/sticky articles */
if ($hesk_settings['kb_numshow'] && $cat['articles'])
{
$res = hesk_dbQuery("SELECT `id`,`subject` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` WHERE `catid`='{$cat['id']}' AND `type`='0' ORDER BY `sticky` DESC, `views` DESC, `art_order` ASC LIMIT " . (intval($hesk_settings['kb_numshow']) + 1) );
$res = hesk_dbQuery("SELECT `id`,`subject`, `sticky` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` WHERE `catid`='{$cat['id']}' AND `type`='0' ORDER BY `sticky` DESC, `views` DESC, `art_order` ASC LIMIT " . (intval($hesk_settings['kb_numshow']) + 1) );
$num = 1;
while ($art = hesk_dbFetchAssoc($res))
{
$icon = 'glyphicon glyphicon-file';
$style = '';
if ($art['sticky'])
{
$icon = 'glyphicon glyphicon-pushpin';
$style = 'style="color: #FF0000"';
}
echo '
<tr>
<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="glyphicon glyphicon-file"></span>
<a href="knowledgebase.php?article='.$art['id'].'" class="article">'.$art['subject'].'</a></td>
</tr>';
<tr>
<td '.$style.'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="'.$icon.'"></span>
<a href="knowledgebase.php?article='.$art['id'].'" class="article">'.$art['subject'].'</a></td>
</tr>';
if ($num == $hesk_settings['kb_numshow'])
{
@ -553,7 +560,7 @@ function hesk_show_kb_category($catid, $is_search = 0) {
<table class="table table-striped">
<tbody>
<?php
$res = hesk_dbQuery("SELECT `id`, `subject`, LEFT(`content`, ".max(200, $hesk_settings['kb_substrart'] * 2).") AS `content`, `rating` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` WHERE `catid`='{$catid}' AND `type`='0' ORDER BY `sticky` DESC, `art_order` ASC");
$res = hesk_dbQuery("SELECT `id`, `subject`, `sticky`, LEFT(`content`, ".max(200, $hesk_settings['kb_substrart'] * 2).") AS `content`, `rating` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."kb_articles` WHERE `catid`='{$catid}' AND `type`='0' ORDER BY `sticky` DESC, `art_order` ASC");
if (hesk_dbNumRows($res) == 0)
{
echo '<tr><td><i>'.$hesklang['noac'].'</i></td></tr>';
@ -562,8 +569,18 @@ function hesk_show_kb_category($catid, $is_search = 0) {
{
while ($article = hesk_dbFetchAssoc($res))
{
$icon = 'fa fa-file';
$color = '';
$style = '';
$txt = hesk_kbArticleContentPreview($article['content']);
if ($article['sticky'])
{
$icon = 'glyphicon glyphicon-pushpin';
$style = 'style="color: #FF0000"';
}
if ($hesk_settings['kb_rating'])
{
$alt = $article['rating'] ? sprintf($hesklang['kb_rated'], sprintf("%01.1f", $article['rating'])) : $hesklang['kb_not_rated'];
@ -577,7 +594,7 @@ function hesk_show_kb_category($catid, $is_search = 0) {
echo '
<tr>
<td>
<i class="fa fa-file"></i>
<i class="'.$icon.'" '.$style.'></i>
<a href="knowledgebase.php?article='.$article['id'].'">'.$article['subject'].'</a>
<br>
<span class="indent-15">'.$txt.'</span>

Loading…
Cancel
Save