Phpfox_Parse_Bbcode

Description

BBCode Parser This class parses common BBCode into HTML. This class is fully part of the parsing system we have in place when parsing incoming data before entering it into the database.

  • author: Raymond Benc
  • version: $Id: bbcode.class.php 1855 2010-09-24 09:07:17Z Raymond_Benc $
  • copyright: [PHPFOX_COPYRIGHT]

Located in /include/library/phpfox/parse/bbcode.class.php (line 18)


	
			
Variable Summary
Method Summary
 Phpfox_Parse_Bbcode __construct ()
 string cleanCode (string $sText)
 string parse (string $sTxt)
 string preParse (string $sTxt)
 string stripCode (string $sText, [string $mCode = null])
 object Return useVideoImage (bool $bUseVideoImage)
 string _attachment (string $iId, [string $sText = null])
 string _cleanSpan (string $sStyle, string $sTxt)
 string _code (string $sTxt, string $sType)
 int _getBlockHeight (string $sTxt)
 array _getHtmlColors ()
 string _htmlTags (string $sTag)
 string _image (string $sTxt)
 string _parseAttachment (string $iId, [string $sText = null])
 string _parseBbCode (string $sBbcode, string $sTxt)
 string _parseBbCodeOption (string $sBbCode, string $sOption, string $sTxt)
 string _parseBbCodeSingle (array $aMatches)
 string _parseMember (string $sType, string $sMember)
 string _parseOption (string $sTxt)
 string _parseTable (int $i, string $sStr)
 string _parseUser (string $sType, string $sMember)
 string _parseValue (string $sTxt)
 string _parseVideo (int $iId)
 string _quote (string $sDetail, string $sTxt)
 string _replaceBbCode (string $sBbCode, [string $sType = 'prefix'], [bool $bOption = false], [string $sOption = null])
 string _trim (string $sTxt)
 string _video (int $iId)
Variables
array $_aAttachments = array() (line 105)

Array of attachments we are going to pull from the db a little later.

Reason we place this into an array is so we don't run a query for each attachment.

  • var: Array of attachments
  • access: private
array $_aCodes = array() (line 97)

Holds an ARRAY of CODE. (eg. [php], [html], [code])

  • access: private
array $_aDefault = array(
'b' => array(
'prefix' => '<b>',
'suffix' => '</b>'
),'i'=>array('prefix'=>'<i>','suffix'=>'</i>'),'link'=>array('prefix'=>'<a href="{option}" target="_blank" rel="nofollow">','suffix'=>'</a>'),'strong'=>array('prefix'=>'<strong>','suffix'=>'</strong>'),'u'=>array('prefix'=>'<u>','suffix'=>'</u>'),'color'=>array('prefix'=>'<span style="color:{option};">','suffix'=>'</span>'),'em'=>array('prefix'=>'<em>','suffix'=>'</em>'),'email'=>array('prefix'=>'<a href="mailto:{option}">','suffix'=>'</a>'),'size'=>array('prefix'=>'<font size="{option}">','suffix'=>'</font>'),'center'=>array('prefix'=>'<div style="text-align:center;">','suffix'=>'</div>'),'align'=>array('prefix'=>'<div style="text-align:{option};">','suffix'=>'</div>'),'ul'=>array('prefix'=>'<ul>','suffix'=>'</ul>'),'ol'=>array('prefix'=>'<ol>','suffix'=>'</ol>'),'li'=>array('prefix'=>'<li>','suffix'=>'</li>'),'br'=>array('prefix'=>'<br />','suffix'=>''),'hr'=>array('prefix'=>'<hr />','suffix'=>''),)
(line 25)

List of parsing rules to convert BBCOde into HTML.

  • access: private
array $_aUsers = array() (line 119)

ARRAY of all the user BBCode calls.

  • access: private
array $_aVideos = array() (line 112)

ARRAY of all the video BBCode calls.

  • access: private
bool $_bUseVideoImage = false (line 127)

Identify if we should use the videos image instead of loading the actual video when replacing the video BBCode.

  • access: private
Methods
Constructor __construct (line 134)

Class constructor is used to load any hooks developers have in case they want to extend BBCode support.

  • access: public
Phpfox_Parse_Bbcode __construct ()
cleanCode (line 271)

Remove BBCode from a block of text.

  • return: Returns text with any BBCode calls.
  • access: public
string cleanCode (string $sText)
  • string $sText: Text to parse.
parse (line 177)

2nd run to parse BBCode into HTML. This is the final run and after this all BBCode will have been converted into HTML.

  • return: Fully parsed string and we know have the final HTML output.
  • access: public
string parse (string $sTxt)
  • string $sTxt: String to parse.
preParse (line 145)

Run the first round of parsing of CODE related BBCode since we need to save them in memory.

  • return: Parsed string.
  • access: public
string preParse (string $sTxt)
  • string $sTxt: String we need to parse.
stripCode (line 283)

Removes any BBCode and any content found within a BBCode call.

  • return: Fully parsed text removing all BBCode.
  • access: public
string stripCode (string $sText, [string $mCode = null])
  • string $sText: String to parse and remove all BBCode.
  • string $mCode: String found within the BBCode.
useVideoImage (line 163)

Identify if we should use the videos image instead of loading the actual video when replacing the video BBCode.

  • return: this class.
  • access: public
