[Phpbbkb-checkins] SF.net SVN: phpbbkb: [37] root
Status: Alpha
Brought to you by:
markthedaemon
From: <so...@us...> - 2007-01-07 22:19:24
|
Revision: 37 http://svn.sourceforge.net/phpbbkb/?rev=37&view=rev Author: softphp Date: 2007-01-07 14:19:22 -0800 (Sun, 07 Jan 2007) Log Message: ----------- - Another quick commit, added the preview function, which means, testing, correcting my english and we're ready for Alpha 1. Modified Paths: -------------- root/kb/functions.php Added Paths: ----------- root/templates/subSilver/kb_previewarticle.tpl Modified: root/kb/functions.php =================================================================== --- root/kb/functions.php 2007-01-07 01:09:59 UTC (rev 36) +++ root/kb/functions.php 2007-01-07 22:19:22 UTC (rev 37) @@ -1,4 +1,4 @@ -<?php + <?php /*************************************************************************** * functions.php * ------------------- @@ -207,7 +207,7 @@ if($mode == 'edit') { // Let's get the old article data - $article_id = ( !empty($HTTP_POST_VARS['id']) ) ? $HTTP_POST_VARS['id'] : false; + $article_id = $id; $sql = "SELECT * FROM " . KB_ARTICLES_TABLE . " @@ -412,17 +412,13 @@ { $smilies_on = ( ( $userdata['user_id'] == ANONYMOUS ) ? $board_config['allow_smilies'] : $userdata['user_allowsmile'] ); } - - if($preview) - { - // Do funny preview stuff - } } elseif($preview || $error_msg != '') { $article_title = $HTTP_POST_VARS['title']; $article_text = $HTTP_POST_VARS['message']; $article_desc = $HTTP_POST_VARS['desc']; + $article_cats = $HTTP_POST_VARS['cats']; $authorname = $HTTP_POST_VARS['authorname']; $attach_sig = ( $HTTP_POST_VARS['enable_sig'] ) ? TRUE : 0; @@ -431,8 +427,17 @@ $bbcode_on = ( $HTTP_POST_VARS['disable_bbcode'] ) ? false : true; $smilies_on = ( $HTTP_POST_VARS['disable_smilies'] ) ? false : true; - $form_action = append_sid("kb.php?pid=ucp&action=post_article"); - $hidden_form_fields = ""; + if($mode == 'edit') + { + $form_action = append_sid("kb.php?pid=ucp&action=edit_article"); + $hidden_form_fields = '<input type="hidden" name="id" value="' . $article_id . '" />'; + } + else + { + $hidden_form_fields = ""; + $form_action = append_sid("kb.php?pid=ucp&action=post_article"); + } + if($error_msg != "") { $template->set_filenames(array( @@ -443,17 +448,40 @@ ); $template->assign_var_from_handle('ERROR_BOX', 'reg_header'); } + + if($preview) + { + // Create the preview box + $preview_article_desc = ( !empty($HTTP_POST_VARS['desc']) ) ? trim($HTTP_POST_VARS['desc']) : ''; + $preview_article_title = ( !empty($HTTP_POST_VARS['title']) ) ? trim($HTTP_POST_VARS['title']) : ''; + $preview_message = ( !empty($HTTP_POST_VARS['message']) ) ? $HTTP_POST_VARS['message'] : ''; + $bbcode_uid = ( $bbcode_on ) ? make_bbcode_uid() : ''; + + $preview_message = stripslashes(prepare_article_text(addslashes(unprepare_article_text(trim($message))), $html_on, $bbcode_on, $smilies_on, $bbcode_uid)); + + $template->set_filenames(array( + 'preview_box' => 'kb_articlepreview.tpl') + ); + + $template->assign_vars(array( + 'PREVIEW_ARTICLE_TITLE' => $preview_article_title, + 'PREVIEW_ARTICLE_DESC' => $preview_article_desc, + 'MESSAGE' => $preview_message) + ); + + $template->assign_var_from_handle('ARTICLE_PREVIEW_BOX', 'preview'); + } } else { - if(empty($id)) + if(empty($article_id)) { message_die(GENERAL_ERROR, "No article defined."); } $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, 'Could not query article data.', '', __LINE__, __FILE__, $sql); @@ -471,7 +499,7 @@ // Now make an array over the cats $sql = "SELECT cat_id FROM " . KB_ARTICLECATS_TABLE . " - WHERE article_id = '$id'"; + WHERE article_id = '$article_id'"; if(!$result = $db->sql_query($sql)) { message_die(GENERAL_ERROR, 'Could not query articlecats data.', '', __LINE__, __FILE__, $sql); @@ -495,7 +523,7 @@ $smilies_on = ( $article['enable_smilies'] ) ? true : false; $form_action = append_sid("kb.php?pid=ucp&action=edit_article"); - $hidden_form_fields = '<input type="hidden" name="id" value="' . $id . '" />'; + $hidden_form_fields = '<input type="hidden" name="id" value="' . $article_id . '" />'; } if ( $article['bbcode_uid'] != '' ) @@ -546,7 +574,7 @@ // First lets sort main cats, yes i know there is a lot of loops, but i can't find a better way :S $s_cats = '<option value="0">-' . $lang['kb_main'] . '</option>'; - if($mode == "edit") + if($mode == "edit" || $preview) { for($i = 0; $i < count($cats); $i++) { @@ -848,7 +876,7 @@ return $message; } -function unprepare_message($message) +function unprepare_article_text($message) { $unhtml_specialchars_match = array('#>#', '#<#', '#"#', '#&#'); $unhtml_specialchars_replace = array('>', '<', '"', '&'); Added: root/templates/subSilver/kb_previewarticle.tpl =================================================================== --- root/templates/subSilver/kb_previewarticle.tpl (rev 0) +++ root/templates/subSilver/kb_previewarticle.tpl 2007-01-07 22:19:22 UTC (rev 37) @@ -0,0 +1,23 @@ + +<table class="forumline" width="100%" cellspacing="1" cellpadding="4" border="0"> + <tr> + <th height="25" class="thHead">{L_PREVIEW}</th> + </tr> + <tr> + <td class="row1"><img src="templates/subSilver/images/icon_minipost.gif" alt="{L_POST}" /><span class="postdetails">{L_ARTICLE_NAME}: {PREVIEW_ARTICLE_TITLE} {L_ARTICLE_DESC}: {PREVIEW_ARTICLE_DESC}</span></td> + </tr> + <tr> + <td class="row1"><table width="100%" border="0" cellspacing="0" cellpadding="0"> + <tr> + <td> + <span class="postbody">{MESSAGE}</span> + </td> + </tr> + </table></td> + </tr> + <tr> + <td class="spaceRow" height="1"><img src="templates/subSilver/images/spacer.gif" width="1" height="1" /></td> + </tr> +</table> + +<br clear="all" /> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |