summary refs log tree commit diff stats
path: root/includes
diff options
context:
space:
mode:
authorStarla Insigna <starla4444@gmail.com>2010-10-15 19:21:59 -0400
committerStarla Insigna <starla4444@gmail.com>2010-10-15 19:21:59 -0400
commit05fef4cd88030e04f233b332a8e32057fb57d5e4 (patch)
treeacbba15de8db693961dbfe1c08a6611593e4497e /includes
parent16e9aedc756003c2ab6fb6ee2d8842c5e7384aa7 (diff)
downloadfourisland-05fef4cd88030e04f233b332a8e32057fb57d5e4.tar.gz
fourisland-05fef4cd88030e04f233b332a8e32057fb57d5e4.tar.bz2
fourisland-05fef4cd88030e04f233b332a8e32057fb57d5e4.zip
Backported [nosmilies] from Layout 8
Diffstat (limited to 'includes')
-rwxr-xr-xincludes/bbcode.php10
-rwxr-xr-xincludes/parsers.php3
-rwxr-xr-xincludes/smilies.php35
3 files changed, 41 insertions, 7 deletions
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
58 $this->bbcodes['thumb'] = '<a href="/images/{CONTENT}"><img src="http://fourisland.com/thumb.php?file=images/{CONTENT}&amp;mode=scale&amp;by=521&amp;side=0" alt="Image" /></a>'; 58 $this->bbcodes['thumb'] = '<a href="/images/{CONTENT}"><img src="http://fourisland.com/thumb.php?file=images/{CONTENT}&amp;mode=scale&amp;by=521&amp;side=0" alt="Image" /></a>';
59 $this->bbcodes['thumb2'] = '<a href="/images/{CONTENT}"><img src="http://fourisland.com/thumb.php?file=images/{CONTENT}&amp;mode=scale&amp;by=260&amp;side=0" align="right" alt="Image" /></a>'; 59 $this->bbcodes['thumb2'] = '<a href="/images/{CONTENT}"><img src="http://fourisland.com/thumb.php?file=images/{CONTENT}&amp;mode=scale&amp;by=260&amp;side=0" align="right" alt="Image" /></a>';
60 $this->bbcodes['thumb3'] = '<a href="/images/{CONTENT}"><img src="http://fourisland.com/thumb.php?file=images/{CONTENT}&amp;mode=scale&amp;by=260&amp;side=0" align="left" style="margin-right: 2em" alt="Image" /></a>'; 60 $this->bbcodes['thumb3'] = '<a href="/images/{CONTENT}"><img src="http://fourisland.com/thumb.php?file=images/{CONTENT}&amp;mode=scale&amp;by=260&amp;side=0" align="left" style="margin-right: 2em" alt="Image" /></a>';
61 $this->bbcodes['project'] = '<a href="http://projects.fourisland.com/projects/show/{CONTENT}">{CONTENT}</a>'; 61 $this->bbcodes['project'] = '<a href="http://projects.fourisland.com/projects/show/{CONTENT}">{CONTENT}</a>';
62 $this->bbcodes['hr'] = '<hr size="2" color="black" />'; 62 $this->bbcodes['hr'] = '<hr size="2" color="black" />';
63 $this->bbcodes2['audio'] = '<p id="audioplayer_{CONTENT}">Click to download: <a href="{PARAM}">{CONTENT}</a></p><script>AudioPlayer.embed("audioplayer_{CONTENT}", {soundFile: "{PARAM}", titles: "{CONTENT}"});</script>'; 63 $this->bbcodes2['audio'] = '<p id="audioplayer_{CONTENT}">Click to download: <a href="{PARAM}">{CONTENT}</a></p><script>AudioPlayer.embed("audioplayer_{CONTENT}", {soundFile: "{PARAM}", titles: "{CONTENT}"});</script>';
64 $this->bbcodes['nosmilies'] = '{CONTENT}';
64 65
65 $this->init = true; 66 $this->init = true;
66 } 67 }
@@ -85,11 +86,16 @@ class BBCode
85 $to_parse = substr_replace($to_parse, $otag, $bbpos, strlen($name) + 2); 86 $to_parse = substr_replace($to_parse, $otag, $bbpos, strlen($name) + 2);
86 $to_parse = substr_replace($to_parse, $ctag, strpos(substr($to_parse, $bbpos), '[/' . $name . ']') + $bbpos, strlen($name) + 3); 87 $to_parse = substr_replace($to_parse, $ctag, strpos(substr($to_parse, $bbpos), '[/' . $name . ']') + $bbpos, strlen($name) + 3);
87 88
88 if (strpos($this->bbcodes[$name], '<pre>') !== -1) 89 if (strpos($this->bbcodes[$name], '<pre>') !== FALSE)
89 { 90 {
90 $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))); 91 $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)));
91 } 92 }
92 93
94 if ($name == 'nosmilies')
95 {
96 $to_parse = preg_replace('/\[emoticon\](..)\[\/emoticon\]/', '\1', $to_parse);
97 }
98
93 $value = str_replace('{CONTENT}', '\1', $value); 99 $value = str_replace('{CONTENT}', '\1', $value);
94 $to_parse = preg_replace('/\[' . $name . ':' . $bbcode_uid . '\](.*)\[\/' . $name . ':' . $bbcode_uid . '\]/', $value, $to_parse); 100 $to_parse = preg_replace('/\[' . $name . ':' . $bbcode_uid . '\](.*)\[\/' . $name . ':' . $bbcode_uid . '\]/', $value, $to_parse);
95 } 101 }
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');
28function parseText($text) 28function parseText($text)
29{ 29{
30 $text = htmlspecialchars($text); 30 $text = htmlspecialchars($text);
31 $text = parseSmiliesFirstPass($text);
31 $text = parseBBCode($text); 32 $text = parseBBCode($text);
32 $text = parseSmilies($text); 33 $text = parseSmiliesSecondPass($text);
33 $text = doAprilFoolsDay($text); 34 $text = doAprilFoolsDay($text);
34 35
35 return $text; 36 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
37 $this->init = true; 37 $this->init = true;
38 } 38 }
39 39
40 function parseSmilies($text) 40 function parseSmiliesFirstPass($text)
41 { 41 {
42 if (!$this->init) 42 if (!$this->init)
43 { 43 {
@@ -46,14 +46,29 @@ class Smilies
46 46
47 foreach ($this->smilies as $name => $value) 47 foreach ($this->smilies as $name => $value)
48 { 48 {
49 $text = str_replace($name, '<img src="http://fourisland.com/theme/images/smilies/' . $value . '" alt="' . $name . '" />', $text); 49 $text = str_replace($name, '[emoticon]' . $name . '[/emoticon]', $text);
50 }
51
52 return $text;
53 }
54
55 function parseSmiliesSecondPass($text)
56 {
57 if (!$this->init)
58 {
59 $this->init();
60 }
61
62 foreach ($this->smilies as $name => $value)
63 {
64 $text = str_replace('[emoticon]' . $name . '[/emoticon]', '<img src="/theme/images/smilies/' . $value . '" alt="' . $name . '" />', $text);
50 } 65 }
51 66
52 return $text; 67 return $text;
53 } 68 }
54} 69}
55 70
56function parseSmilies($text) 71function parseSmiliesFirstPass($text)
57{ 72{
58 global $smilies; 73 global $smilies;
59 if (!isset($smilies)) 74 if (!isset($smilies))
@@ -61,7 +76,19 @@ function parseSmilies($text)
61 $smilies = new Smilies(); 76 $smilies = new Smilies();
62 } 77 }
63 78
64 return $smilies->parseSmilies($text); 79 return $smilies->parseSmiliesFirstPass($text);
65} 80}
66 81
82function parseSmiliesSecondPass($text)
83{
84 global $smilies;
85 if (!isset($smilies))
86 {
87 $smilies = new Smilies();
88 }
89
90 return $smilies->parseSmiliesSecondPass($text);
91}
92
93
67?> 94?>