|
From: Jon O. <jon...@us...> - 2008-07-13 19:31:11
|
Update of /cvsroot/mxbb/core/includes/sessions/phpbb3 In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv1887/phpbb3 Modified Files: core.php Log Message: bbcodes as a class, backend extended Index: core.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/sessions/phpbb3/core.php,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** core.php 12 Jul 2008 20:24:17 -0000 1.6 --- core.php 13 Jul 2008 19:31:07 -0000 1.7 *************** *** 22,25 **** --- 22,27 ---- include_once($mx_root_path . 'includes/shared/phpbb3/includes/functions.' . $phpEx); + include_once($mx_root_path . 'includes/mx_functions_bbcode.' . $phpEx); // BBCode associated functions + // // Switch *************** *** 806,809 **** --- 808,1029 ---- /** + * MXP BBcodes + * @package MX-Publisher + */ + class mx_bbcode extends bbcode_base + { + var $smiley_path_url = ''; + var $smiley_root_path = ''; + + var $smiley_url = 'smiley_url'; + var $smiley_id = 'smiley_id'; + var $emotion = 'emotion'; + + function mx_bbcode() + { + global $board_config, $phpbb_root_path; + + $this->smiley_path_url = PHPBB_URL; //change this to PORTAL_URL when shared folder will be removed + $this->smiley_root_path = $phpbb_root_path; //same here + $board_config['smilies_path'] = str_replace("smiles", "smilies", $board_config['smilies_path']); + } + + /** + * Generate smilies. + * + * Hacking generate_smilies from phpbb/includes/functions_post(ing).php + * + * @param string $mode + * @param integer $page_id + * + * Fill smiley templates (or just the variables) with smilies, either in a window or inline + */ + function generate_smilies($mode, $forum_id) + { + global $mx_page, $board_config, $template, $mx_root_path, $phpbb_root_path, $phpEx; + global $db, $lang, $images, $theme; + global $user_ip, $session_length, $starttime; + global $userdata, $phpbb_auth, $mx_user; + + $inline_columns = 4; + $inline_rows = 5; + $window_columns = 8; + + if ($mode == 'window') + { + $mx_user->init($user_ip, PAGE_INDEX); + + $gen_simple_header = TRUE; + $page_title = $lang['Emoticons']; + + if ($forum_id) + { + $sql = 'SELECT forum_style + FROM ' . FORUMS_TABLE . " + WHERE forum_id = $forum_id"; + $result = $db->sql_query_limit($sql, 1); + $row = $db->sql_fetchrow($result); + $db->sql_freeresult($result); + + $mx_user->setup('posting', (int) $row['forum_style']); + } + else + { + $mx_user->setup('posting'); + } + + include($mx_root_path . 'includes/page_header.'.$phpEx); + + $template->set_filenames(array( + 'smiliesbody' => 'posting_smilies.html') + ); + } + + $display_link = false; + if ($mode == 'inline') + { + $sql = 'SELECT smiley_id + FROM ' . SMILIES_TABLE . ' + WHERE display_on_posting = 0'; + $result = $db->sql_query_limit($sql, 1, 0, 3600); + + if ($row = $db->sql_fetchrow($result)) + { + $display_link = true; + } + $db->sql_freeresult($result); + } + + $last_url = ''; + + $sql = 'SELECT * + FROM ' . SMILIES_TABLE . + (($mode == 'inline') ? ' WHERE display_on_posting = 1 ' : '') . ' + ORDER BY smiley_order'; + + //phpBB2 code start + if ($result = $db->sql_query($sql)) + { + $num_smilies = 0; + $rowset = array(); + while ($row = $db->sql_fetchrow($result)) + { + if (empty($rowset[$row['smiley_url']])) + { + $rowset[$row['smiley_url']]['code'] = str_replace("'", "\\'", str_replace('\\', '\\\\', $row['code'])); + $rowset[$row['smiley_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' => $this->smiley_path_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' => mx3_append_sid(PHPBB_URL . "posting.$phpEx", "mode=smilies")) + ); + } + + $template->assign_vars(array( + 'L_EMOTICONS' => $lang['Emoticons'], + 'L_CLOSE_WINDOW' => $lang['Close_window'], + 'S_SMILIES_COLSPAN' => $s_colspan) + ); + } + } + + /* + $result = $db->sql_query($sql, 3600); + + $smilies = array(); + while ($row = $db->sql_fetchrow($result)) + { + if (empty($smilies[$row['smiley_url']])) + { + $smilies[$row['smiley_url']] = $row; + } + } + $db->sql_freeresult($result); + + if (sizeof($smilies)) + { + foreach ($smilies as $row) + { + $template->assign_block_vars('smiley', array( + 'SMILEY_CODE' => $row['code'], + 'A_SMILEY_CODE' => addslashes($row['code']), + 'SMILEY_IMG' => $this->smiley_root_path . $board_config['smilies_path'] . '/' . $row['smiley_url'], + 'SMILEY_WIDTH' => $row['smiley_width'], + 'SMILEY_HEIGHT' => $row['smiley_height'], + 'SMILEY_DESC' => $row['emotion']) + ); + } + } + + //What we do here with forum_id versus page_id ? + if ($mode == 'inline' && $display_link) + { + $template->assign_vars(array( + 'S_SHOW_SMILEY_LINK' => true, + 'U_MORE_SMILIES' => mx3_append_sid(PHPBB_URL . "posting.$phpEx", 'mode=smilies&f=' . $forum_id)) + ); + } + */ + + if ($mode == 'window') + { + $template->pparse('smiliesbody'); + include($mx_root_path . 'includes/page_tail.'.$phpEx); + } + } + } + + // + // Instantiate the mx_cache class + // + $mx_bbcode = new mx_bbcode(); + + /** * Olympus Parse cfg file */ *************** *** 1063,1067 **** function mx_generate_text_for_display($text, $uid, $bitfield, $flags) { ! static $bbcode; if (!$text) --- 1283,1287 ---- function mx_generate_text_for_display($text, $uid, $bitfield, $flags) { ! static $bbcode, $mx_bbcode; if (!$text) *************** *** 1095,1099 **** $text = str_replace("\n", '<br />', $text); ! $text = mx_smilies_pass($text, !($flags & OPTION_FLAG_SMILIES)); return $text; --- 1315,1319 ---- $text = str_replace("\n", '<br />', $text); ! $text = $mx_bbcode->smilies_pass($text, !($flags & OPTION_FLAG_SMILIES)); return $text; |