Okay, according to the mod it replaces two things. one in bbcode.php and the other in functions_post.php
Quote:
Complete new function generate_smilies
Below are the major edits done.
#-----[ OPEN ]-----------------------------------------------------------------
#
includes/bbcode.php
#
#-----[ FIND ]-----------------------------------------------------------------
# This is the complete smilies_pass function
#
//
// Smilies code ... would this be better tagged on to the end of bbcode.php?
// Probably so and I'll move it before B2
//
function 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) )
{
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)" . preg_quote($smilies[$i]['code'], "/") . "(?=.W|W.|W$)/";
$repl[] = '<img src="'. $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;
}
#
#-----[ REPLACE WITH ]---------------------------------------------------------
# Complete new function
#
//START MOD Smiley_management
//
// Smilies code
//
function smilies_pass($message)
{
static $orig, $repl;
if (!isset($orig))
{
// EDIT MSTheme: smilies are in templates/..../images/smiles
global $db, $board_config, $theme, $userdata;
$orig = $repl = array();
//Smilies for parsing: No hidden pages (hidden > ADMIN) (assumed duplicate pages),
//and get only 1 of each themed set.
$style = ($userdata['user_style']) ? $userdata['user_style'] : $board_config['default_style'];
$sql = "SELECT s.*
FROM " . SMILIES_TABLE . " s, " . SMILIES_PAGES_TABLE . " p
WHERE p.id = s.page
AND code <> '' and smile_url <> ''
AND access IN(" . USER . ', ' . MOD . ', ' . ADMIN . ")
AND (theme = 0 OR theme = $style)
ORDER BY code";
if( !$result = $db->sql_query($sql) )
{
message_die(GENERAL_ERROR, "Couldn't obtain smilies data", "", __LINE__, __FILE__, $sql);
}
$smilies = $db->sql_fetchrowset($result);
for ($i = 0; $i < count($smilies); $i++)
{
if (strpos($smilies[$i]['code'], ' ')>0) //multiple codes?
{ //Get all codes, create more records, sorting must be absolute correct
$all_code = explode(' ', $smilies[$i]['code']);
for ($k=1;$k<count($all_code);$k++)
{
$smilies[$i]['code'] = $all_code[$k]; //set code
$smilies[] = $smilies[$i]; //add record
}
$smilies[$i]['code'] = $all_code[0]; //set first code
}
}
if (count($smilies)) usort($smilies, 'smiley_sort');
$smilies_path = $board_config['smilies_path']; //"images/smiles";//###
for ($i = 0; $i < count($smilies); $i++)
{
$orig[] = "/(?<=.W|W.|^W)" . phpbb_preg_quote($smilies[$i]['code'], "/") . "(?=.W|W.|W$)/";
switch ($smilies[$i]['align'])
{
case 0: $align="-3px;";break;
case 1: $align="top";break;
case 2: $align="middle";break;
case 3: $align="bottom";break;
}
$align = 'style="vertical-align:' . $align . '"';
$repl[] = '<img src="'. $smilies_path . '/' . $smilies[$i]['smile_url']
. '" title="' . $smilies[$i]['emoticon'] . '" alt="[' . $smilies[$i]['emoticon']
. ']" border="0" ' . $align . ' />';
}
}
if (count($orig))
{
$message = preg_replace($orig, $repl, ' ' . $message . ' ');
$message = substr($message, 1, -1);
}
return $message;
}
//END MOD Smiley_management
and Functions_post.php
#-----[ OPEN ]-----------------------------------------------------------------
#
includes/functions_post.php
#
#-----[ FIND ]-----------------------------------------------------------------
# Complete function generate_smilies
#
//
// Fill smiley templates (or just the variables) with smileys
// Either in a window or inline
//
function generate_smilies($mode, $page_id)
{
global $db, $board_config, $template, $lang, $images, $theme, $phpEx, $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);
init_userprefs($userdata);
$gen_simple_header = TRUE;
$page_title = $lang['Emoticons'];
include($phpbb_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' => $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("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($phpbb_root_path . 'includes/page_tail.'.$phpEx);
}
}
#
#-----[ REPLACE WITH ]---------------------------------------------------------
# Complete new function generate_smilies
#
//START MOD Smiley_management
//
// Fill smiley templates for window or inline
//
function generate_smilies($mode, $page_id, $page_id = 0) //Called from posting.php and privmsg.php
{
global $db, $board_config, $template, $lang, $images, $theme, $phpEx, $phpbb_root_path;
global $user_ip, $session_length, $starttime;
global $userdata;
$inline_columns = 4;
$inline_rows = 5;
//******* Get data *******//
if ($mode == 'window')
{
//Initialise separate form
$userdata = session_pagestart($user_ip, $page_id);
init_userprefs($userdata);
$gen_simple_header = TRUE;
}
//Get page list for both window and inline
$style = ($userdata['user_style']) ? $userdata['user_style'] : $board_config['default_style'];
$access = ' access = ' . USER ;
switch ($userdata['user_level'])
{
case MOD: $access = ' access IN (' . USER . ',' . MOD . ')'; break;
case ADMIN: $access = ' access IN (' . USER . ',' . MOD . ',' . ADMIN . ')'; break;
}
$sql = "SELECT *
FROM " . SMILIES_PAGES_TABLE . "
WHERE $access
AND (theme = 0 OR theme = $style)
ORDER BY `default_page` DESC,title";
$result = $db->sql_query($sql);
if( !$result )
{
message_die(GENERAL_ERROR, "Couldn't obtain smileys page list", "", __LINE__, __FILE__, $sql);
}
$row = $db->sql_fetchrowset($result);
if ($mode == 'window')
{
$verified = 0;
for ($i=0;$i<count($row);$i++) //Check page_id
{
//echo $row[$i]['title'] . "||" . $row[$i]['default_page'] , '<br />';
if ($page_id == 0)
{
if ($row[$i]['default_page'] ) $page_id = $row[$i]['id'];
}
if ($row[$i]['id'] == $page_id) $verified = 1;
}
// echo $page_id.'<br />';
if (($page_id == 0 || $verified == 0) && count($row) > 0) $page_id = $row[0]['id'];
$url = "posting.$phpEx?mode=smilies&page=";
for ($i=0;$i<count($row);$i++) //Build list
{
$page_list .= ($page_list ? ' :: ' : '');
$page_list .= '<a href="' . $url . $row[$i]['id'] . '" >' . $row[$i]['title'] . '</a>';
if ($row[$i]['id']==$page_id) $page_data = $row[$i];
}
$page_title = $lang['Emoticons'] . ($page_data['title'] ? ' * ' . $page_data['title'] : '');
$page_width = $page_data['width'];
$page_height = $page_data['height'];
include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$template->set_filenames(array(
'smiliesbody' => 'posting_smilies.tpl')
);
//Get smilies
$sql = "SELECT *
FROM " . SMILIES_TABLE . "
WHERE code <> '' AND smile_url <> '' AND page = $page_id
ORDER BY number";
}
else //$mode == 'inline'
{
//First record is first default page
$page_width = $row[0]['width'];
$page_height = $row[0]['height'];
$style = ($userdata['user_style']) ? $userdata['user_style'] : $board_config['default_style'];
$sql = "SELECT s.*
FROM " . SMILIES_TABLE . " s, " . SMILIES_PAGES_TABLE . " p
WHERE p.id = s.page
AND code <> '' AND smile_url <> '' AND inline = 1
AND $access
AND (theme = 0 OR theme = $style)
ORDER BY number
LIMIT " . ($inline_columns * $inline_rows);
}
$result = $db->sql_query($sql);
if( !$result )
{
message_die(GENERAL_ERROR, "Couldn't obtain smileys list", "", __LINE__, __FILE__, $sql);
}
$smilies = $db->sql_fetchrowset($result);
//****** Fill template *******//
$smilies_colspan = ($mode == 'inline') ? $inline_columns : $page_data['column_count'];
$smilies_path = $board_config['smilies_path'];
$row = 0; $col = 0;
for ($i=0;$i<count($smilies);$i++)
{
$all_code = explode(' ', $smilies[$i]['code']); //Select first code only from multiple to insert
$code = str_replace("'", "'", str_replace('', '\', $all_code[0]));
$colspan = ($smilies[$i]['colspan'] ? $smilies[$i]['colspan'] : 1);
if ($col==0) $template->assign_block_vars('smilies_row', array());
$template->assign_block_vars('smilies_row.smilies_col', array(
'SMILEY_CODE' => $code,
'SMILEY_IMG' => $smilies_path . '/' . $smilies[$i]['smile_url'],
'SMILEY_DESC' => $smilies[$i]['emoticon'],
'SMILEY_COLSPAN' => $colspan)
);
$col += $colspan;
if ( $col >= $smilies_colspan) {$col = 0; $row++; }
} //Next smiley
//More smilies button * Can't check if there are more smilies than just inline, assume there are:
if ($mode == 'inline')
{
$template->assign_block_vars('switch_smilies_extra', array());
$template->assign_vars(array(
'L_MORE_SMILIES' => $lang['More_emoticons'],
'U_MORE_SMILIES' => append_sid("posting.$phpEx?mode=smilies"))
);
}
$template->assign_vars(array(
'S_PAGE_WIDTH' => $page_width,
'S_PAGE_HEIGHT' => $page_height,
'S_PAGE_LIST' => $page_list,
'S_SMILIES_COLSPAN' => $smilies_colspan,
'L_EMOTICONS' => $lang['Emoticons'],
'L_CLOSE_WINDOW' => $lang['Close_window'])
);
//Parse separate template
if ($mode == 'window')
{
$template->pparse('smiliesbody');
include($phpbb_root_path . 'includes/page_tail.'.$phpEx);
}
}
//END MOD Smiley_management