Class bbcode

Description

BBCode class to perform the majority of BBcode functions within ILance

  • author: ILance
  • version: $Revision: 1.0.0 $

Located in /api/class.bbcode.inc.php (line 23)


	
			
Method Summary
bbcode bbcode ()
void bbcode_quote_handler ( &$output, string $str)
string bbcode_to_html ([string $text = ''], [boolean $doamperstand = false])
string html_to_bbcode ([string $text = ''])
string prepare_special_codes ([string $tag = ''], [string $html = ''])
string restore_special_codes ([string $tag = ''], array &$text, array &$matches)
string strip_bb_tags ([string $text = ''])
string strip_html_tags ([array $matches = array()])
string strip_special_codes ([string $tag = ''], string &$text, array &$matches)
Methods
Constructor bbcode (line 28)

BBCode Constructor.

bbcode bbcode ()
bbcode_quote_handler (line 592)

Function to handle the processing of nested bbcode [quote] tags within a string.

  • return: Working with the actual string, not a copy.
void bbcode_quote_handler ( &$output, string $str)
  • string $str: Passed by reference
  • &$output
bbcode_to_html (line 40)

Function to convert a string formatted in BBCode [B]xx[/B] into HTML format <strong>xx</strong>.

  • return: Converted BBcode [B]xx[/B] to HTML -> <strong>xx</strong>
string bbcode_to_html ([string $text = ''], [boolean $doamperstand = false])
  • string $text: text
  • boolean $doamperstand: do amperstand & conversion? ie: & = &amp; (default false)
html_to_bbcode (line 342)

