Class: StringHandling

Source Location: /bblog/inc/stringHandling.class.php ( Revision Log )

Class StringHandling

Class Overview
Method Summary
void   containsExternalLinks()  
bool   containsLinks()   Reports whether a string contains hyperlinks
void   containsRedirector()   Reports whether a link contains the Google Redirector.
bool   containsTransformedLinks()   Reports whether a string contains clickable links
string   encodeHTML()   Replace various characters with their HTML entities equivalent
bool   isProtocolPresent()   Simple check for presence of a protocol
string   redirectHref()   Prepends the Google redirector service to the HREF attribute of anchor tags Use this when a hyperlink already exists as a HTML tag
str   redirectUrl()   Prepends the Google redirector service to raw hyperlinks Use this when the hyperlink is raw text, not transformed into a HTML tag
string   removeTags()   Remove HTML tags from a string
string   transformLinks()   Converts typed links into clickable links

[ Top ]
Methods
containsExternalLinks  [line 163]

  void containsExternalLinks( mixed $str  )



[ Top ]
containsLinks  [line 82]

  bool containsLinks( string $str  )

Reports whether a string contains hyperlinks

Parameters:
string   $str:  The string to check


[ Top ]
containsRedirector  [line 141]

  void containsRedirector( string $str  )

Reports whether a link contains the Google Redirector.

This is meant to be used after a string successfully passes the containsTransformedLinks check. If used without first passing that check unexpected results may return.

Parameters:
string   $str:  The link to check return bool True if contains the link redirector, False if it does not


[ Top ]
containsTransformedLinks  [line 125]

  bool containsTransformedLinks( string $str  )

Reports whether a string contains clickable links

Parameters:
string   $str:  The string to check


[ Top ]
encodeHTML  [line 155]

  string encodeHTML( string $str  )

Replace various characters with their HTML entities equivalent

Parameters:
string   $str:  The string to parse


[ Top ]
isProtocolPresent  [line 109]

  bool isProtocolPresent( string $str  )

Simple check for presence of a protocol

Checks a string for the http:// and ftp:// protocol qualifiers

Parameters:
string   $str: 


[ Top ]
redirectHref  [line 175]

  string redirectHref( string $str  )

Prepends the Google redirector service to the HREF attribute of anchor tags Use this when a hyperlink already exists as a HTML tag

Parameters:
string   $str: 


[ Top ]
redirectUrl  [line 189]

  str redirectUrl( string $str  )

Prepends the Google redirector service to raw hyperlinks Use this when the hyperlink is raw text, not transformed into a HTML tag

Only works for the http protocol

Parameters:
string   $str: 


[ Top ]
removeTags  [line 73]

  string removeTags( string $str, [array $tags = '']  )

Remove HTML tags from a string

This is merely a wrapper around the native strip_tags function

Parameters:
string   $str:  String to remove tags from
array   $tags:  Optional. List of tags to allow


[ Top ]
transformLinks  [line 42]

  string transformLinks( string $str  )

Converts typed links into clickable links

The following URI patterns are searched, and replaced with URIs prepended with the Google Redirector. Additionally, if a URI is not already in an Anchor (<a>) tag, we wrap it with one. For URIs that already have anchor tags, all attributes (style="", title="", etc) are saved. Patterns: <a href="www.example.com">Example</a> <a href="http://www.example.com">Example</a> <a href="ftp://www.example.com">Example</a> <a href="https://www.example.com">Example</a> http://www.example.com https://www.example.com ftp://ftp.example.com ftp.example.com www.really.long.example.com All URIs with a query path: www.example.com?example=yes

Parameters:
string   $str:  String to check and convert


[ Top ]