object Return useVideoImage (bool $bUseVideoImage)
  • bool $bUseVideoImage: Set to TRUE if we should use the videos image instead of loading the actual video when replacing the video BBCode.
_attachment (line 457)

Parse attachments and create the new ID.

  • return: Full parse text.
  • access: private
string _attachment (string $iId, [string $sText = null])
  • string $iId: Attachment ID.
  • string $sText: Text to parse.
_cleanSpan (line 819)

Clean html <span>.

  • return: Cleaned span.
  • access: private
string _cleanSpan (string $sStyle, string $sTxt)
  • string $sStyle: Custom CSS for this span.
  • string $sTxt: Text to parse.
_code (line 525)

Parse code blocks (eg. code, html, php)

  • return: Fully parsed code blocks.
  • access: private
string _code (string $sTxt, string $sType)
  • string $sTxt: Text to parse.
  • string $sType: Type of code block.
_getBlockHeight (line 834)

Block height.

  • return: Height of block in pixels
  • access: private
int _getBlockHeight (string $sTxt)
  • string $sTxt: Block of text to find the height of
_getHtmlColors (line 950)

Color code.

  • return: array of type (key) to color (value)
  • access: private
array _getHtmlColors ()
_htmlTags (line 861)

Handles an individual HTML tag in a [html] tag.

  • return: Syntax highlighted, displayable HTML tag.
  • access: private
string _htmlTags (string $sTag)
  • string $sTag: The body of the tag.
_image (line 971)

Parse images from BBCode [image]

  • return: Converted BBCode.
  • access: private
string _image (string $sTxt)
  • string $sTxt: Text to parse.
_parseAttachment (line 393)

Parse BBCode attachments.

  • return: Parsed text.
  • access: private
string _parseAttachment (string $iId, [string $sText = null])
  • string $iId: Unique ID identifying the attachment call.
  • string $sText: String of text to parse.
_parseBbCode (line 758)

Parse BBCode with contents within it.

  • return: Converted BBCode.
  • access: private
string _parseBbCode (string $sBbcode, string $sTxt)
  • string $sBbcode: BBCode to parse.
  • string $sTxt: Text to parse.
_parseBbCodeOption (line 789)

Parse BBCode with options.

  • return: Converted text from BBCode to HTML.
  • access: private
string _parseBbCodeOption (string $sBbCode, string $sOption, string $sTxt)
  • string $sBbCode: BBCode to parse.
  • string $sOption: Option part of the BBCode.
  • string $sTxt: Text to parse.
_parseBbCodeSingle (line 731)

Parse a specific BBCode.

  • return: Converted BBCode into HTML.
  • access: private
string _parseBbCodeSingle (array $aMatches)
  • array $aMatches: ARRAY of matches for this bbcode.
_parseMember (line 696)

Holds in memory all the memers we need to parse.

  • return: Parsed text.
  • access: private
string _parseMember (string $sType, string $sMember)
  • string $sType: Type of method to parse.
  • string $sMember: Name of the member.
_parseOption (line 1027)

Clean BBCode option.

  • return: Clean value of the 1st argument.
  • access: private
string _parseOption (string $sTxt)
  • string $sTxt: String to parse.
_parseTable (line 710)

Parse BBCode [table][/table]

  • return: Parsed text.
  • access: private
string _parseTable (int $i, string $sStr)
  • int $i: Size of the table.
  • string $sStr: String to parse.
_parseUser (line 656)

Parse user BBCode that creates a link to their profile.

  • return: Parsed string.
  • access: private
string _parseUser (string $sType, string $sMember)
  • string $sType: Type of connection to the profile.
  • string $sMember: Name of the member.
_parseValue (line 1038)

Clean BBCode value.

  • return: Clean value of the 1st argument.
  • access: private
string _parseValue (string $sTxt)
  • string $sTxt: String to parse.
_parseVideo (line 485)

Parse videos.

  • return: Parse video.
  • access: private
string _parseVideo (int $iId)
  • int $iId: Unique ID of the video.
_quote (line 990)

Parse and convert [quote][/quote] BBCode.

  • return: Converted BBCode.
  • access: private
string _quote (string $sDetail, string $sTxt)
  • string $sDetail: Details identifying the quote message.
  • string $sTxt: Text to parse.
_replaceBbCode (line 1072)

Replace default BBCode with HTML.

  • return: Converted BBCode string.
  • access: private
string _replaceBbCode (string $sBbCode, [string $sType = 'prefix'], [bool $bOption = false], [string $sOption = null])
  • string $sBbCode: BBCode to parse.
  • string $sType: Type of BBCode.
  • bool $bOption: TRUE if option is allowed, FALSE if not.
  • string $sOption: If argument 3 is TRUE then you can pass a valid STRING option here.
_trim (line 1054)

Trim BBCode.

  • return: Trimmed text.
  • access: private
string _trim (string $sTxt)
  • string $sTxt: Text to parse.
_video (line 503)

Create an ID and store the parsed video ID in memory.

  • return: BBCode of the parsed video.
  • access: private
string _video (int $iId)
  • int $iId: ID of the video.

Documentation generated on Tue, 28 Sep 2010 10:36:37 +0200 by phpDocumentor 1.4.0a2