diff options
| author | Paul S. Owen <psotfx@users.sourceforge.net> | 2002-02-08 01:33:36 +0000 |
|---|---|---|
| committer | Paul S. Owen <psotfx@users.sourceforge.net> | 2002-02-08 01:33:36 +0000 |
| commit | 405efb48e0542398f22711bcbe0a7733655e3462 (patch) | |
| tree | c926671f7a3118b61ae55eeacc40dd7f54829201 /phpBB/includes/bbcode.php | |
| parent | 2087cf9f1157855d3383431ec93beade3698addd (diff) | |
| download | forums-405efb48e0542398f22711bcbe0a7733655e3462.tar forums-405efb48e0542398f22711bcbe0a7733655e3462.tar.gz forums-405efb48e0542398f22711bcbe0a7733655e3462.tar.bz2 forums-405efb48e0542398f22711bcbe0a7733655e3462.tar.xz forums-405efb48e0542398f22711bcbe0a7733655e3462.zip | |
Various updates, mods, changes to several functions, moved smilies stuff to bbcode.php ... nathan may kill me ... good bye all in advance
git-svn-id: file:///svn/phpbb/trunk@2063 89ea8834-ac86-4346-8a33-228a782c2dd0
Diffstat (limited to 'phpBB/includes/bbcode.php')
| -rw-r--r-- | phpBB/includes/bbcode.php | 54 |
1 files changed, 53 insertions, 1 deletions
diff --git a/phpBB/includes/bbcode.php b/phpBB/includes/bbcode.php index fc0fe4beef..ea0d6b2437 100644 --- a/phpBB/includes/bbcode.php +++ b/phpBB/includes/bbcode.php @@ -713,4 +713,56 @@ function bbcode_array_pop(&$stack) return($return_val); } -?> +// +// 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) +{ + global $db, $board_config; + static $smilies; + + if( empty($smilies) ) + { + $sql = "SELECT code, smile_url + FROM " . SMILIES_TABLE; + if( !$result = $db->sql_query($sql) ) + { + message_die(GENERAL_ERROR, "Couldn't obtain smilies data", "", __LINE__, __FILE__, $sql); + } + + if( !$db->sql_numrows($result) ) + { + return $message; + } + + $smilies = $db->sql_fetchrowset($result); + } + + 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="'. $board_config['smilies_path'] . '/' . $smilies[$i]['smile_url'] . '" alt="' . $smilies[$i]['smile_url'] . '" border="0">'; + } + + if( $i > 0 ) + { + $message = preg_replace($orig, $repl, ' ' . $message . ' '); + $message = substr($message, 1, -1); + } + + return $message; +} + +function smiley_sort($a, $b) +{ + if ( strlen($a['code']) == strlen($b['code']) ) + { + return 0; + } + + return ( strlen($a['code']) > strlen($b['code']) ) ? -1 : 1; +} + +?>
\ No newline at end of file |
