summary refs log tree commit diff stats
path: root/includes/bbcode.php
diff options
context:
space:
mode:
authorStarla Insigna <hatkirby@fourisland.com>2009-08-09 09:14:58 -0400
committerStarla Insigna <hatkirby@fourisland.com>2009-08-09 09:14:58 -0400
commit893957c41481a0cd5eb624096337762ffa54ff28 (patch)
tree09d2487f8add5a6281e3482a471abf21faa4f819 /includes/bbcode.php
parentd27a3784c81f0c582e43655509e806978b7e65e4 (diff)
downloadfourisland-893957c41481a0cd5eb624096337762ffa54ff28.tar.gz
fourisland-893957c41481a0cd5eb624096337762ffa54ff28.tar.bz2
fourisland-893957c41481a0cd5eb624096337762ffa54ff28.zip
Created layout 7
The following changes were also made in this revision:

* All HTML was changed to XHTML and a !DOCTYPE was included to reflect this
* Rewrote quotes tracking system to be much less complicated and actually working
* Changed quotes rendering to look more like Chirpy than Rash
* Fixed comment textarea bug
* Rewrote a ton of CSS so it's not as bloated
* Added a JavaScript confirmation when deleting a comment
* AJAXified voting on the POTW
* AJAXified voting and flagging quotes
* AJAXified commenting
* AJAXified voting on posts
* Added DateFinder back after it was accidentally deleted in Layout 4.5

The following database changes must be performed as soon as possible:

* Fix title of NO <!DOCTYPE> post (the &lt; is missing the semicolon)
* Restore post Frasty Tha Snaman from a backup
* Reset "flag" field of all rows in "rash_quotes" to 0
* Remove the "vote" and "flag" columns of "rash_tracking"
* Rename the "quote_id" column of "rash_tracking" to "vote"

The following external code changes must also be performed as soon as possible:

* Add the following line to the end of the // Four Island block in The Fourm's functions.php:
  require('/svr/www/hatkirby/fourisland/main/includes/specialdates.php');
Diffstat (limited to 'includes/bbcode.php')
-rwxr-xr-xincludes/bbcode.php66
1 files changed, 38 insertions, 28 deletions
diff --git a/includes/bbcode.php b/includes/bbcode.php index af0b1a4..b116e7a 100755 --- a/includes/bbcode.php +++ b/includes/bbcode.php
@@ -30,30 +30,33 @@ class BBCode
30 30
31 function init() 31 function init()
32 { 32 {
33 $this->bbcodes['b'] = '<B>{CONTENT}</B>'; 33 $this->bbcodes['b'] = '<strong>{CONTENT}</strong>';
34 $this->bbcodes['i'] = '<I>{CONTENT}</I>'; 34 $this->bbcodes['i'] = '<em>{CONTENT}</em>';
35 $this->bbcodes['u'] = '<U>{CONTENT}</U>'; 35 $this->bbcodes['u'] = '<u>{CONTENT}</u>';
36 $this->bbcodes['url'] = '<A HREF="{CONTENT}">{CONTENT}</A>'; 36 $this->bbcodes['url'] = '<a href="{CONTENT}">{CONTENT}</a>';
37 $this->bbcodes2['url'] = '<A HREF="{PARAM}">{CONTENT}</A>'; 37 $this->bbcodes2['url'] = '<a href="{PARAM}">{CONTENT}</a>';
38 $this->bbcodes['img'] = '<IMG SRC="{CONTENT}" ALT="Image">'; 38 $this->bbcodes['img'] = '<img src="{CONTENT}" alt="Image" />';
39 $this->bbcodes2['img'] = '<IMG SRC="{CONTENT}" ALT="{PARAM}" TITLE="{PARAM}">'; 39 $this->bbcodes2['img'] = '<img src="{CONTENT}" alt="{PARAM}" title="{PARAM}" />';
40 $this->bbcodes['big'] = '<BIG>{CONTENT}</BIG>'; 40 $this->bbcodes['big'] = '<big>{CONTENT}</big>';
41 $this->bbcodes['small'] = '<SMALL>{CONTENT}</SMALL>'; 41 $this->bbcodes['small'] = '<small>{CONTENT}</small>';
42 $this->bbcodes['ul'] = '<UL>{CONTENT}</UL>'; 42 $this->bbcodes['ul'] = '<ul>{CONTENT}</ul>';
43 $this->bbcodes['ol'] = '<OL>{CONTENT}</OL>'; 43 $this->bbcodes['ol'] = '<ol>{CONTENT}</ol>';
44 $this->bbcodes['li'] = '<LI>{CONTENT}</LI>'; 44 $this->bbcodes['li'] = '<li>{CONTENT}</li>';
45 $this->bbcodes['code'] = '<CODE>{CONTENT}</CODE>'; 45 $this->bbcodes['code'] = '<code>{CONTENT}</code>';
46 $this->bbcodes['pre'] = '<P><DIV CLASS="autosize"><DIV CLASS="bubble"><DIV CLASS="bquote"><BLOCKQUOTE><DIV><CODE>{CONTENT}</CODE></DIV></BLOCKQUOTE></DIV></DIV></DIV><DIV CLASS="cleardiv"></DIV>'; 46 $this->bbcodes['pre'] = '<pre><code>{CONTENT}</code></pre>';
47 $this->bbcodes2['blog'] = '<A HREF="/blog/{PARAM}/">{CONTENT}</A>'; 47 $this->bbcodes['pref'] = '<pre>{CONTENT}</pre>';
48 $this->bbcodes2['quote'] = '<A HREF="/quotes/{PARAM}.php">{CONTENT}</A>'; 48 $this->bbcodes2['blog'] = '<a href="/blog/{PARAM}/">{CONTENT}</a>';
49 $this->bbcodes['ins'] = '<INS>{CONTENT}</INS>'; 49 $this->bbcodes['quote'] = '<a href="/quotes/{CONTENT}.php">#{CONTENT}</a>';
50 $this->bbcodes['del'] = '<DEL>{CONTENT}</DEL>'; 50 $this->bbcodes2['quote'] = '<a href="/quotes/{PARAM}.php">{CONTENT}</a>';
51 $this->bbcodes['bquote'] = '<P><DIV CLASS="autosize"><DIV CLASS="bubble"><DIV CLASS="bquote"><BLOCKQUOTE><DIV>{CONTENT}</DIV></BLOCKQUOTE></DIV><CITE><STRONG>Anonymous</STRONG></CITE></DIV></DIV><DIV CLASS="cleardiv"></DIV>'; 51 $this->bbcodes['ins'] = '<ins>{CONTENT}</ins>';
52 $this->bbcodes2['bquote'] = '<P><DIV CLASS="autosize"><DIV CLASS="bubble"><DIV CLASS="bquote"><BLOCKQUOTE><DIV>{CONTENT}</DIV></BLOCKQUOTE></DIV><CITE><STRONG>{PARAM}</STRONG></CITE></DIV></DIV><DIV CLASS="cleardiv"></DIV>'; 52 $this->bbcodes['del'] = '<del>{CONTENT}</del>';
53 $this->bbcodes2['abbr'] = '<ABBR TITLE="{PARAM}">{CONTENT}</ABBR>'; 53 $this->bbcodes['bquote'] = '<div class="bquote module unrounded"><blockquote>{CONTENT}</blockquote></div><cite><strong>Anonymous</strong></cite><div class="cleardiv"></div>';
54 $this->bbcodes['hidden'] = '<SPAN STYLE="display: none">{CONTENT}</SPAN>'; 54 $this->bbcodes2['bquote'] = '<div class="bquote module unrounded"><blockquote>{CONTENT}</blockquote></div><cite><strong>{PARAM}</strong></cite><div class="cleardiv"></div>';
55 $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>'; 55 $this->bbcodes2['abbr'] = '<abbr title="{PARAM}">{CONTENT}</abbr>';
56 $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>'; 56 $this->bbcodes['hidden'] = '<span style="display: none">{CONTENT}</span>';
57 $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['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['project'] = '<a href="http://projects.fourisland.com/projects/show/{CONTENT}">{CONTENT}</a>';
57 60
58 $this->init = true; 61 $this->init = true;
59 } 62 }
@@ -73,8 +76,15 @@ class BBCode
73 { 76 {
74 $bbcode_uid = unique_id(); 77 $bbcode_uid = unique_id();
75 $bbpos = strpos($to_parse, '[' . $name . ']'); 78 $bbpos = strpos($to_parse, '[' . $name . ']');
76 $to_parse = substr_replace($to_parse, '[' . $name . ':' . $bbcode_uid . ']', $bbpos, strlen($name) + 2); 79 $otag = '[' . $name . ':' . $bbcode_uid . ']';
77 $to_parse = substr_replace($to_parse, '[/' . $name . ':' . $bbcode_uid . ']', strpos(substr($to_parse, $bbpos), '[/' . $name . ']') + $bbpos, strlen($name) + 3); 80 $ctag = '[/' . $name . ':' . $bbcode_uid . ']';
81 $to_parse = substr_replace($to_parse, $otag, $bbpos, strlen($name) + 2);
82 $to_parse = substr_replace($to_parse, $ctag, strpos(substr($to_parse, $bbpos), '[/' . $name . ']') + $bbpos, strlen($name) + 3);
83
84 if (strpos($this->bbcodes[$name], '<pre>') !== -1)
85 {
86 $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)));
87 }
78 88
79 $value = str_replace('{CONTENT}', '\1', $value); 89 $value = str_replace('{CONTENT}', '\1', $value);
80 $to_parse = preg_replace('/\[' . $name . ':' . $bbcode_uid . '\](.*)\[\/' . $name . ':' . $bbcode_uid . '\]/', $value, $to_parse); 90 $to_parse = preg_replace('/\[' . $name . ':' . $bbcode_uid . '\](.*)\[\/' . $name . ':' . $bbcode_uid . '\]/', $value, $to_parse);
@@ -96,13 +106,13 @@ class BBCode
96 } 106 }
97 } 107 }
98 108
99 return str_replace('[br]','<BR>',$to_parse); 109 return str_replace('[br]','<br />',$to_parse);
100 } 110 }
101} 111}
102 112
103function parseBBCode($text) 113function parseBBCode($text)
104{ 114{
105 global $bbcode; 115 static $bbcode;
106 if (!isset($bbcode)) 116 if (!isset($bbcode))
107 { 117 {
108 $bbcode = new BBCode(); 118 $bbcode = new BBCode();