|
From: Markus P. <mar...@us...> - 2005-03-21 19:33:56
|
Update of /cvsroot/mxbb/core/includes In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1512 Modified Files: mx_functions_phpbb.php Log Message: Hacking smilies_pass from phpbb/includes/bbcode.php Hacking generate_smilies from phpbb/includes/functions_post.php Index: mx_functions_phpbb.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/mx_functions_phpbb.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** mx_functions_phpbb.php 16 Mar 2005 00:17:26 -0000 1.1 --- mx_functions_phpbb.php 21 Mar 2005 19:33:44 -0000 1.2 *************** *** 23,26 **** --- 23,27 ---- * Included functions in this file: (validated for phpbb 2.0.10) * - mx_smilies_pass (from bbcode.php) + * - mx_generate_smilies (from functions_post.php) * - mx_decode * - mx_init_userprefs (from functions.php) *************** *** 28,71 **** * - mx_message_die (from functions.php) * - mx_block_info (another message_die clone, from functions.php) - * - mx_generate_smilies (from functions_post.php) * - mx_redirect (from functions_post.php) */ ! function mx_smilies_pass( $message ) { ! static $orig, $repl; ! ! if ( !isset( $orig ) ) ! { ! global $db, $board_config; ! $orig = $repl = array(); ! ! $sql = 'SELECT * FROM ' . SMILIES_TABLE; ! if ( !$result = $db->sql_query( $sql ) ) ! { ! mx_message_die( GENERAL_ERROR, "Couldn't obtain smilies data", "", __LINE__, __FILE__, $sql ); ! } ! $smilies = $db->sql_fetchrowset( $result ); ! ! if ( count( $smilies ) ) ! { ! usort( $smilies, 'smiley_sort' ); ! } ! ! for( $i = 0; $i < count( $smilies ); $i++ ) ! { ! $orig[] = "/(?<=.\W|\W.|^\W)" . phpbb_preg_quote( $smilies[$i]['code'], "/" ) . "(?=.\W|\W.|\W$)/"; ! $repl[] = '<img src="' . PHPBB_URL . $board_config['smilies_path'] . '/' . $smilies[$i]['smile_url'] . '" alt="' . $smilies[$i]['emoticon'] . '" border="0" />'; ! } ! } ! ! if ( count( $orig ) ) ! { ! $message = preg_replace( $orig, $repl, ' ' . $message . ' ' ); ! $message = substr( $message, 1, -1 ); ! } return $message; } // Convert the bbcode to html function mx_decode( $bbtext, $bbcode_uid ) { --- 29,66 ---- * - mx_message_die (from functions.php) * - mx_block_info (another message_die clone, from functions.php) * - mx_redirect (from functions_post.php) */ ! // ! // Hacking smilies_pass from phpbb/includes/bbcode.php ! // ! function mx_smilies_pass($message) { ! global $board_config; ! $smilies_path = $board_config['smilies_path']; ! $board_config['smilies_path'] = PHPBB_URL . $board_config['smilies_path']; ! $message = smilies_pass($message); ! $board_config['smilies_path'] = $smilies_path; return $message; } + + // + // Hacking generate_smilies from phpbb/includes/functions_post.php + // + function mx_generate_smilies($mode, $page_id) + { + global $board_config, $template, $phpEx; + $smilies_path = $board_config['smilies_path']; + $board_config['smilies_path'] = PHPBB_URL . $board_config['smilies_path']; + generate_smilies($mode, $page_id); + $board_config['smilies_path'] = $smilies_path; + $template->assign_vars(array( + 'U_MORE_SMILIES' => append_sid(PHPBB_URL . "posting.$phpEx?mode=smilies")) + ); + } + + // // Convert the bbcode to html + // function mx_decode( $bbtext, $bbcode_uid ) { *************** *** 597,706 **** } - // Fill smiley templates (or just the variables) with smileys - // Either in a window or inline - function mx_generate_smilies( $mode, $page_id ) - { - global $db, $board_config, $template, $lang, $images, $theme, $phpEx, $mx_root_path, $phpbb_root_path; - global $user_ip, $session_length, $starttime; - global $userdata; - - $inline_columns = 4; - $inline_rows = 5; - $window_columns = 8; - - if ( $mode == 'window' ) - { - $userdata = session_pagestart( $user_ip, $page_id ); - mx_init_userprefs( $userdata ); - - $gen_simple_header = true; - // $page_title = $lang['Review_topic'] . " - $topic_title"; - $page_title = $lang['Emoticons'] . " - $topic_title"; - include( $mx_root_path . 'includes/page_header.' . $phpEx ); - - $template->set_filenames( array( 'smiliesbody' => 'mx_posting_smilies.tpl' ) - ); - } - - $sql = "SELECT emoticon, code, smile_url - FROM " . SMILIES_TABLE . " - ORDER BY smilies_id"; - if ( $result = $db->sql_query( $sql ) ) - { - $num_smilies = 0; - $rowset = array(); - while ( $row = $db->sql_fetchrow( $result ) ) - { - if ( empty( $rowset[$row['smile_url']] ) ) - { - $rowset[$row['smile_url']]['code'] = str_replace( '\\', '\\\\', str_replace( "'", "\\'", $row['code'] ) ); - $rowset[$row['smile_url']]['emoticon'] = $row['emoticon']; - $num_smilies++; - } - } - - if ( $num_smilies ) - { - $smilies_count = ( $mode == 'inline' ) ? min( 19, $num_smilies ) : $num_smilies; - $smilies_split_row = ( $mode == 'inline' ) ? $inline_columns - 1 : $window_columns - 1; - - $s_colspan = 0; - $row = 0; - $col = 0; - - while ( list( $smile_url, $data ) = @each( $rowset ) ) - { - if ( !$col ) - { - $template->assign_block_vars( 'smilies_row', array() ); - } - - $template->assign_block_vars( 'smilies_row.smilies_col', array( 'SMILEY_CODE' => $data['code'], - 'SMILEY_IMG' => PHPBB_URL . $board_config['smilies_path'] . '/' . $smile_url, - 'SMILEY_DESC' => $data['emoticon'] ) - ); - - $s_colspan = max( $s_colspan, $col + 1 ); - - if ( $col == $smilies_split_row ) - { - if ( $mode == 'inline' && $row == $inline_rows - 1 ) - { - break; - } - $col = 0; - $row++; - } - else - { - $col++; - } - } - - if ( $mode == 'inline' && $num_smilies > $inline_rows * $inline_columns ) - { - $template->assign_block_vars( 'switch_smilies_extra', array() ); - - $template->assign_vars( array( 'L_MORE_SMILIES' => $lang['More_emoticons'], - 'U_MORE_SMILIES' => append_sid( PORTAL_URL . "more_smilies.$phpEx?mode=smilies" ) ) - ); - } - - $template->assign_vars( array( 'FIELD' => 'block_info', - 'L_EMOTICONS' => $lang['Emoticons'], - 'L_CLOSE_WINDOW' => $lang['Close_window'], - 'S_SMILIES_COLSPAN' => $s_colspan ) - ); - } - } - - if ( $mode == 'window' ) - { - $template->pparse( 'smiliesbody' ); - - include( $mx_root_path . 'includes/page_tail.' . $phpEx ); - } - } - // MX - Redeclarations of functions from function.php function mx_redirect( $url, $redirect_msg = '', $redirect_link = '' ) --- 592,595 ---- |