\Text_Wiki_Parse_Url

Parse for URLS in the source text.

Various URL markings are supported: inline (the URL by itself), numbered or footnote reference (where the URL is enclosed in square brackets), and named reference (where the URL is enclosed in square brackets and has a name included inside the brackets). E.g.:

inline -- http://example.com numbered -- [http://example.com] described -- [http://example.com Example Description]

When rendering a URL token, this will convert URLs pointing to a .gif, .jpg, or .png image into an inline tag (for the 'xhtml' format).

Token options are:

'type' => ['inline'|'footnote'|'descr'] the type of URL

'href' => the URL link href portion

'text' => the displayed text of the URL link

Summary

Methods
Properties
Constants
__construct()
parse()
process()
getConf()
getAttrs()
processWithoutProtocol()
processInlineEmail()
processFootnote()
processDescr()
$conf
$regex
$rule
$wiki
$footnoteCount
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Properties

$conf

$conf : array

URL schemes recognized by this rule.

Type

array

$regex

$regex : string

Regular expression to find matching text for this rule.

Type

string

$rule

$rule : string

The name of this rule for new token array elements.

Type

string

$wiki

$wiki : object

A reference to the calling Text_Wiki object.

This is needed so that each rule has access to the same source text, token set, URLs, interwiki maps, page names, etc.

Type

object

$footnoteCount

$footnoteCount : integer

Keeps a running count of numbered-reference URLs.

Type

integer

Methods

__construct()

__construct(  $obj) 

Constructor.

We override the constructor so we can comment the regex nicely.

Parameters

$obj

parse()

parse() 

Find three different kinds of URLs in the source text.

Applies the rule's regular expression to the source text, passes every match to the process() method, and replaces the matched text with the results of the processing.

process()

process(array  $matches) : string

Process inline URLs.

Parameters

array $matches

An array of matches from the parse() method as generated by preg_replace_callback. $matches[0] is the full matched string, $matches[1] is the first matched pattern, $matches[2] is the second matched pattern, and so on.

Returns

string —

The processed text replacement.

getConf()

getConf(string  $key, mixed  $default = null) : mixed

Simple method to safely get configuration key values.

Parameters

string $key

The configuration key.

mixed $default

If the key does not exist, return this value instead.

Returns

mixed —

The configuration key value (if it exists) or the default value (if not).

getAttrs()

getAttrs(string  $text) : array

Extract 'attribute="value"' portions of wiki markup.

This kind of markup is typically used only in macros, but is useful anywhere.

The syntax is pretty strict; there can be no spaces between the option name, the equals, and the first double-quote; the value must be surrounded by double-quotes. You can escape characters in the value with a backslash, and the backslash will be stripped for you.

Parameters

string $text

The "attributes" portion of markup.

Returns

array —

An associative array of key-value pairs where the key is the option name and the value is the option value.

processWithoutProtocol()

processWithoutProtocol(  $matches) 

Parameters

$matches

processInlineEmail()

processInlineEmail(  $matches) 

Parameters

$matches

processFootnote()

processFootnote(array  $matches) : string

Process numbered (footnote) URLs.

Token options are:

Parameters

array $matches

An array of matches from the parse() method as generated by preg_replace_callback. $matches[0] is the full matched string, $matches[1] is the first matched pattern, $matches[2] is the second matched pattern, and so on.

Returns

string —

The processed text replacement.

processDescr()

processDescr(array  $matches) : string

Process described-reference (named-reference) URLs.

Token options are: 'type' => ['inline'|'footnote'|'descr'] the type of URL 'href' => the URL link href portion 'text' => the displayed text of the URL link

Parameters

array $matches

An array of matches from the parse() method as generated by preg_replace_callback. $matches[0] is the full matched string, $matches[1] is the first matched pattern, $matches[2] is the second matched pattern, and so on.

Returns

string —

The processed text replacement.