From bd56abb1e531d1122a0719b2108ed38e2d8c7327 Mon Sep 17 00:00:00 2001 From: admin Date: Sat, 28 Oct 2006 18:00:37 +0000 Subject: --- system/helpers/smiley_helper.php | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'system/helpers') diff --git a/system/helpers/smiley_helper.php b/system/helpers/smiley_helper.php index 05ffb29b2..0f426d609 100644 --- a/system/helpers/smiley_helper.php +++ b/system/helpers/smiley_helper.php @@ -22,7 +22,7 @@ * @subpackage Helpers * @category Helpers * @author Rick Ellis - * @link http://www.codeigniter.com/user_guide/helpers/download_helper.html + * @link http://www.codeigniter.com/user_guide/helpers/smiley_helper.html */ // ------------------------------------------------------------------------ @@ -61,12 +61,15 @@ EOF; * @param string the URL to the folder containing the smiley images * @return array */ -function get_clickable_smileys($image_url = '') +function get_clickable_smileys($image_url = '', $smileys = NULL) { - if (FALSE === ($smileys = _get_smiley_array())) + if ( ! is_array($smileys)) { - return array(); - } + if (FALSE === ($smileys = _get_smiley_array())) + { + return $str; + } + } // Add a trailing slash to the file path if needed $image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url); @@ -78,14 +81,14 @@ function get_clickable_smileys($image_url = '') // mapping array contains multiple identical replacements. For example: // :-) and :) might be replaced with the same image so both smileys // will be in the array. - if (isset($used[$smileys[$key]['0']])) + if (isset($used[$smileys[$key][0]])) { continue; } - $link[] = "\"".$smileys[$key]['3']."\""; + $link[] = "\"".$smileys[$key][3]."\""; - $used[$smileys[$key]['0']] = TRUE; + $used[$smileys[$key][0]] = TRUE; } return $link; @@ -103,19 +106,27 @@ function get_clickable_smileys($image_url = '') * @param string the URL to the folder containing the smiley images * @return string */ -function parse_smileys($str, $image_url) +function parse_smileys($str = '', $image_url = '', $smileys = NULL) { - if (FALSE === ($smileys = _get_smiley_array())) + if ($image_url == '') { return $str; - } + } + if ( ! is_array($smileys)) + { + if (FALSE === ($smileys = _get_smiley_array())) + { + return $str; + } + } + // Add a trailing slash to the file path if needed $image_url = preg_replace("/(.+?)\/*$/", "\\1/", $image_url); foreach ($smileys as $key => $val) { - $str = str_replace($key, "\"".$smileys[$key]['3']."\"", $str); + $str = str_replace($key, "\"".$smileys[$key][3]."\"", $str); } return $str; -- cgit v1.2.3-24-g4f1b