Semantic MediaWiki and related extensions
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
ParserHook Class Reference

Public Member Functions

 __construct ($forTagExtensions=true, $forParserFunctions=true, $flags=0)
 
 init (Parser &$parser)
 
 magic (array &$magicWords, $langCode)
 
 renderTag ($input, array $args, Parser $parser, PPFrame $frame=null)
 
 renderFunction (Parser &$parser)
 
 renderFunctionObj (Parser &$parser, PPFrame $frame, $args)
 
 validateAndRender (array $arguments, $type)
 
 getParamDefinitions ($type=self::TYPE_FUNCTION)
 
 getDescriptionData ($type)
 
 getDescription ()
 
 getMessage ()
 

Static Public Member Functions

static getRegisteredParserHooks ()
 
static getHookClassName ($hookName)
 

Public Attributes

const TYPE_TAG = 0
 
const TYPE_FUNCTION = 1
 
 $forTagExtensions
 
 $forParserFunctions
 
const FH_NO_HASH = 1
 

Protected Member Functions

 getName ()
 
 render (array $parameters)
 
 getNames ()
 
 getFunctionOptions ()
 
 getErrorsToDisplay ()
 
 renderFatalError (ProcessingError $error)
 
 getParameterInfo ($type)
 
 getDefaultParameters ($type)
 
 isTag ()
 
 isFunction ()
 
 parseWikitext ($text)
 

Protected Attributes

 $validator
 
 $parser
 
 $frame
 
 $currentType
 
 $parserHookOptions
 

Static Protected Attributes

static $registeredHooks = array()
 

Detailed Description

Class for out of the box parser hook functionality integrated with the validation provided by Validator.

Since
0.4
Deprecated:
since 1.0 in favour of the ParserHooks library

GNU GPL v2+

Author
Jeroen De Dauw < jeroe.nosp@m.nded.nosp@m.auw@g.nosp@m.mail.nosp@m..com >
Daniel Werner

Constructor & Destructor Documentation

ParserHook::__construct (   $forTagExtensions = true,
  $forParserFunctions = true,
  $flags = 0 
)

Constructor.

Since
0.4
Parameters
boolean$forTagExtensions
boolean$forParserFunctions
integer$flagcombination of option flags to manipulare the parser hooks characteristics. The following are available:

Member Function Documentation

ParserHook::getDefaultParameters (   $type)
protected

Returns the list of default parameters. These parameters can be used as unnamed parameters where it is not necessary to use the name and the '=' as long as there is no '=' within the value. It is possible to define that a parameter should not have a named fallback. Therefore the information has to be returnd as sub-array with the parameter name as first and Validator::PARAM_UNNAMED as second value. Parameter using this option must be set first, before any unnamed parameter in the same order as set here. All parameters defined before the last parameter making use of Validator::PARAM_UNNAMED will automatically be populated with this option.

Override in deriving classes to add default parameters.

Since
0.4
Parameters
integer$typeItem of the ParserHook::TYPE_ enum
Returns
array
ParserHook::getDescription ( )

Returns a description for the parser hook, or false when there is none. Override in deriving classes to add a message.

Since
0.4.3
Deprecated:
since 1.0
Returns
mixed string or false
ParserHook::getDescriptionData (   $type)

Returns the data needed to describe the parser hook. This is mainly needed because some of the individual get methods that return the needed data are protected, and cannot be made public without breaking b/c in a rather bad way.

Since
0.4.3
Parameters
integer$typeItem of the ParserHook::TYPE_ enum
Returns
array
ParserHook::getErrorsToDisplay ( )
protected

Returns the ProcessingError objects for the errors and warnings that should be displayed.

Since
0.4
Returns
array of array of ProcessingError
ParserHook::getFunctionOptions ( )
protected

Returns the parser function otpions.

Since
0.4
Returns
array
static ParserHook::getHookClassName (   $hookName)
static

Returns the name of the ParserHook deriving class that defines a certain parser hook, or false if there is none.

Since
0.4.3
Parameters
string$hookName
Returns
mixed string or false
ParserHook::getMessage ( )

