class Smilies {
+ /**
+ * @brief Replaces/adds the emoticon list
+ *
+ * This function should be used whenever emoticons are added
+ *
+ * @param array $b Array of emoticons
+ * @param string $smiley The text smilie
+ * @param string $representation The replacement
+ */
+ public static function add(&$b, $smiley, $representation) {
+ $found = array_search($smiley, $b['texts']);
+
+ if (!is_int($found)) {
+ $b['texts'][] = $smiley;
+ $b['icons'][] = $representation;
+ } else {
+ $b['icons'][$found] = $representation;
+ }
+ }
+
/**
* @brief Function to list all smilies
*
call_hooks('smilie', $params);
return $params;
-
}
/**
* function from being executed by the prepare_text() routine when preparing
* bbcode source for HTML display
*
- * @param string $s
+ * @param string $s Text that should be replaced
* @param boolean $sample
+ * @param boolean $no_images Only replace emoticons without images
*
* @return string HML Output of the Smilie
*/
- public static function replace($s, $sample = false) {
+ public static function replace($s, $sample = false, $no_images = false) {
if(intval(get_config('system','no_smilies'))
|| (local_user() && intval(get_pconfig(local_user(),'system','no_smilies'))))
return $s;
$s = preg_replace_callback('/<code>(.*?)<\/code>/ism','self::encode',$s);
$params = self::get_list();
+
+ if ($no_images) {
+ $cleaned = array('texts' => array(), 'icons' => array());
+ $icons = $params['icons'];
+ foreach ($icons AS $key => $icon) {
+ if (!strstr($icon, '<img ')) {
+ $cleaned['texts'][] = $params['texts'][$key];
+ $cleaned['icons'][] = $params['icons'][$key];
+ }
+ }
+ $params = $cleaned;
+ }
+
$params['string'] = $s;
if($sample) {
$r = str_replace($x[0],$t,$x[0]);
return $r;
}
-
}
require_once 'mod/proxy.php';
require_once 'include/Contact.php';
require_once 'include/plaintext.php';
+require_once 'include/Smilies.php';
function bb_PictureCacheExt($matches) {
if (strpos($matches[3], "data:image/") === 0) {
$Text = preg_replace("/\[event\-id\](.*?)\[\/event\-id\]/ism", '', $Text);
}
+ // Replace non graphical smilies for external posts
+ if ($simplehtml) {
+ $Text = Smilies::replace($Text, false, true);
+ }
// Replace inline code blocks
$Text = preg_replace_callback("|(?!<br[^>]*>)<code>([^<]*)</code>(?!<br[^>]*>)|ism",