From 1c98913f62ed01c1e2af771b9a1ee94aa0e4956e Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 8 May 2016 08:59:54 -0700 Subject: [PATCH] Fix for texts containing only one emoticon. Cleanup of some debug reporting. --- e107_handlers/e107_class.php | 20 ++++++++++++++------ e107_handlers/e_parse_class.php | 30 +++++++++++++++++------------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index 899dd0257..d798d32d2 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -4376,7 +4376,8 @@ class e107 if(null === self::$_instance) return; $print = defined('E107_DBG_TIMEDETAILS') && E107_DBG_TIMEDETAILS; - !$print || print('Destructing $e107:
'); + + !$print || print(''); $vars = get_object_vars($this); foreach ($vars as $name => $value) { @@ -4384,10 +4385,10 @@ class e107 { if(method_exists($value, '__destruct')) { - !$print || print('object [property] using __destruct(): '.$path.' - '.get_class($value).'
'); + !$print || print(''); $value->__destruct(); } - else !$print || print('object [property]: '.$name.' - '.get_class($value).'
'); + else !$print || print(''); $this->$name = null; } } @@ -4397,14 +4398,21 @@ class e107 { if(method_exists($reg, '__destruct')) { - !$print || print('object [registry] using __destruct(): '.$path.' - '.get_class($reg).'
'); + !$print || print(''); $reg->__destruct(); } - else !$print || print('object [registry]: '.$path.' - '.get_class($reg).'
'); + else !$print || print(''); unset(self::$_registry[$path]); } - + + } + + if($print) + { + echo "
Destructing $e107
object [property] using __destruct()'.$name.''.get_class($value).'
object [property]'.$name.''.get_class($value).'
object [registry] using __destruct()'.$path.''.get_class($reg).'
object [registry]'.$path.''.get_class($reg).'
"; + } + self::$_registry = null; self::$_instance = null; } diff --git a/e107_handlers/e_parse_class.php b/e107_handlers/e_parse_class.php index 15199c23a..fc62238af 100644 --- a/e107_handlers/e_parse_class.php +++ b/e107_handlers/e_parse_class.php @@ -4620,6 +4620,8 @@ class e_emotefilter private $search; private $replace; public $emotes; + private $singleSearch; + private $singleReplace; function __construct() { @@ -4666,8 +4668,6 @@ class e_emotefilter foreach($tmp as $code) { $img = "\"".$alt."\""; - // $this->regSearch[] = "#(^|[\s>])(".$this->buildRegex($code).")($|[\s<])#"; - // $this->regReplace[] ="$1".$img."$3"; $this->search[] = "\n".$code; $this->replace[] = "\n".$img; @@ -4678,8 +4678,9 @@ class e_emotefilter $this->search[] = ">".$code; // Fix for emote within html. $this->replace[] = ">".$img; - // $this->search[] = $code."<"; // Fix for emote within html. - // $this->replace[] = $img."<"; + $this->singleSearch[] = $code; + $this->singleReplace[] = $img; + } @@ -4723,19 +4724,22 @@ class e_emotefilter } - private function buildRegex($code) - { - - $code = quotemeta($code); - $code = str_replace('|','\|',$code); - return $code; - } - function filterEmotes($text) { - // return preg_replace($this->regSearch,$this->regReplace,$text); + + if(empty($text)) + { + return ''; + } + + if((strlen($text) < 12) && in_array($text, $this->singleSearch)) // just one emoticon with no space, line-break or html tags around it. + { + return str_replace($this->singleSearch,$this->singleReplace,$text); + } + return str_replace($this->search, $this->replace, $text); + }