Function to convert HTML code into BBCode.

  1.                 $search array(
  2.                         "'<pre>(.*)</pre>'siU",
  3.                         "'<b>(.*)</b>'siU",
  4.                         "'<strong>(.*)</strong>'siU",
  5.                         "'<i>(.*)</i>'siU",
  6.                         "'<em>(.*)</em>'siU",
  7.                         "'<u>(.*)</u>'siU",
  8.                         "'<strike>(.*)</strike>'siU",
  9.                         "'<p align=\"justify\">(.*)</p>'siU",
  10.                         "'<div style=\"text-align: left;\">(.*)</div>'siU",
  11.                         "'<p align=\"left\">(.*)</p>'siU",
  12.                         "'<div style=\"text-align: center;\">(.*)</div>'siU",
  13.                         "'<p align=\"center\">(.*)</p>'siU",
  14.                         "'<div style=\"text-align: right;\">(.*)</div>'siU",
  15.                         "'<p align=\"right\">(.*)</p>'siU",
  16.                         "'<blockquote dir=\"ltr\" style=\"margin-right: 0px\">(.*)</blockquote>'siU",
  17.                         "'<div style=\"margin-left: 40px;\">(.*)</div>'siU",
  18.                         "'<ol>(.*)</ol>'siU",
  19.                         "'<ul>(.*)</ul>'siU",
  20.                         "'<li>(.*)</li>'siU",
  21.                         "'<img(.*)src=\"([^\"]+)\"(.*)>'siU",
  22.                         "'<a href=\"mailto:(.*)\">(.*)</a>'siU",
  23.                         "'<a href=(.*)>(.*)</a>'siU",
  24.                         "'<font size=(.*)>(.*)</font>'siU",
  25.                         "'<font face=(.*) size=(.*)>(.*)</font>'siU",
  26.                         "'<font face=(.*)>(.*)</font>'siU",
  27.                         "'<font color=(.*) size=(.*)>(.*)</font>'siU",
  28.                         "'<font color=(.*)>(.*)</font>'siU",
  29.                         "'<p>(.*)</p>'siU",
  30.                         "'<div>(.*)</div>'siU",
  31.                         "'<p />'siU",
  32.                         "'<(br|br /)>'si",
  33.                         "'<hr />'siU",
  34.                         "'<hr style=\"(.*)\">(.*)'siU",
  35.                         "'<div class=(.*)>(.*)'siU",
  36.                         "'<div class=\"(.*)\">(.*)'siU",
  37.                         "'<h(.*)>(.*)</h(.*)>'siU",
  38.                 );
  39.                 
  40.                 $replace array(
  41.                         "[PHP]$1[/PHP]",
  42.                         "[B]$1[/B]",
  43.                         "[B]$1[/B]",
  44.                         "[I]$1[/I]",
  45.                         "[I]$1[/I]",
  46.                         "[U]$1[/U]",
  47.                         "[STRIKE]$1[/STRIKE]",
  48.                         "[JUSTIFY]$1[/JUSTIFY]",
  49.                         "[LEFT]$1[/LEFT]",
  50.                         "[LEFT]$1[/LEFT]",
  51.                         "[CENTER]$1[/CENTER]",
  52.                         "[CENTER]$1[/CENTER]",
  53.                         "[RIGHT]$1[/RIGHT]",
  54.                         "[RIGHT]$1[/RIGHT]",
  55.                         "[INDENT]$1[/INDENT]",
  56.                         "[INDENT]$1[/INDENT]",
  57.                         "[list=1]$1[/list]",
  58.                         "[list=a]$1[/list]",
  59.                         "[*]$1",
  60.                         "[IMG]$2[/IMG]",
  61.                         "[EMAIL=\"$1\"]$2[/EMAIL]",
  62.                         "[URL=\"$1\"]$2[/URL]",
  63.                         "[SIZE=\"$1\"]$2[/SIZE]",
  64.                         "[FONT=\"$1\" SIZE=\"$2\"]$3[/FONT]",
  65.                         "[FONT=\"$1\"]$2[/FONT]",
  66.                         "[COLOR=\"$1\" SIZE=\"$2\"]$3[/FONT]",
  67.                         "[COLOR=\"$1\"]$2[/COLOR]",
  68.                         "[P]$1[/P]",
  69.                         "[P]$1[/P]",
  70.                         "",
  71.                         "[BR]",
  72.                         "[HR]",
  73.                         "[HR]",
  74.                         "",
  75.                         "",
  76.                         "[P][B]$2[/B][/P]",
  77.                 );
  78.                 
  79.                 ($apihook $ilance->api('html_to_bbcode_start')) ? eval($apihookfalse;
  80.                 
  81.                 $text preg_replace($search$replace$text);
  82.                 unset($search$replace);
  83.                 
  84.                 $search array(
  85.                         "[P][/P]",
  86.                         "[B][/B]",
  87.                         "[I][/I]",
  88.                         "[U][/U]",
  89.                         "[STRIKE][/STRIKE]",
  90.                         "[JUSTIFY][/JUSTIFY]",
  91.                         "[LEFT][/LEFT]",
  92.                         "[CENTER][/CENTER]",
  93.                         "[RIGHT][/RIGHT]",
  94.                         "[INDENT][/INDENT]",
  95.                         "[TABLE][/TABLE]",
  96.                 );
  97.                 
  98.                 $replace array(
  99.                         "",
  100.                         "",
  101.                         "",
  102.                         "",
  103.                         "",
  104.                         "",
  105.                         "",
  106.                         "",
  107.                         "",
  108.                         "",
  109.                         "",
  110.                 );
  111.                 
  112.                 ($apihook $ilance->api('html_to_bbcode_end')) ? eval($apihookfalse;
  113.                 
  114.                 $text str_replace($search$replace$text);
  115.                 unset($search$replace);
  116.                 
  117.                 $this->restore_special_codes('QUOTE'$text$quote_matches);
  118.                 $this->restore_special_codes('HTML'$text$html_matches);
  119.                 $this->restore_special_codes('CODE'$text$code_matches);
  120.                 $this->restore_special_codes('PHP'$text$php_matches);
  121.                 
  122.                 return $text;
  123.         }

  • return: HTML formatted string
string html_to_bbcode ([string $text = ''])
  • string $text: text
prepare_special_codes (line 305)

Function to prepare special tags supplied to the function along with any text string.

  • return: HTML formatted string
string prepare_special_codes ([string $tag = ''], [string $html = ''])
  • string $tag: tag to match
  • string $html: text
restore_special_codes (line 289)

Function to restore any stripped out special tags.

  • return: HTML formatted string
string restore_special_codes ([string $tag = ''], array &$text, array &$matches)
  • string $tag: tag to restore (example: PHP)
  • array &$text: text
  • array &$matches: matches text
strip_bb_tags (line 489)

Function to strip out any BBCode tags within the supplied text string.

  • return: HTML formatted string formatted without any BBCode tags
string strip_bb_tags ([string $text = ''])
  • string $text: text
strip_html_tags (line 326)

Function to strip out any HTML tags within the supplied text string.

  • return: HTML formatted string
string strip_html_tags ([array $matches = array()])
  • array $matches: matches text
strip_special_codes (line 269)

Function to strip out any special tags we provide the function and then have them replaced at the very end. This is useful for stripping out [PHP]xxxx[/PHP] tags so we don't process anything within the [PHP]..[/PHP] tags and other situations that may arise.

  • return: HTML formatted string
string strip_special_codes ([string $tag = ''], string &$text, array &$matches)
  • string $tag: tag to strip (example: PHP)
  • string &$text: text
  • array &$matches: matches text

Documentation generated on Mon, 08 Aug 2011 17:40:49 +0200 by phpDocumentor 1.4.1