Text_Wiki
[ class tree: Text_Wiki ] [ index: Text_Wiki ] [ all elements ]

Class: Text_Wiki

Source Location: /Text_Wiki-0.23.0/Text/Wiki.php

Class Overview


Parse structured wiki text and render into arbitrary formats such as XHTML.


Author(s):

Version:

  • 0.23.0

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 34]
Parse structured wiki text and render into arbitrary formats such as XHTML.

This is the "master" class for handling the management and convenience functions to transform Wiki-formatted text.

$Id: Wiki.php,v 1.24 2004/09/30 13:42:14 pmjones Exp $



[ Top ]


Class Variables

$delim =  "\xFF"

[line 201]

The delimiter for token numbers of parsed elements in source text.
  • Access: public

Type:   string


[ Top ]

$disable = array(
        'Html',
        'Include',
        'Embed'
    )

[line 95]

The list of rules to not-apply to the source text.
  • Access: public

Type:   array


[ Top ]

$formatConf = array(
        'Docbook' => array(),'Latex'=>array(),'Pdf'=>array(),'Plain'=>array(),'Rtf'=>array(),'Xhtml'=>array())

[line 181]

Custom configuration for the output format itself.

Even though Text_Wiki will render the tokens from parsed text, the format itself may require some configuration. For example, RTF needs to know font names and sizes, PDF requires page layout information, and DocBook needs a section hierarchy. This array matches the $conf property of the the format-level renderer (e.g., Text_Wiki_Render_Xhtml).

In this array, the key is the rendering format name, and the value is an array of key-value configuration pairs corresponding to the $conf property in the rendering format rule.

  • Access: public

Type:   array


[ Top ]

$parseConf = array()

[line 128]

Custom configuration for rules at the parsing stage.

In this array, the key is the parsing rule name, and the value is an array of key-value configuration pairs corresponding to the $conf property in the target parsing rule.

For example:

  1.  $parseConf = array(
  2.      'Include' => array(
  3.          'base' => '/path/to/scripts/'
  4.      )
  5.  );

Note that most default rules do not need any parsing configuration.

  • Access: public

Type:   array


[ Top ]

$renderConf = array(
        'Docbook' => array(),'Latex'=>array(),'Pdf'=>array(),'Plain'=>array(),'Rtf'=>array(),'Xhtml'=>array())

[line 150]

Custom configuration for rules at the rendering stage.

Because rendering may be different for each target format, the first-level element in this array is always a format name (e.g., 'Xhtml').

Within that first level element, the subsequent elements match the $parseConf format. That is, the sub-key is the rendering rule name, and the sub-value is an array of key-value configuration pairs corresponding to the $conf property in the target rendering rule.

  • Access: public

Type:   array


[ Top ]

$rules = array(
        'Prefilter',
        'Delimiter',
        'Code',
        'Function',
        'Html',
        'Raw',
        'Include',
        'Embed',
        'Anchor',
        'Heading',
        'Toc',
        'Horiz',
        'Break',
        'Blockquote',
        'List',
        'Deflist',
        'Table',
        'Image',
        'Phplookup',
        'Center',
        'Newline',
        'Paragraph',
        'Url',
        'Freelink',
        'Interwiki',
        'Wikilink',
        'Colortext',
        'Strong',
        'Bold',
        'Emphasis',
        'Italic',
        'Tt',
        'Superscript',
        'Revise',
        'Tighten'
    )

[line 46]

The default list of rules, in order, to apply to the source text.
  • Access: public

Type:   array


[ Top ]



Method Detail

Text_Wiki (Constructor)   [line 332]

Text_Wiki Text_Wiki( [array $rules = null])

Constructor.
  • Access: public

Parameters:

array   $rules   —  The set of rules to load for this object.

[ Top ]

addPath   [line 1165]

void addPath( string $type, string $dir)

Add a path to a path array.
  • Access: public

Parameters:

string   $type   —  The path-type to add (parse or render).
string   $dir   —  The directory to add to the path-type.

[ Top ]

addToken   [line 992]

string|int addToken( $rule, [array $options = array()], [boolean $id_only = false])

Add a token to the Text_Wiki tokens array, and return a delimited token number.
  • Return: By default, return the number of the newly-created token array element with a delimiter prefix and suffix; however, if $id_only is set to true, return only the token number (no delimiters).
  • Access: public

Parameters:

array   $options   —  An associative array of options for the new token array element. The keys and values are specific to the rule, and may or may not be common to other rule options. Typical options keys are 'text' and 'type' but may include others.
boolean   $id_only   —  If true, return only the token number, not a delimited token string.
   $rule   — 

[ Top ]

changeRule   [line 695]

void changeRule( string $old, string $new)

Change from one rule to another in-place.
  • Access: public

Parameters:

string   $old   —  The name of the rule to change from.
string   $new   —  The name of the rule to change to.

[ Top ]

deleteRule   [line 671]

void deleteRule( $name, string $rule)

Delete (remove or unset) a rule from the $rules property.
  • Access: public

Parameters:

string   $rule   —  The name of the rule to remove.
   $name   — 

[ Top ]

disableRule   [line 740]

void disableRule( $name, string $rule)

Disables a rule so that it is not applied when parsing.
  • Access: public

Parameters:

string   $rule   —  The name of the rule to disable.
   $name   — 

[ Top ]

enableRule   [line 718]

void enableRule( $name, string $rule)

Enables a rule so that it is applied when parsing.
  • Access: public

Parameters:

string   $rule   —  The name of the rule to enable.
   $name   — 

[ Top ]

findFile   [line 1215]

string|bool findFile( array $type, string $file)

Searches a series of paths for a given file.
  • Return: The full path and file name for the target file, or boolean false if the file is not found in any of the paths.

Parameters:

array   $type   —  The type of paths to search (template, plugin, or filter).
string   $file   —  The file name to look for.

[ Top ]

getFormatConf   [line 565]

mixed getFormatConf( string $format, [mixed $key = null])

Get configuration for a specific format and key.
  • Return: The whole conf array if no key is specified, or the specific conf key value.
  • Access: public

Parameters:

string   $format   —  The format to get config for.
mixed   $key   —  A key in the conf array; if null, returns the entire conf array.

[ Top ]

getParseConf   [line 403]

mixed getParseConf( string $rule, [string $key = null])

Get parser configuration for a specific rule and key.
  • Return: The whole conf array if no key is specified, or the specific conf key value.
  • Access: public

Parameters:

string   $rule   —  The parse rule to get config for.
string   $key   —  A key in the conf array; if null, returns the entire conf array.

[ Top ]

getPath   [line 1189]

array getPath( [string $type = null])

Get the current path array for a path-type.
  • Return: The array of paths for the requested type.
  • Access: public

Parameters:

string   $type   —  The path-type to look up (plugin, filter, or template). If not set, returns all path types.

[ Top ]

getRenderConf   [line 489]

mixed getRenderConf( string $format, string $rule, [string $key = null])

Get renderer configuration for a specific format, rule, and key.
  • Return: The whole conf array if no key is specified, or the specific conf key value.
  • Access: public

Parameters:

string   $format   —  The render format to get config for.
string   $rule   —  The render format rule to get config for.
string   $key   —  A key in the conf array; if null, returns the entire conf array.

[ Top ]

getSource   [line 933]

string getSource( )

Returns the parsed source text with delimited token placeholders.
  • Return: The parsed source text.
  • Access: public

[ Top ]

getTokens   [line 953]

array getTokens( [array $rules = null])

Returns tokens that have been parsed out of the source text.
  • Return: An array of tokens.
  • Access: public

Parameters:

array   $rules   —  If an array of rule names is passed, only return tokens matching these rule names. If no array is passed, return all tokens.

[ Top ]

insertRule   [line 605]

void insertRule( string $name, [string $tgt = null])

Inserts a rule into to the rule set.
  • Access: public

Parameters:

string   $name   —  The name of the rule. Should be different from all other keys in the rule set.
string   $tgt   —  The rule after which to insert this new rule. By default (null) the rule is inserted at the end; if set to '', inserts at the beginning.

[ Top ]

loadFormatObj   [line 1130]

bool loadFormatObj( $format)

Load a format-render class file.
  • Return: True if loaded, false if not.
  • Access: public

Parameters:

   $format   — 

[ Top ]

loadParseObj   [line 1064]

bool loadParseObj( $rule)

Load a rule parser class file.
  • Return: True if loaded, false if not.
  • Access: public

Parameters:

   $rule   — 

[ Top ]

loadRenderObj   [line 1097]

bool loadRenderObj( $format, $rule)

Load a rule-render class file.
  • Return: True if loaded, false if not.
  • Access: public

Parameters:

   $format   — 
   $rule   — 

[ Top ]

parse   [line 800]

void parse( string $text)

Sets the $_source text property, then parses it in place and retains tokens in the $_tokens array property.
  • Access: public

Parameters:

string   $text   —  The source text to which wiki rules should be applied, both for parsing and for rendering.

[ Top ]

render   [line 841]

string render( [string $format = 'Xhtml'])

Renders tokens back into the source text, based on the requested format.
  • Return: The transformed wiki text.
  • Access: public

Parameters:

string   $format   —  The target output format, typically 'xhtml'. If a rule does not support a given format, the output from that rule is rule-specific.

[ Top ]

setFormatConf   [line 531]

void setFormatConf( string $format, $arg1, [ $arg2 = null], string $key, string $val)

Set format configuration for a specific rule and key.
  • Access: public

Parameters:

string   $format   —  The format to set config for.
string   $key   —  The config key within the format.
string   $val   —  The config value for the key.
   $arg1   — 
   $arg2   — 

[ Top ]

setParseConf   [line 368]

void setParseConf( string $rule, array|string $arg1, [string $arg2 = null])

Set parser configuration for a specific rule and key.
  • Access: public

Parameters:

string   $rule   —  The parse rule to set config for.
array|string   $arg1   —  The full config array to use for the parse rule, or a conf key in that array.
string   $arg2   —  The config value for the key.

[ Top ]

setRenderConf   [line 447]

void setRenderConf( string $format, string $rule, array|string $arg1, [string $arg2 = null])

Set renderer configuration for a specific format, rule, and key.
  • Access: public

Parameters:

string   $format   —  The render format to set config for.
string   $rule   —  The render rule to set config for in the format.
array|string   $arg1   —  The config array, or the config key within the render rule.
string   $arg2   —  The config value for the key.

[ Top ]

setToken   [line 1044]

void setToken( int $id, int $rule, [array $options = array()])

Set or re-set a token with specific information, overwriting any previous rule name and rule options.
  • Access: public

Parameters:

int   $id   —  The token number to reset.
int   $rule   —  The rule name to use.
array   $options   —  An associative array of options for the token array element. The keys and values are specific to the rule, and may or may not be common to other rule options. Typical options keys are 'text' and 'type' but may include others.

[ Top ]

transform   [line 779]

string transform( string $text, [string $format = 'Xhtml'])

Parses and renders the text passed to it, and returns the results.

First, the method parses the source text, applying rules to the text as it goes. These rules will modify the source text in-place, replacing some text with delimited tokens (and populating the $this->tokens array as it goes).

Next, the method renders the in-place tokens into the requested output format.

Finally, the method returns the transformed text. Note that the source text is transformed in place; once it is transformed, it is no longer the same as the original source text.

  • Return: The transformed wiki text.
  • Access: public

Parameters:

string   $text   —  The source text to which wiki rules should be applied, both for parsing and for rendering.
string   $format   —  The target output format, typically 'xhtml'. If a rule does not support a given format, the output from that rule is rule-specific.

[ Top ]


Documentation generated on Mon, 11 Mar 2019 13:56:12 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.