|
From: Jon O. <jon...@us...> - 2008-07-13 19:31:10
|
Update of /cvsroot/mxbb/core/includes/sessions/internal In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv1887/internal Modified Files: core.php Log Message: bbcodes as a class, backend extended Index: core.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/sessions/internal/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:15 -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 + /** * Backend specific tasks *************** *** 491,493 **** --- 493,638 ---- } } + + /** + * MXP BBcodes + * @package MX-Publisher + */ + class mx_bbcode extends bbcode_base + { + var $smiley_path_url = ''; + var $smiley_root_path = ''; + + var $smiley_url = 'smile_url'; + var $smiley_id = 'smilies_id'; + var $emotion = 'emoticon'; + + function mx_bbcode() + { + global $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 + } + + /** + * 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']; + + include($mx_root_path . 'includes/page_header.'.$phpEx); + + $template->set_filenames(array( + 'smiliesbody' => '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' => $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) + ); + } + } + + if ($mode == 'window') + { + $template->pparse('smiliesbody'); + include($mx_root_path . 'includes/page_tail.'.$phpEx); + } + } + } + + // + // Instantiate the mx_cache class + // + $mx_bbcode = new mx_bbcode(); ?> \ No newline at end of file |