Returns a description message for the parser hook, or false when there is none. Override in deriving classes to add a message.

Since
0.4.10
Returns
mixed string or false
ParserHook::getName ( )
abstractprotected

Gets the name of the parser hook.

Since
0.4
Returns
string or array of string
ParserHook::getNames ( )
protected

Returns an array with the names for the parser hook.

Since
0.4
Returns
array
ParserHook::getParamDefinitions (   $type = self::TYPE_FUNCTION)
ParserHook::getParameterInfo (   $type)
protected

Returns an array containing the parameter info. Override in deriving classes to add parameter info.

Since
0.4
Parameters
integer$typeItem of the ParserHook::TYPE_ enum
Returns
array
static ParserHook::getRegisteredParserHooks ( )
static

Returns an array of registered parser hooks (keys) and their handling ParserHook deriving class names (values).

Since
0.4.3
Returns
array
ParserHook::init ( Parser &  $parser)

Function to hook up the coordinate rendering functions to the parser.

Since
0.4
Parameters
Parser$parser
Returns
true
ParserHook::isFunction ( )
protected

Returns if the current render request is coming from a parser function.

Since
0.4.4
Returns
boolean
ParserHook::isTag ( )
protected

Returns if the current render request is coming from a tag extension.

Since
0.4.4
Returns
boolean
ParserHook::magic ( array &  $magicWords,
  $langCode 
)

Function to add the magic word in pre MW 1.16.

Since
0.4
Parameters
array$magicWords
string$langCode
Returns
boolean
ParserHook::parseWikitext (   $text)
protected

Utility function to parse wikitext without having to care about handling a tag extension or parser function.

Since
0.4.4
Parameters
string$textThe wikitext to be parsed
Returns
string the parsed output
ParserHook::render ( array  $parameters)
abstractprotected

Renders and returns the output.

Since
0.4
Parameters
array$parameters
Returns
string
ParserHook::renderFatalError ( ProcessingError  $error)
protected

Creates and returns the output when a fatal error prevent regular rendering.

Since
0.4
Parameters
ProcessingError$error
Returns
string
ParserHook::renderFunction ( Parser &  $parser)

Handler for rendering the function hook registered by Parser::setFunctionHook()

Since
0.4
Parameters
Parser&$parser... further arguments ...
Returns
array

: FIXME: Is this really necessary? The same thing is propably going to happen in Parser::braceSubstitution() if 'isHTML' is set! : other options besides 'isHTML' like 'noparse' are ignored here!

ParserHook::renderFunctionObj ( Parser &  $parser,
PPFrame  $frame,
  $args 
)

Handler for rendering the function hook registered by Parser::setFunctionHook() together with object style arguments (SFH_OBJECT_ARGS flag).

Since
0.4.13
Parameters
Parser&$parser
PPFrame$frame
type$args
Returns
array
ParserHook::renderTag (   $input,
array  $args,
Parser  $parser,
PPFrame  $frame = null 
)

Handler for rendering the tag hook registered by Parser::setHook()

Since
0.4
Parameters
mixed$inputstring or null
array$args
Parser$parser
PPFrame$frameAvailable from 1.16
Returns
string
ParserHook::validateAndRender ( array  $arguments,
  $type 
)

Takes care of validation and rendering, and returns the output.

Since
0.4
Parameters
array$arguments
integer$typeItem of the ParserHook::TYPE_ enum
Returns
string

Member Data Documentation

ParserHook::$currentType
protected
ParserHook::$forParserFunctions
ParserHook::$forTagExtensions
ParserHook::$frame
protected
ParserHook::$parser
protected
ParserHook::$parserHookOptions
protected
ParserHook::$registeredHooks = array()
staticprotected
ParserHook::$validator
protected
const ParserHook::FH_NO_HASH = 1

Flag for constructor, whether the function hook should be one callable without leading hash, i.e. {{plural:...}} instead of {{if:...}}

Since
0.4.13
const ParserHook::TYPE_FUNCTION = 1
const ParserHook::TYPE_TAG = 0

The documentation for this class was generated from the following file: