[ Index ]
 

Code source de Serendipity 1.2

Accédez au Source d'autres logiciels libres

title

Body

[fermer]

/bundled-libs/Text/Wiki/ -> Rule.php (sommaire)

(pas de description)

Poids: 345 lignes (10 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 1 class

Text_Wiki_Rule:: (7 méthodes):
  Text_Wiki_Rule()
  addToken()
  setToken()
  parse()
  process()
  renderXhtml()
  getMacroArgs()


Classe: Text_Wiki_Rule  - X-Ref

Baseline rule class for extension into a "real" wiki rule.

Text_Wiki_Rule classes do not stand on their own; they are called by a
Text_Wiki object, typcially in the transform()method. Each rule class
performs three main activities: parse, process, and render.

The parse() method takes a regex and applies it to the whole block of
source text at one time. Each match is sent as $matches to the
process() method.

The process() method acts on the matched text from the source, and
then processes the source text is some way.  This may mean the
creation of a delimited token using addToken().  In every case, the
process() method returns the text that should replace the matched text
from parse().

Finally, the render*() methods take any token created by the rule and
creates output text matching a specific format.  Individual rules may
or may not have options for specific formats.

Typically, the extended rule only needs to define the process() and
render() methods; the parse() method is generally the same from rule
to rule, and has been included here.  However, there is no reason that
rules cannot override these methods, so long as the new methods operate
in substantially the same manner; similarly, the rule need not generate
any tokens at all, and may use a specialized parse() method to filter
the source text.  See the default rule classes for many examples.

Text_Wiki_Rule(&$obj, $name)   X-Ref
Constructor for the rule.

param: object &$obj The calling "parent" Text_Wiki object.
param: string $name The token name to use for this rule.

addToken($options = array()   X-Ref
Add a token to the Text_Wiki tokens array, and return a delimited
token number.

param: array $options An associative array of options for the new
param: boolean $id_only If true, return only the token number, not
return: string|int By default, return the number of the

setToken($id, $rule = null, $options = array()   X-Ref
Set or re-set a token with specific information, overwriting any
previous rule name and rule options.

param: int $id The token number to reset.
param: int $rule The rule name to use; by default, use the current
param: array $options An associative array of options for the
return: void

parse()   X-Ref
Simple parsing method to apply the rule's regular expression to
the source text, pass every match to the process() method, and
replace the matched text with the results of the processing.


process(&$matches)   X-Ref
Simple processing mathod to take matched text and generate
replacement text. This is one of the methods you will definitely
want to override in your rule class extensions.

param: array $matches An array of matches from the parse() method
return: string The processed text replacement; defaults to the

renderXhtml($options)   X-Ref
Simple rendering method to take a set of token options and
generate replacement text for it.  This is another method you will
definitely want to override in your rule subclass extensions.

param: array $options The "options" portion of the token (second element).
return: string The text rendered from the token options; by default,

getMacroArgs($text)   X-Ref
Simple method to extract 'option="value"' portions of wiki markup,
typically used only in macros.

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.

param: string $text The "macro options" portion of macro markup.
return: array An associative array of key-value pairs where the



Généré le : Sat Nov 24 09:00:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics