[Phpbbkb-checkins] SF.net SVN: phpbbkb: [19] root
Status: Alpha
Brought to you by:
markthedaemon
|
From: <so...@us...> - 2006-11-21 19:57:08
|
Revision: 19
http://svn.sourceforge.net/phpbbkb/?rev=19&view=rev
Author: softphp
Date: 2006-11-21 11:57:07 -0800 (Tue, 21 Nov 2006)
Log Message:
-----------
- Added possibility for viewing cats, updated the articles table and added a new template file.
Modified Paths:
--------------
root/kb.php
root/kb_install.php
root/language/lang_english/lang_kb.php
root/templates/subSilver/kb_main.tpl
Added Paths:
-----------
root/templates/subSilver/kb_viewcat.tpl
Modified: root/kb.php
===================================================================
--- root/kb.php 2006-11-21 15:00:56 UTC (rev 18)
+++ root/kb.php 2006-11-21 19:57:07 UTC (rev 19)
@@ -145,6 +145,173 @@
break;
case "view_cat":
+ $cat_id = ( isset( $HTTP_GET_VARS['id'] ) ) ? $HTTP_GET_VARS['id'] : false;
+ if(!$cat_id)
+ {
+ message_die(GENERAL_MESSAGE, "The chosen category doesn't exist.");
+ }
+
+ // Store the main cat in a variable
+ $sql = "SELECT *
+ FROM " . KB_CATEGORIES_TABLE . "
+ WHERE cat_id = '" . $cat_id . "'";
+ if( !($result = $db->sql_query($sql)) )
+ {
+ message_die(GENERAL_ERROR, 'Could not query the main category', '', __LINE__, __FILE__, $sql);
+ }
+ $cat = $db->sql_fetchrow($result);
+
+ // Let's find subcats
+ $sql = "SELECT c.cat_id, c.cat_main, c.cat_title, c.cat_desc, c.cat_articles, c.cat_order
+ FROM " . KB_CATEGORIES_TABLE . " c
+ WHERE c.cat_main = '$cat_id'
+ ORDER BY c.cat_order";
+ if( !($result = $db->sql_query($sql)) )
+ {
+ message_die(GENERAL_ERROR, 'Could not query subcategories list', '', __LINE__, __FILE__, $sql);
+ }
+
+ $subcats = array();
+ while($row = $db->sql_fetchrow($result))
+ {
+ $subcats[] = $row;
+ }
+
+ // Now articles, the LIKE handles multiple cats
+ // First handle the sorting
+ // default is by edit time, other options: -rating, -author, -title
+ if(isset($HTTP_GET_VARS['sort']))
+ {
+ switch($HTTP_GET_VARS['sort'])
+ {
+ case "rating":
+ // Later
+ $sort = "ORDER BY article_edittime DESC";
+ break;
+
+ case "author":
+ // Later
+ $sort = "ORDER BY article_edittime DESC";
+ break;
+
+ case "title":
+ $sort = "ORDER BY article_title";
+ break;
+
+ case "time":
+ default:
+ $sort = "ORDER BY article_edittime DESC";
+ break;
+ }
+ }
+ else
+ {
+ $sort = "ORDER BY article_edittime DESC";
+ }
+
+ $sql = "SELECT *
+ FROM " . KB_ARTICLES_TABLE . "
+ WHERE cat_id LIKE '$cat_id'
+ $sort";
+ if( !($result = $db->sql_query($sql)) )
+ {
+ message_die(GENERAL_ERROR, 'Could not query articles list', '', __LINE__, __FILE__, $sql);
+ }
+
+ $articles = array();
+ while($row = $db->sql_fetchrow($result))
+ {
+ $articles[] = $row;
+ }
+
+ // Start Page output
+ $page_title = $lang['kb_viewcat'] . ": " . $cat['cat_title'];
+ include($phpbb_root_path . 'includes/page_header.'.$phpEx);
+
+ $template->set_filenames(array(
+ 'body' => 'kb_viewcat.tpl')
+ );
+
+ // Process the whole thing
+ $template->assign_vars(array(
+ 'L_VIEWS' => $lang['Views'],
+ 'L_AUTHOR' => $lang['Author'],
+ 'L_ARTICLES' => $lang['kb_articles'],
+ 'L_SUBCATS' => sprintf($lang['kb_viewcat_subcats'], $cat['cat_title']),
+ 'L_LAST_ACTION' => $lang['kb_last_action'])
+ );
+
+ if( $total_subcats = count($subcats) )
+ {
+ $template->assign_block_vars('switch_subcats', array());
+
+ // Ok it contains subcats, let's build them.
+ for($i = 0; $i < $total_subcats; $i++)
+ {
+ // Ok display one cat here
+ $template->assign_block_vars('switch_subcats.catrow', array(
+ 'CAT_TITLE' => $subcats[$i]['cat_title'],
+ 'CAT_DESC' => $subcats[$i]['cat_desc'],
+ 'CAT_ARTICLES' => $subcats[$i]['cat_articles'],
+ 'U_VIEWCAT' => append_sid("kb.$phpEx?pid=view_cat&id=" . $subcats[$i]['cat_id']),
+ 'FORUM_FOLDER_IMG' => $images['forum']) // Stolen :D
+ );
+ }
+ }
+
+ if( $total_articles = count($articles) )
+ {
+ // Contains articles
+ for($i = 0; $i < $total_articles; $i++)
+ {
+ if($articles[$i]['article_authorname'] == "")
+ {
+ $sql = "SELECT username
+ FROM " . USERS_TABLE . "
+ WHERE user_id = '" . $articles[$i]['article_author'];
+ if( !($result = $db->sql_query($sql)) )
+ {
+ message_die(GENERAL_ERROR, 'Could not query authorname', '', __LINE__, __FILE__, $sql);
+ }
+
+ $user = $db->sql_fetchrow($result);
+ $authorname = $user['username'];
+ }
+ else
+ {
+ $authorname = $articles[$i]['article_authorname'];
+ }
+ $author = "<a href=\"profile.php?mode=viewprofile&u=" . $articles[$i]['article_author'] . "\">$authorname</a>";
+
+ $sql = "SELECT username
+ FROM " . USERS_TABLE . "
+ WHERE user_id = '" . $articles[$i]['article_editby'];
+ if( !($result = $db->sql_query($sql)) )
+ {
+ message_die(GENERAL_ERROR, 'Could not query last edited by\'s username.', '', __LINE__, __FILE__, $sql);
+ }
+
+ $user = $db->sql_fetchrow($result);
+ $last_action = sprintf($lang['kb_last_action_row'], "<a href=\"profile.php?mode=viewprofile&u=" . $articles[$i]['article_editby'] . "\">" . $user['username'] . "</a>", create_date($board_config['default_dateformat'], $articles[$i]['article_edittime'], $board_config['board_timezone']));
+
+ $template->assign_block_vars('articlerow', array(
+ 'TOPIC_FOLDER_IMG' => $images['folder'],
+ 'ARTICLE_TITLE' => $articles[$i]['article_title'],
+ 'ARTICLE_DESC' => $articles[$i]['article_desc'],
+ 'ARTICLE_AUTHOR' => $author,
+ 'ARTICLE_HITS' => $articles[$i]['article_hits'],
+ 'ARTICLE_LAST_ACTION' => $last_action,
+ 'U_VIEW_ARTICLE' => append_sid("kb.$phpEx?pid=viewarticle&id=" . $articles[$i]['article_id']))
+ );
+ }
+ }
+
+ //
+ // Generate the page
+ //
+ $template->pparse('body');
+
+ include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
break;
case "view_article":
@@ -156,6 +323,10 @@
case "search":
break;
+ case "comment":
+ // For Adding, deleting and editing comments, this includes rating.
+ break;
+
default:
message_die(GENERAL_MESSAGE, 'Wrong page id defined. No page shown.');
break;
Modified: root/kb_install.php
===================================================================
--- root/kb_install.php 2006-11-21 15:00:56 UTC (rev 18)
+++ root/kb_install.php 2006-11-21 19:57:07 UTC (rev 19)
@@ -64,6 +64,13 @@
article_id mediumint(8) UNSIGNED NOT NULL auto_increment,
cat_id mediumint(8) UNSIGNED DEFAULT '0',
article_title varchar(100) NOT NULL,
+ article_desc varchar(255) NOT NULL,
+ article_author mediumint(8) UNSIGNED NOT NULL,
+ article_authorname varchar(50) NOT NULL,
+ article_edittime int(20) UNSIGNED DEFAULT '0',
+ article_hits mediumint(8) UNSIGNED DEFAULT '0',
+ article_editby mediumint(8) UNSIGNED DEFAULT '0',
+ article_status smallint(1) UNSIGNED DEFAULT '0',
article_text text,
PRIMARY KEY (article_id),
KEY cat_id (cat_id)
Modified: root/language/lang_english/lang_kb.php
===================================================================
--- root/language/lang_english/lang_kb.php 2006-11-21 15:00:56 UTC (rev 18)
+++ root/language/lang_english/lang_kb.php 2006-11-21 19:57:07 UTC (rev 19)
@@ -26,4 +26,8 @@
$lang['kb_subcats'] = "Subcategories";
$lang['kb_remove_installfile'] = "Please ensure that you remove the kb_install.php file located in your phpBB root folder. KnowledgeBase won't work before that has been done!";
$lang['No_kb_cats'] = "No knowledgebase categories has been added.";
+
+$lang['kb_viewcat_subcats'] = "Subcategories in %s";
+$lang['kb_last_action'] = "Last action";
+$lang['kb_last_action_row'] = "Last action for this article was comitted by %s on the %s";
?>
\ No newline at end of file
Modified: root/templates/subSilver/kb_main.tpl
===================================================================
--- root/templates/subSilver/kb_main.tpl 2006-11-21 15:00:56 UTC (rev 18)
+++ root/templates/subSilver/kb_main.tpl 2006-11-21 19:57:07 UTC (rev 19)
@@ -23,6 +23,9 @@
<td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"> <span class="gensmall">{catrow.CAT_ARTICLES}</span></td>
</tr>
<!-- END catrow -->
+ <tr>
+ <td class="catBottom" align="center" valign="middle" colspan="3" height="28"> </td>
+ </tr>
</table>
<table width="100%" cellspacing="0" border="0" align="center" cellpadding="2">
Added: root/templates/subSilver/kb_viewcat.tpl
===================================================================
--- root/templates/subSilver/kb_viewcat.tpl (rev 0)
+++ root/templates/subSilver/kb_viewcat.tpl 2006-11-21 19:57:07 UTC (rev 19)
@@ -0,0 +1,51 @@
+<!-- BEGIN switch_subcats -->
+<table width="100%" cellpadding="2" cellspacing="1" border="0" class="forumline">
+ <tr>
+ <th colspan="2" class="thCornerL" height="25" nowrap="nowrap"> {L_SUBCATS} </th>
+ <th class="thCornerR" nowrap="nowrap"> {L_ARTICLES} </th>
+ </tr>
+ <!-- BEGIN catrow -->
+ <tr>
+ <td class="row1" align="center" valign="middle" height="50"><img src="{switch_subcats.catrow.FORUM_FOLDER_IMG}" width="46" height="25" /></td>
+ <td class="row1" width="100%" height="50"><span class="forumlink"> <a href="{switch_subcats.catrow.U_VIEWCAT}" class="forumlink">{switch_subcats.catrow.CAT_TITLE}</a></span><br />
+ <span class="gensmall">{switch_subcats.catrow.CAT_DESC}</span><br />
+ </td>
+ <td class="row2" align="center" valign="middle" height="50" nowrap="nowrap"> <span class="gensmall">{switch_subcats.catrow.CAT_ARTICLES}</span></td>
+ </tr>
+ <!-- END catrow -->
+ <tr>
+ <td class="catBottom" align="center" valign="middle" colspan="4" height="28"> </td>
+ </tr>
+</table>
+<!-- END switch_subcats -->
+<br />
+<!-- BEGIN switch_articles -->
+<table border="0" cellpadding="4" cellspacing="1" width="100%" class="forumline">
+ <tr>
+ <th colspan="2" align="center" height="25" class="thCornerL" nowrap="nowrap"> {L_ARTICLES} </th>
+ <th width="100" align="center" class="thTop" nowrap="nowrap"> {L_AUTHOR} </th>
+ <th width="50" align="center" class="thTop" nowrap="nowrap"> {L_VIEWS} </th>
+ <th align="center" class="thCornerR" nowrap="nowrap"> {L_LAST_ACTION} </th>
+ </tr>
+ <!-- BEGIN articlerow -->
+ <tr>
+ <td class="row1" align="center" valign="middle" width="20"><img src="{articlerow.TOPIC_FOLDER_IMG}" width="19" height="18" /></td>
+ <td class="row1" width="100%"><span class="topictitle"><a href="{articlerow.U_VIEW_ARTICLE}" class="topictitle">{articlerow.ARTICLE_TITLE}</a></span><span class="gensmall"><br />
+ {articlerow.ARTICLE_DESC}</span></td>
+ <td class="row3" align="center" valign="middle"><span class="name">{articlerow.ARTICLE_AUTHOR}</span></td>
+ <td class="row2" align="center" valign="middle"><span class="postdetails">{articlerow.ARTICLE_HITS}</span></td>
+ <td class="row3Right" align="center" valign="middle" nowrap="nowrap"><span class="postdetails">{articlerow.ARTICLE_LAST_ACTION}</span></td>
+ </tr>
+ <!-- END articlerow -->
+ <tr>
+ <td class="catBottom" align="center" valign="middle" colspan="4" height="28"> </td>
+ </tr>
+</table>
+<!-- END switch_articles -->
+
+<table width="100%" cellspacing="0" border="0" align="center" cellpadding="2">
+ <tr>
+ <td align="left"> </td>
+ <td align="right"><span class="gensmall">{S_TIMEZONE}</span></td>
+ </tr>
+</table>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|