diff --git a/checkin_notes b/checkin_notes index d82eabf332..9c783701f5 100755 --- a/checkin_notes +++ b/checkin_notes @@ -4657,3 +4657,12 @@ David 9 May 2007 sched/ sched_send.C server_types.h + +Rytis 9 May 2007 + - Update BBCode to allow easy linking to Trac tickets, wiki and changesets. + + html/ + user/ + bbcode.php + inc/ + text_transform.inc diff --git a/html/inc/text_transform.inc b/html/inc/text_transform.inc index 05026129a7..a64a1a5f18 100644 --- a/html/inc/text_transform.inc +++ b/html/inc/text_transform.inc @@ -117,73 +117,77 @@ function get_transform_settings_from_user($user, $options = '') { * Converts bbcode to proper HTML **/ function bb2html($text) { - $urlregex = "(?:\"?)(?:(http\:\/\/)?)([^\[\"<\ ]+)(?:\"?)"; - $httpsregex = "(?:\"?)https\:\/\/([^\[\"<\ ]+)(?:\"?)"; - // List of allowable tags - $bbtags = array ( - "@\[b\](.*?)\[/b\]@is", - "@\[i\](.*?)\[/i\]@is", - "@\[u\](.*?)\[/u\]@is", - "@\[url=$httpsregex\](.*?)\[/url\]@i", - "@\[url\]$httpsregex\[/url\]@i", - "@\[link=$urlregex\](.*?)\[/link\]@i", - "@\[link\]$urlregex\[/link\]@i", - "@\[url=$urlregex\](.*?)\[/url\]@i", - "@\[url\]$urlregex\[/url\]@i", - "@\[quote=(.*?)\](.*?)\[/quote\]@is", - "@\[quote\](.*?)\[/quote\]@is", - "@\[font=(.*?)\](.*?)\[/font\]@is", + $urlregex = "(?:\"?)(?:(http\:\/\/)?)([^\[\"<\ ]+)(?:\"?)"; + $httpsregex = "(?:\"?)https\:\/\/([^\[\"<\ ]+)(?:\"?)"; + // List of allowable tags + $bbtags = array ( + "@\[b\](.*?)\[/b\]@is", + "@\[i\](.*?)\[/i\]@is", + "@\[u\](.*?)\[/u\]@is", + "@\[url=$httpsregex\](.*?)\[/url\]@i", + "@\[url\]$httpsregex\[/url\]@i", + "@\[link=$urlregex\](.*?)\[/link\]@i", + "@\[link\]$urlregex\[/link\]@i", + "@\[url=$urlregex\](.*?)\[/url\]@i", + "@\[url\]$urlregex\[/url\]@i", + "@\[quote=(.*?)\](.*?)\[/quote\]@is", + "@\[quote\](.*?)\[/quote\]@is", "@\[list\](.*?)\[/list\]@is", "@\[list=1\](.*?)\[/list\]@is", - "@\[pre\](.*?)\[/pre\]@is", - "@\[img\]$urlregex\[/img\]@is", - "@\[color=(?:\"?)(.{3,8})(?:\"?)\](.*?)\[/color\]@is", - "@((?:
    |
|))@is", - "@\[size=([1-9]|[0-2][0-9])\](.*?)\[/size\]@is", - "@\[code\](.*?)\[/code\]@is", - "@\[mailto\](.*?)\[/mailto\]@is", - "@\[email\](.*?)\[/email\]@is" - //Note: The above list array member ensures we're within a list - // when doing list item transformations. - //TODO: Make sure we're not between two lists - ); - - // What the above tags are turned in to - $htmltags = array ( - "\\1", - "\\1", - "\\1", - "\\2", - "https://\\1", - "\\3", - "http://\\2", - "\\3", - "http://\\2", + "@\[pre\](.*?)\[/pre\]@is", + "@\[img\]$urlregex\[/img\]@is", + "@\[color=(?:\"?)(.{3,8})(?:\"?)\](.*?)\[/color\]@is", + "@((?:
    |
