MediaWiki  REL1_19
ApiFormatBase Class Reference

This is the abstract base class for API formatters. More...

Inheritance diagram for ApiFormatBase:
Collaboration diagram for ApiFormatBase:

List of all members.

Public Member Functions

 __construct ($main, $format)
 Constructor If $format ends with 'fm', pretty-print the output in HTML.
 closePrinter ()
 Finish printing.
 disable ()
 Disable the formatter completely.
 getBuffer ()
 Get the contents of the buffer.
 getDescription ()
 Returns the description string for this module.
 getExamples ()
 Returns usage examples for this module.
 getFormat ()
 Get the internal format name.
 getHelpUrls ()
 getIsHtml ()
 Returns true when the HTML pretty-printer should be used.
 getMimeType ()
 Overriding class returns the mime type that should be sent to the client.
 getNeedsRawData ()
 Whether this formatter needs raw data such as _element tags.
 getWantsHelp ()
 Whether this formatter can format the help message in a nice way.
 initPrinter ($isError)
 Initialize the printer function and prepare the output headers, etc.
 isDisabled ()
 printText ($text)
 The main format printing function.
 setBufferResult ($value)
 Set the flag to buffer the result instead of printing it.
 setHelp ($help=true)
 Sets whether the pretty-printer should format *bold* and $italics$.
 setUnescapeAmps ($b)
 Specify whether or not sequences like " should be unescaped to " .

Static Public Member Functions

static getBaseVersion ()
 Returns a string that identifies the version of this class.

Public Attributes

 $mBuffer
 $mCleared
 $mDisabled = false
 $mFormat
 $mHelp
 $mUnescapeAmps

Protected Member Functions

 formatHTML ($text)
 Pretty-print various elements in HTML format, such as xml tags and URLs.

Private Attributes

 $mBufferResult = false
 $mIsHtml

Detailed Description

This is the abstract base class for API formatters.

Definition at line 32 of file ApiFormatBase.php.


Constructor & Destructor Documentation

ApiFormatBase::__construct ( main,
format 
)

Constructor If $format ends with 'fm', pretty-print the output in HTML.

Parameters:
$mainApiMain
$formatstring Format name

Reimplemented in ApiFormatXmlRsd, ApiFormatXml, ApiFormatRaw, ApiFormatJson, ApiFormatDbg, ApiFormatDump, ApiFormatPhp, ApiFormatTxt, and ApiFormatWddx.

Definition at line 43 of file ApiFormatBase.php.


Member Function Documentation

Finish printing.

Closes HTML tags.

Definition at line 191 of file ApiFormatBase.php.

References getIsHtml().

Here is the call graph for this function:

Disable the formatter completely.

This causes calls to initPrinter(), printText() and closePrinter() to be ignored.

Definition at line 116 of file ApiFormatBase.php.

ApiFormatBase::formatHTML ( text) [protected]

Pretty-print various elements in HTML format, such as xml tags and URLs.

This method also escapes characters like <

Parameters:
$textstring
Returns:
string

Definition at line 262 of file ApiFormatBase.php.

References $matches, and wfUrlProtocolsWithoutProtRel().

Referenced by printText().

Here is the call graph for this function:

Here is the caller graph for this function:

static ApiFormatBase::getBaseVersion ( ) [static]

Returns a string that identifies the version of this class.

Returns:
string

Reimplemented from ApiBase.

Definition at line 324 of file ApiFormatBase.php.

Get the contents of the buffer.

Definition at line 236 of file ApiFormatBase.php.

Returns the description string for this module.

Returns:
mixed string or array of strings

Reimplemented from ApiBase.

Reimplemented in ApiFormatXml, ApiFormatWddx, ApiFormatJson, ApiFormatDump, ApiFormatDbg, ApiFormatTxt, ApiFormatPhp, and ApiFormatYaml.

Definition at line 320 of file ApiFormatBase.php.

References getIsHtml().

Here is the call graph for this function:

Returns usage examples for this module.

Return false if no examples are available.

Returns:
false|string|array

Reimplemented from ApiBase.

Definition at line 309 of file ApiFormatBase.php.

References ApiBase\getModuleName().

Here is the call graph for this function:

Get the internal format name.

Returns:
string

Definition at line 75 of file ApiFormatBase.php.

Returns:
false|string|array Returns a false if the module has no help url, else returns a (array of) string

Reimplemented from ApiBase.

Definition at line 316 of file ApiFormatBase.php.

Returns true when the HTML pretty-printer should be used.

The default implementation assumes that formats ending with 'fm' should be formatted in HTML.

Returns:
bool

Definition at line 98 of file ApiFormatBase.php.

Referenced by closePrinter(), ApiFormatWddx\execute(), ApiFormatXml\execute(), ApiFormatJson\execute(), getDescription(), getWantsHelp(), initPrinter(), printText(), and ApiFormatWddx\slowWddxPrinter().

Here is the caller graph for this function:

Overriding class returns the mime type that should be sent to the client.

This method is not called if getIsHtml() returns true.

Returns:
string

Reimplemented in ApiFormatFeedWrapper, ApiFormatXmlRsd, ApiFormatRaw, ApiFormatXml, ApiFormatJson, ApiFormatDbg, ApiFormatDump, ApiFormatPhp, ApiFormatTxt, ApiFormatWddx, and ApiFormatYaml.

Referenced by initPrinter().

Here is the caller graph for this function:

Whether this formatter needs raw data such as _element tags.

Returns:
bool

Reimplemented in ApiFormatFeedWrapper, ApiFormatJson, and ApiFormatXml.

Definition at line 67 of file ApiFormatBase.php.

Whether this formatter can format the help message in a nice way.

By default, this returns the same as getIsHtml(). When action=help is set explicitly, the help will always be shown

Returns:
bool

Reimplemented in ApiFormatJson.

Definition at line 108 of file ApiFormatBase.php.

References getIsHtml().

Here is the call graph for this function:

Initialize the printer function and prepare the output headers, etc.

This method must be the first outputing method during execution. A help screen's header is printed for the HTML-based output

Parameters:
$isErrorbool Whether an error message is printed

Definition at line 130 of file ApiFormatBase.php.

References $mime, $wgApiFrameOptions, echo, getIsHtml(), ApiBase\getMain(), getMimeType(), and wfScript().

Here is the call graph for this function:

Definition at line 120 of file ApiFormatBase.php.

The main format printing function.

Call it to output the result string to the user. This function will automatically output HTML when format name ends in 'fm'.

Parameters:
$textstring

Definition at line 213 of file ApiFormatBase.php.

References echo, formatHTML(), and getIsHtml().

Referenced by ApiFormatXml\addXslt(), ApiFormatPhp\execute(), ApiFormatWddx\execute(), ApiFormatDump\execute(), ApiFormatDbg\execute(), ApiFormatTxt\execute(), ApiFormatXml\execute(), ApiFormatRaw\execute(), ApiFormatJson\execute(), and ApiFormatWddx\slowWddxPrinter().

Here is the call graph for this function:

Here is the caller graph for this function:

Set the flag to buffer the result instead of printing it.

Parameters:
$valuebool

Definition at line 244 of file ApiFormatBase.php.

ApiFormatBase::setHelp ( help = true)

Sets whether the pretty-printer should format *bold* and $italics$.

Parameters:
$helpbool

Definition at line 252 of file ApiFormatBase.php.

Specify whether or not sequences like &quot; should be unescaped to " .

This should only be set to true for the help message when rendered in the default (xmlfm) format. This is a temporary special-case fix that should be removed once the help has been reworked to use a fully HTML interface.

Parameters:
$bbool Whether or not ampersands should be escaped.

Definition at line 88 of file ApiFormatBase.php.


Member Data Documentation

ApiFormatBase::$mBuffer

Definition at line 35 of file ApiFormatBase.php.

ApiFormatBase::$mBufferResult = false [private]

Definition at line 35 of file ApiFormatBase.php.

ApiFormatBase::$mCleared

Definition at line 34 of file ApiFormatBase.php.

ApiFormatBase::$mDisabled = false

Definition at line 35 of file ApiFormatBase.php.

ApiFormatBase::$mFormat

Definition at line 34 of file ApiFormatBase.php.

ApiFormatBase::$mHelp

Definition at line 34 of file ApiFormatBase.php.

ApiFormatBase::$mIsHtml [private]

Definition at line 34 of file ApiFormatBase.php.

ApiFormatBase::$mUnescapeAmps

Definition at line 34 of file ApiFormatBase.php.


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