From 05fef4cd88030e04f233b332a8e32057fb57d5e4 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Fri, 15 Oct 2010 19:21:59 -0400 Subject: Backported [nosmilies] from Layout 8 --- includes/bbcode.php | 10 ++++++++-- includes/parsers.php | 3 ++- includes/smilies.php | 35 +++++++++++++++++++++++++++++++---- 3 files changed, 41 insertions(+), 7 deletions(-) (limited to 'includes') diff --git a/includes/bbcode.php b/includes/bbcode.php index a7bb247..b83e403 100755 --- a/includes/bbcode.php +++ b/includes/bbcode.php @@ -58,9 +58,10 @@ class BBCode $this->bbcodes['thumb'] = 'Image'; $this->bbcodes['thumb2'] = 'Image'; $this->bbcodes['thumb3'] = 'Image'; - $this->bbcodes['project'] = '{CONTENT}'; + $this->bbcodes['project'] = '{CONTENT}'; $this->bbcodes['hr'] = '
'; $this->bbcodes2['audio'] = '

Click to download: {CONTENT}

'; + $this->bbcodes['nosmilies'] = '{CONTENT}'; $this->init = true; } @@ -85,11 +86,16 @@ class BBCode $to_parse = substr_replace($to_parse, $otag, $bbpos, strlen($name) + 2); $to_parse = substr_replace($to_parse, $ctag, strpos(substr($to_parse, $bbpos), '[/' . $name . ']') + $bbpos, strlen($name) + 3); - if (strpos($this->bbcodes[$name], '
') !== -1)
+				if (strpos($this->bbcodes[$name], '
') !== FALSE)
 				{
 					$to_parse = substr_replace($to_parse, str_replace('[br]', '', substr($to_parse, strpos($to_parse, $otag) + strlen($otag), strpos($to_parse, $ctag) - (strpos($to_parse, $otag) + strlen($otag)))), strpos($to_parse, $otag) + strlen($otag), strpos($to_parse, $ctag) - (strpos($to_parse, $otag) + strlen($otag)));
 				}
 
+				if ($name == 'nosmilies')
+				{
+					$to_parse = preg_replace('/\[emoticon\](..)\[\/emoticon\]/', '\1', $to_parse);
+				}
+
 				$value = str_replace('{CONTENT}', '\1', $value);
 				$to_parse = preg_replace('/\[' . $name . ':' . $bbcode_uid . '\](.*)\[\/' . $name . ':' . $bbcode_uid . '\]/', $value, $to_parse);
 			}
diff --git a/includes/parsers.php b/includes/parsers.php
index 86284af..a57561d 100755
--- a/includes/parsers.php
+++ b/includes/parsers.php
@@ -28,8 +28,9 @@ include('includes/smilies.php');
 function parseText($text)
 {
 	$text = htmlspecialchars($text);
+	$text = parseSmiliesFirstPass($text);
 	$text = parseBBCode($text);
-	$text = parseSmilies($text);
+	$text = parseSmiliesSecondPass($text);
 	$text = doAprilFoolsDay($text);
 
 	return $text;
diff --git a/includes/smilies.php b/includes/smilies.php
index f9ffde8..e189ad6 100755
--- a/includes/smilies.php
+++ b/includes/smilies.php
@@ -37,7 +37,7 @@ class Smilies
 		$this->init = true;
 	}
 
-	function parseSmilies($text)
+	function parseSmiliesFirstPass($text)
 	{
 		if (!$this->init)
 		{
@@ -46,14 +46,29 @@ class Smilies
 
 		foreach ($this->smilies as $name => $value)
 		{
-			$text = str_replace($name, '' . $name . '', $text);
+			$text = str_replace($name, '[emoticon]' . $name . '[/emoticon]', $text);
+		}
+
+		return $text;
+	}
+
+	function parseSmiliesSecondPass($text)
+	{
+		if (!$this->init)
+		{
+			$this->init();
+		}
+
+		foreach ($this->smilies as $name => $value)
+		{
+			$text = str_replace('[emoticon]' . $name . '[/emoticon]', '' . $name . '', $text);
 		}
 
 		return $text;
 	}
 }
 
-function parseSmilies($text)
+function parseSmiliesFirstPass($text)
 {
 	global $smilies;
 	if (!isset($smilies))
@@ -61,7 +76,19 @@ function parseSmilies($text)
 		$smilies = new Smilies();
 	}
 
-	return $smilies->parseSmilies($text);
+	return $smilies->parseSmiliesFirstPass($text);
 }
 
+function parseSmiliesSecondPass($text)
+{
+	global $smilies;
+	if (!isset($smilies))
+	{
+		$smilies = new Smilies();
+	}
+
+	return $smilies->parseSmiliesSecondPass($text);
+}
+
+
 ?>
-- 
cgit 1.4.1