[Phpbbkb-checkins] SF.net SVN: phpbbkb: [26] root
Status: Alpha
Brought to you by:
markthedaemon
From: <so...@us...> - 2006-11-29 23:28:50
|
Revision: 26 http://svn.sourceforge.net/phpbbkb/?rev=26&view=rev Author: softphp Date: 2006-11-29 15:28:36 -0800 (Wed, 29 Nov 2006) Log Message: ----------- -- Added a very simple page for viewing articles -- Fixed a bug that made the author id delete when you edited an article. Modified Paths: -------------- root/kb/functions.php root/kb/ucp_class.php root/kb.php root/language/lang_english/lang_kb.php Modified: root/kb/functions.php =================================================================== --- root/kb/functions.php 2006-11-27 15:50:04 UTC (rev 25) +++ root/kb/functions.php 2006-11-29 23:28:36 UTC (rev 26) @@ -69,6 +69,23 @@ case "viewarticle": // Viewing an article + if($id_ary[2] == 0) + { + $navigation = '<span class="nav"> <a href="' . append_sid('kb.' . $phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_cat&id=' . $id_ary[0]) . '">' . $id_ary[1] .'</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_article&id=' . $id_ary[3]) . '&cid=' . $id_ary[0] . '">' . $id_ary[4] .'</a></span>'; + } + else + { + $sql = "SELECT cat_title + FROM " . KB_CATEGORIES_TABLE . " + WHERE cat_id = '" . $id_ary[2] . "'"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query cat name.', '', __LINE__, __FILE__, $sql); + } + $maincat = $db->sql_fetchrow($result); + + $navigation = '<span class="nav"> <a href="' . append_sid('kb.' . $phpEx) . '" class="nav">' . $lang['kb_main'] . '</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_cat&id=' . $id_ary[2]) . '">' . $maincat['cat_title'] .'</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_cat&id=' . $id_ary[0]) . '">' . $id_ary[1] .'</a> -> <a class="nav" href="' . append_sid('kb.' . $phpEx.'?pid=view_article&id=' . $id_ary[3]) . '&cid=' . $id_ary[0] . '">' . $id_ary[4] .'</a></span>'; + } break; case "search": Modified: root/kb/ucp_class.php =================================================================== --- root/kb/ucp_class.php 2006-11-27 15:50:04 UTC (rev 25) +++ root/kb/ucp_class.php 2006-11-29 23:28:36 UTC (rev 26) @@ -128,7 +128,7 @@ $sql = "SELECT * FROM " . KB_ARTICLES_TABLE . " - WHERE article_id = '$id'"; + WHERE article_id = '$article_id'"; if (!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Error while retrieving old article data.', '', __LINE__, __FILE__, $sql); Modified: root/kb.php =================================================================== --- root/kb.php 2006-11-27 15:50:04 UTC (rev 25) +++ root/kb.php 2006-11-29 23:28:36 UTC (rev 26) @@ -351,19 +351,170 @@ $cid = ( empty($HTTP_GET_VARS['cid']) ) ? false : $HTTP_GET_VARS['cid']; $id = ( empty($HTTP_GET_VARS['cid']) ) ? false : $HTTP_GET_VARS['id']; + // Get naughty words :) + $orig_word = array(); + $replacement_word = array(); + obtain_word_list($orig_word, $replacement_word); + if(!$cid || !$id) { message_die(GENERAL_ERROR, 'Not enough arguments defined. Please make sure both id and cat id is defined.'); } - $sql = "SELECT * - FROM " . KB_ARTICLES_TABLE . " - WHERE article_id = '$id'"; + $sql = "SELECT a.*, u.* + FROM " . KB_ARTICLES_TABLE . " a, " . USERS_TABLE . " u + WHERE a.article_id = '$id' + AND a.article_author = u.user_id"; if( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Could not query article info', '', __LINE__, __FILE__, $sql); } + $article = $db->sql_fetchrow($result); + + $sql = "SELECT c.*, ca.* + FROM " . KB_ARTICLECATS_TABLE . " c, " . KB_CATEGORIES_TABLE . " ca + WHERE c.article_id = '$id' + AND ca.cat_id = c.cat_id"; + if( !($result = $db->sql_query($sql)) ) + { + message_die(GENERAL_ERROR, 'Could not query article categories.', '', __LINE__, __FILE__, $sql); + } + + // + // These vars are for later use + // + $cats = array(); + while($row = $db->sql_fetchrow($result)) + { + $cats[] = $row; + + if($row['cat_id'] == $cid) + { + $current_cat['cat_title'] = $row['cat_title']; + $current_cat['cat_id'] = $row['cat_id']; + $current_cat['cat_main'] = $row['cat_main']; + } + } + + $article_title = $article['article_title']; + $article_text = $article['article_text']; + $article_bbcode_uid = $article['bbcode_uid']; + + $user_sig = ( $article['enable_sig'] && $article['user_sig'] != '' && $board_config['allow_sig'] ) ? $article['user_sig'] : ''; + $user_sig_bbcode_uid = $article['user_sig_bbcode_uid']; + + // A lot of copy/paste from viewtopic.php, then shaped for this file ofc :) + // + // If the board has HTML off but the post has HTML + // on then we process it, else leave it alone + // + if ( !$board_config['allow_html'] || !$userdata['user_allowhtml']) + { + if ( $user_sig != '' ) + { + $user_sig = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $user_sig); + } + + if ( $article['enable_html'] ) + { + $article_text = preg_replace('#(<)([\/]?.*?)(>)#is', "<\\2>", $article_text); + } + } + + // + // Parse message and/or sig for BBCode if reqd + // + if ($user_sig != '' && $user_sig_bbcode_uid != '') + { + $user_sig = ($board_config['allow_bbcode']) ? bbencode_second_pass($user_sig, $user_sig_bbcode_uid) : preg_replace("/\:$user_sig_bbcode_uid/si", '', $user_sig); + } + + if ($article_bbcode_uid != '') + { + $article_text = ($board_config['allow_bbcode']) ? bbencode_second_pass($article_text, $article_bbcode_uid) : preg_replace("/\:$article_bbcode_uid/si", '', $article_text); + } + + if ( $user_sig != '' ) + { + $user_sig = make_clickable($user_sig); + } + $article_text = make_clickable($article_text); + + // + // Parse smilies + // + if ( $board_config['allow_smilies'] ) + { + if ( $article['user_allowsmile'] && $user_sig != '' ) + { + $user_sig = smilies_pass($user_sig); + } + + if ( $article['enable_smilies'] ) + { + $article_text = smilies_pass($article_text); + } + } + + // + // Replace naughty words + // + if (count($orig_word)) + { + $article_title = preg_replace($orig_word, $replacement_word, $article_title); + + if ($user_sig != '') + { + $user_sig = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $user_sig . '<'), 1, -1)); + } + + $article_text = str_replace('\"', '"', substr(@preg_replace('#(\>(((?>([^><]+|(?R)))*)\<))#se', "@preg_replace(\$orig_word, \$replacement_word, '\\0')", '>' . $article_text . '<'), 1, -1)); + } + + // + // Replace newlines (we use this rather than nl2br because + // till recently it wasn't XHTML compliant) + // + if ( $user_sig != '' ) + { + $user_sig = '<br />_________________<br />' . str_replace("\n", "\n<br />\n", $user_sig); + } + + $article_text = str_replace("\n", "\n<br />\n", $article_text); + + // Start Page output + $page_title = $lang['kb_viewarticle'] . " : " . $article_title; + include($phpbb_root_path . 'includes/page_header.' . $phpEx); + + $template->set_filenames(array( + 'body' => 'kb_viewarticle.tpl') + ); + + create_navigation("viewarticle", array( + 0 => $current_cat['cat_id'], + 1 => $current_cat['cat_title'], + 2 => $current_cat['cat_main'], + 3 => $article['article_id'], + 4 => $article_title) + ); + + $posted_by = sprintf($lang['kb_posted_by'], '<a href="' . append_sid('profile.' . $phpEx . '?mode=viewprofile&u=' . $article['article_author']) . '">' . $article['article_authorname'] . '</a>', create_date($board_config['default_dateformat'], $article['article_time'], $board_config['board_timezone']), create_date($board_config['default_dateformat'], $article['article_edittime'], $board_config['board_timezone'])); + + $template->assign_vars(array( + 'U_VIEW_ARTICLE' => append_sid('kb.' . $phpEx . '?pid=view_article&cid=' . $cid . '&id=' . $article['article_id']), + 'ARTICLE_TITLE' => $article_title, + 'ARTICLE_TEXT' => $article_text, + 'POSTED_BY' => $posted_by, + 'SIGNATURE' => $user_sig) + ); + + // + // Generate the page + // + $template->pparse('body'); + + include($phpbb_root_path . 'includes/page_tail.'.$phpEx); break; case "ucp": Modified: root/language/lang_english/lang_kb.php =================================================================== --- root/language/lang_english/lang_kb.php 2006-11-27 15:50:04 UTC (rev 25) +++ root/language/lang_english/lang_kb.php 2006-11-29 23:28:36 UTC (rev 26) @@ -21,6 +21,7 @@ // Page titles $lang['kb_main'] = "KnowledgeBase Home"; $lang['kb_viewcat'] = "Viewing Category"; +$lang['kb_viewarticle'] = "Viewing Article"; $lang['kb_ucp'] = "KB User Control Panel"; $lang['kb_ucp_articlepost'] = "Post new article"; $lang['kb_ucp_articleedit'] = "Edit article"; @@ -53,4 +54,5 @@ $lang['kb_added'] = "Your article has been submitted and is awaiting approval."; $lang['kb_click_view_article'] = "Click %here% to view you article."; // Change this later on, they can't view the article yet. $lang['kb_click_return_ucp'] = "Click %here% to go back to the user control panel"; +$lang['kb_posted_by'] = "This article was submitted by %s on %s, it was last updated on %s."; ?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |