\Horde_Text_Filter_Linkurls

The Horde_Text_Filter_Linkurls:: class turns all URLs in the text into hyperlinks. The regex used is adapted from John Gruber's: http://daringfireball.net/2010/07/improved_regex_for_matching_urls

Changes:

  • Require at least one slash after the protocol. Horde's other filters don't expect us to match mailto: as part of these filters, so don't.
  • Limit the URL protocol to 20 characters to avoid PCRE problems.
  • Allow "+" characters in URL protocols (like svn+ssh://).

Parameters:

  • callback: (string) A callback function that the URL is passed through before being set as the href attribute. Must be a string with the function name, the function must take the original URL as the first and only parameter. DEFAULT: No callback
  • class: (string) The CSS class of the generated links. DEFAULT: none
  • encode: (boolean) Whether to escape special HTML characters in the URLs and finally "encode" the complete tag so that it can be decoded later with the decode() method. This is useful if you want to run htmlspecialchars() or similar after using this filter. DEFAULT: false
  • nofollow: (boolean) Whether to set the 'rel="nofollow"' attribute on links. DEFAULT: false
  • target: (string) The link target. DEFAULT: '_blank'

Copyright 2003-2017 Horde LLC (http://www.horde.org/)

See the enclosed file LICENSE for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.

Summary

Methods
Properties
Constants
__construct()
preProcess()
getPatterns()
postProcess()
getRegex()
initializeRegex()
callback()
decode()
$regex
No constants found
_parseurl()
$_params
N/A
No private methods found
No private properties found
N/A

Properties

$regex

$regex : 

Link-finding regex

Type

$_params

$_params : array

Filter parameters.

Type

array

Methods

__construct()

__construct(array  $params = array()) 

Constructor.

Parameters

array $params

Any parameters that the filter instance needs.

preProcess()

preProcess(string  $text) : string

Executes any code necessaray before applying the filter patterns.

Parameters

string $text

The text before the filtering.

Returns

string —

The modified text.

getPatterns()

getPatterns() : array

Returns a hash with replace patterns.

Returns

array —

Patterns hash.

postProcess()

postProcess(string  $text) : string

Executes any code necessaray after applying the filter patterns.

Parameters

string $text

The text after the filtering.

Returns

string —

The modified text.

getRegex()

getRegex() : string

Return the regex used to search for links.

Returns

string —

The regex string.

initializeRegex()

initializeRegex() 

Initialize the regex for this instance.

callback()

callback(  $match) 

Parameters

$match

decode()

decode(string  $text) : string

"Decodes" the text formerly encoded by using the "encode" parameter.

Parameters

string $text

An encoded text.

Returns

string —

The decoded text.

_parseurl()

_parseurl(string  $url) : mixed

Handle multi-byte data since parse_url is not multibyte safe on all systems. Adapted from php.net/parse_url comments.

See https://bugs.php.net/bug.php?id=52923 for description of parse_url issues.

Parameters

string $url

The url to parse.

Throws

\InvalidArgumentException

Returns

mixed —

The parsed url.