|))@is", + "@\[size=([1-9]|[0-2][0-9])\](.*?)\[/size\]@is", + "@\[code\](.*?)\[/code\]@is", + "@\[mailto\](.*?)\[/mailto\]@is", + "@\[email\](.*?)\[/email\]@is", + "@\[trac\](?:\#|ticket:)(\d+)\[/trac\]@is", + "@\[trac\]wiki:(.*?)\[/trac\]@is", + "@\[trac\]changeset:(\d+)\[/trac\]@is" + //Note: The above list array member ensures we're within a list + //when doing list item transformations. + //TODO: Make sure we're not between two lists + ); + + // What the above tags are turned in to + $htmltags = array ( + "\\1", + "\\1", + "\\1", + "\\2", + "https://\\1", + "\\3", + "http://\\2", + "\\3", + "http://\\2", "
\\1 wrote:
\\2
", "
\\1
", - "\\2", - "

", - "

    \\1

", - "

\\1
", - "", - "\\2", - "\\1
  • \\2
  • \n\\3", - "\\2", - "
    \\1
    ", - "\\1", - "\\1" - ); - - // Do the actual replacing - iterations for nested items - $lasttext = ""; - $i = 0; - // $i<10 to prevent DoS - while ($text != $lasttext && $i<20) { - $lasttext = $text; - $text = preg_replace($bbtags,$htmltags,$text); - $i = $i + 1; - } - return $text; + "

    ", + "

      \\1

    ", + "

    \\1
    ", + "", + "\\2", + "\\1
  • \\2
  • \n\\3", + "\\2", + "
    \\1
    ", + "\\1", + "\\1", + "#\\1", + "\\1", + "[\\1]" + ); + + // Do the actual replacing - iterations for nested items + $lasttext = ""; + $i = 0; + // $i<20 to prevent DoS + while ($text != $lasttext && $i<20) { + $lasttext = $text; + $text = preg_replace($bbtags,$htmltags,$text); + $i = $i + 1; + } + return $text; } /** diff --git a/html/user/bbcode.php b/html/user/bbcode.php index 653d7bfc24..5897908789 100644 --- a/html/user/bbcode.php +++ b/html/user/bbcode.php @@ -2,34 +2,34 @@ require_once("../inc/util.inc"); page_head("BBCode tags"); -echo " - -

    +echo "

    BBCode tags let you format text in your profile and message-board postings. -It's similar to HTML, but simpler. -The tags start with a [ (where you would have used < in HTML) -and end with ] -(where you would have used > in HTML).

    -

    Examples:

    - -

    Lists are also possible:
    [list]
    *Item 1
    *Item 2
    [/list] to:

    - -

    +It's similar to HTML, but simpler. The tags start with a [ (where you would +have used < in HTML) and end with ] (where you would have used > in +HTML).

    "; + +start_table(); +row1("Examples"); +row2_plain("[b]Bold[/b]", "Bold"); +row2_plain("[i]Italic[/i]", "Italic"); +row2_plain("[u]Underline[/u]", "Underline"); +row2_plain("[size=15]Big text[/size]", "Big text"); +row2_plain("[color=red]Red text[/color]", "Red text"); +row2_plain("[url=http://google.com/]Google[/url]", "Google"); +row2_plain("[quote]Quoted[/quoted]", "use for quoted blocks of text"); +row2_plain("[img]http://example.com/pic.jpg[/img]", "use to display an image"); +row2_plain("[code]Code snippet here[/code]", "use to display some code"); +row2_plain("[pre]Pre-formatted text here[/pre]", "use to display pre-formatted (usually monospaced) text"); +row2_plain("[list]
    * Item 1
    *Item2
    [/list]", ""); +row2_plain("[trac]#1[/trac] or [trac]ticket:1[/trac]", + "use to link to Trac ticket on BOINC website: #1"); +row2_plain("[trac]wiki:WebForum[/trac]", + "use to link to Trac Wiki on BOINC website: WebForum"); +row2_plain("[trac]changeset:12345[/trac]", + "use to link to SVN changeset on BOINC website: [12345]"); +end_table(); + +echo "

    If you don't close a tag or don't specify a parameter correctly, the raw tag itself will display instead of the formatted text.

    "; diff --git a/html/user/forum_pm.php b/html/user/forum_pm.php index 3b383ef607..513329b984 100644 --- a/html/user/forum_pm.php +++ b/html/user/forum_pm.php @@ -1,5 +1,5 @@