|
From: Jon O. <jon...@us...> - 2006-06-25 21:55:15
|
Update of /cvsroot/mxbb/mx_kb/kb/includes In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv26394/modules/mx_kb/kb/includes Modified Files: functions_comment.php functions_kb.php Log Message: Implementing a new mx_post class, to handle all kind of html, bbcode, smilies, links, images etc Index: functions_comment.php =================================================================== RCS file: /cvsroot/mxbb/mx_kb/kb/includes/functions_comment.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** functions_comment.php 17 Jun 2006 20:11:23 -0000 1.6 --- functions_comment.php 25 Jun 2006 21:55:12 -0000 1.7 *************** *** 151,154 **** --- 151,161 ---- // + // Toggles + // + $bbcode_on = !$kb_config['allow_wysiwyg'] ? ($kb_config['allow_bbcode'] ? true : false) : false; + $html_on = !$kb_config['allow_wysiwyg'] ? ($kb_config['allow_html'] ? true : false) : true; + $smilies_on = !$kb_config['allow_wysiwyg'] ? ($kb_config['allow_smilies'] ? true : false) : false; + + // // page number (only used for kb articles) // *************** *** 168,174 **** // ! // Includes // ! include_once($phpbb_root_path . 'includes/bbcode.'.$phpEx); $template->assign_block_vars( 'use_comments', array( --- 175,184 ---- // ! // Instantiate the mx_text class // ! include_once($mx_root_path . 'includes/mx_functions_tools.'.$phpEx); ! $mx_text = new mx_text(); ! $mx_text->init($html_on, $bbcode_on, $smilies_on); // Note: allowed_html_tags is altered above ! $mx_text->allow_all_html_tags = $kb_config['allow_wysiwyg'] ? true : false; $template->assign_block_vars( 'use_comments', array( *************** *** 177,187 **** // - // Define censored word matches - // - $orig_word = array(); - $replacement_word = array(); - obtain_word_list( $orig_word, $replacement_word ); - - // // Get all comments // --- 187,190 ---- *************** *** 194,206 **** { $time = create_date( $board_config['default_dateformat'], $this->comments_row['comments_time'], $board_config['board_timezone'] ); - $comments_text = $this->comments_row['comments_text']; ! if ( !$kb_config['allow_html'] ) ! { ! if ( $comments_text != '' && $userdata['user_allowhtml'] ) ! { ! $comments_text = preg_replace( '#(<)([\/]?.*?)(>)#is', "<\\2>", $comments_text ); ! } ! } // --- 197,206 ---- { $time = create_date( $board_config['default_dateformat'], $this->comments_row['comments_time'], $board_config['board_timezone'] ); ! // ! // Decode comment for display ! // ! $comments_title = $mx_text->display_simple($this->comments_row['comments_title']); ! $comments_text = $mx_text->display($this->comments_row['comments_text'], $this->comments_row['comment_bbcode_uid']); // *************** *** 209,242 **** if (!$kb_config['allow_comment_images'] || !$kb_config['allow_comment_links']) { - $comments_text = $mx_kb_text_tools->remove_images_links( $comments_text, $kb_config['allow_comment_images'], $kb_config['no_comment_image_message'], $kb_config['allow_comment_links'], $kb_config['no_comment_link_message'] ); } - if ( $kb_config['allow_bbcode'] ) - { - if ( $comments_text != '' && $this->comments_row['comment_bbcode_uid'] != '' ) - { - $comments_text = ( $kb_config['allow_bbcode'] ) ? bbencode_second_pass( $comments_text, $this->comments_row['comment_bbcode_uid'] ) : preg_replace( '/\:[0-9a-z\:]+\]/si', ']', $comments_text ); - } - } - - $comments_text = make_clickable( $comments_text ); - - if ( count( $orig_word ) ) - { - if ( $comments_text != '' ) - { - $comments_text = preg_replace( $orig_word, $replacement_word, $comments_text ); - } - } - - if ( $kb_config['allow_smilies'] ) - { - if ( $userdata['user_allowsmile'] && $comments_text != '' ) - { - $comments_text = mx_smilies_pass( $comments_text ); - } - } - $poster = ( $this->comments_row['user_id'] == ANONYMOUS ) ? $lang['Guest'] : $this->comments_row['username']; $poster_avatar = ''; --- 209,215 ---- *************** *** 289,295 **** } - $comments_title = $this->comments_row['comments_title']; - $comments_text = str_replace( "\n", "\n<br />\n", $comments_text ); - // // Text formatting --- 262,265 ---- *************** *** 389,392 **** --- 359,369 ---- // + // Toggles + // + $bbcode_on = !$kb_config['allow_wysiwyg'] ? ($kb_config['allow_bbcode'] ? true : false) : false; + $html_on = !$kb_config['allow_wysiwyg'] ? ($kb_config['allow_html'] ? true : false) : true; + $smilies_on = !$kb_config['allow_wysiwyg'] ? ($kb_config['allow_smilies'] ? true : false) : false; + + // // page number (only used for kb articles) // *************** *** 406,412 **** // ! // Includes // ! include_once($phpbb_root_path . 'includes/bbcode.'.$phpEx); $template->assign_block_vars( 'use_comments', array( --- 383,392 ---- // ! // Instantiate the mx_text class // ! include_once($mx_root_path . 'includes/mx_functions_tools.'.$phpEx); ! $mx_text = new mx_text(); ! $mx_text->init($html_on, $bbcode_on, $smilies_on); // Note: allowed_html_tags is altered above ! $mx_text->allow_all_html_tags = $kb_config['allow_wysiwyg'] ? true : false; $template->assign_block_vars( 'use_comments', array( *************** *** 415,425 **** // - // Define censored word matches - // - $orig_word = array(); - $replacement_word = array(); - obtain_word_list( $orig_word, $replacement_word ); - - // // Get all comments // --- 395,398 ---- *************** *** 446,469 **** $poster_rank = $lang['Guest']; } - $comments_title = ( $this->comments_row['post_subject'] != '' ) ? $this->comments_row['post_subject'] : ''; - - $comments_text = $this->comments_row['post_text']; - $bbcode_uid = $this->comments_row['bbcode_uid']; - - // 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'] ) - { - if ( $user_sig != '' && $userdata['user_allowhtml'] ) - { - $user_sig = preg_replace( '#(<)([\/]?.*?)(>)#is', "<\\2>", $user_sig ); - } ! if ( $this->comments_row['enable_html'] ) ! { ! $comments_text = preg_replace( '#(<)([\/]?.*?)(>)#is', "<\\2>", $comments_text ); ! } ! } // --- 419,429 ---- $poster_rank = $lang['Guest']; } ! // ! // Decode comment for display ! // ! $comments_title = $mx_text->display_simple($this->comments_row['post_subject']); ! $comments_text = $mx_text->display($this->comments_row['post_text'], $this->comments_row['bbcode_uid']); ! $user_sig = $mx_text->display($this->comments_row['user_sig'], $this->comments_row['user_sig_bbcode_uid']); // *************** *** 472,519 **** if (!$kb_config['allow_comment_images'] || !$kb_config['allow_comment_links']) { - $comments_text = $mx_kb_text_tools->remove_images_links( $comments_text, $kb_config['allow_comment_images'], $kb_config['no_comment_image_message'], $kb_config['allow_comment_links'], $kb_config['no_comment_link_message'] ); } // - // Parse message and/or sig for BBCode if reqd - // - if ( $board_config['allow_bbcode'] ) - { - if ( $user_sig != '' && $user_sig_bbcode_uid != '' ) - { - $user_sig = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass( $user_sig, $user_sig_bbcode_uid ) : preg_replace( '/\:[0-9a-z\:]+\]/si', ']', $user_sig ); - } - - if ( $bbcode_uid != '' ) - { - $comments_text = ( $board_config['allow_bbcode'] ) ? bbencode_second_pass( $comments_text, $bbcode_uid ) : preg_replace( '/\:[0-9a-z\:]+\]/si', ']', $comments_text ); - } - } - - if ( $user_sig != '' ) - { - $user_sig = make_clickable( $user_sig ); - } - $comments_text = make_clickable( $comments_text ); - - // - // Parse smilies - // - if ( $board_config['allow_smilies'] ) - { - if ( $this->comments_row['user_allowsmile'] && $user_sig != '' ) - { - $user_sig = mx_smilies_pass( $user_sig ); - } - - if ( $this->comments_row['enable_smilies'] ) - { - $comments_text = mx_smilies_pass( $comments_text ); - } - } - $comments_text = str_replace( "\n", "\n<br />\n", $comments_text ); - - // // Text formatting // --- 432,439 ---- Index: functions_kb.php =================================================================== RCS file: /cvsroot/mxbb/mx_kb/kb/includes/functions_kb.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** functions_kb.php 17 Jun 2006 20:11:23 -0000 1.6 --- functions_kb.php 25 Jun 2006 21:55:12 -0000 1.7 *************** *** 1429,1441 **** $length = strlen( $message ); - $title = ( !empty( $subject ) ) ? htmlspecialchars( trim ( $subject ) ) : ''; // ! // Formatting // ! $comment_bbcode_uid = make_bbcode_uid(); ! $comments_text = str_replace( '<br />', "\n", $message ); ! $comments_text = prepare_message( trim($comments_text), $html_on, $bbcode_on, $smilies_on, $comment_bbcode_uid ); ! $comments_text = bbencode_first_pass( $comments_text, $comment_bbcode_uid ); if ( $length > $kb_config['max_comment_chars'] ) --- 1429,1447 ---- $length = strlen( $message ); // ! // Instantiate the mx_text class // ! include_once($mx_root_path . 'includes/mx_functions_tools.'.$phpEx); ! $mx_text = new mx_text(); ! $mx_text->init($html_on, $bbcode_on, $smilies_on); ! //$mx_text->allow_all_html_tags = $parameter_data['parameter_type'] = 'WysiwygTextBlock' ? true : false; ! ! // ! // Encode for db storage ! // ! $title = $mx_text->encode_simple($subject); ! $comments_text = $mx_text->encode($message); ! $comment_bbcode_uid = $mx_text->bbcode_uid; if ( $length > $kb_config['max_comment_chars'] ) |