ApiFormatBase Class Reference
[API]

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

Inherits ApiBase.

Inherited by ApiFormatDbg, ApiFormatFeedWrapper, ApiFormatJson, ApiFormatPhp, ApiFormatRaw, ApiFormatTxt, ApiFormatWddx, ApiFormatXml, and ApiFormatYaml.

List of all members.

Public Member Functions

 __construct ($main, $format)
 Constructor If $format ends with 'fm', pretty-print the output in HTML.
 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.
 getFormat ()
 Get the internal format name.
 setUnescapeAmps ($b)
 Specify whether or not sequences like " should be unescaped to " .
 getIsHtml ()
 Returns true when the HTML pretty-printer should be used.
 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.
 closePrinter ()
 Finish printing.
 printText ($text)
 The main format printing function.
 getBuffer ()
 Get the contents of the buffer.
 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$.
 getDescription ()
 Returns the description string for this module.

Static Public Member Functions

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

Protected Member Functions

 formatHTML ($text)
 Prety-print various elements in HTML format, such as xml tags and URLs.
 getExamples ()
 Returns usage examples for this module.

Private Attributes

 $mIsHtml
 $mFormat
 $mUnescapeAmps
 $mHelp
 $mCleared
 $mBufferResult = false
 $mBuffer


Detailed Description

This is the abstract base class for API formatters.

Definition at line 36 of file ApiFormatBase.php.


Constructor & Destructor Documentation

ApiFormatBase::__construct ( main,
format 
)

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

Parameters:
$main ApiMain
$format string Format name

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

Definition at line 47 of file ApiFormatBase.php.


Member Function Documentation

ApiFormatBase::closePrinter (  ) 

Finish printing.

Closes HTML tags.

Definition at line 172 of file ApiFormatBase.php.

References getIsHtml().

ApiFormatBase::formatHTML ( text  )  [protected]

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

This method also escapes characters like <

Parameters:
$text string
Returns:
string

Definition at line 236 of file ApiFormatBase.php.

References $wgUrlProtocols.

Referenced by printText().

static ApiFormatBase::getBaseVersion (  )  [static]

Returns a string that identifies the version of this class.

Returns:
string

Reimplemented from ApiBase.

Definition at line 275 of file ApiFormatBase.php.

ApiFormatBase::getBuffer (  ) 

Get the contents of the buffer.

Definition at line 212 of file ApiFormatBase.php.

ApiFormatBase::getDescription (  ) 

Returns the description string for this module.

Returns:
mixed string or array of strings

Reimplemented from ApiBase.

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

Definition at line 271 of file ApiFormatBase.php.

References getIsHtml().

ApiFormatBase::getExamples (  )  [protected]

Returns usage examples for this module.

Return null if no examples are available.

Returns:
mixed string or array of strings

Reimplemented from ApiBase.

Definition at line 267 of file ApiFormatBase.php.

References ApiBase::getModuleName().

ApiFormatBase::getFormat (  ) 

Get the internal format name.

Returns:
string

Definition at line 78 of file ApiFormatBase.php.

ApiFormatBase::getIsHtml (  ) 

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 101 of file ApiFormatBase.php.

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

ApiFormatBase::getMimeType (  )  [abstract]

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, ApiFormatDbg, ApiFormatJson, ApiFormatPhp, ApiFormatRaw, ApiFormatTxt, ApiFormatWddx, ApiFormatXml, and ApiFormatYaml.

Referenced by initPrinter().

ApiFormatBase::getNeedsRawData (  ) 

Whether this formatter needs raw data such as _element tags.

Returns:
bool

Reimplemented in ApiFormatFeedWrapper, ApiFormatJson, and ApiFormatXml.

Definition at line 70 of file ApiFormatBase.php.

ApiFormatBase::getWantsHelp (  ) 

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 111 of file ApiFormatBase.php.

References getIsHtml().

ApiFormatBase::initPrinter ( isError  ) 

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:
$isError bool Whether an error message is printed

Definition at line 121 of file ApiFormatBase.php.

References $script, getIsHtml(), getMimeType(), and wfScript().

ApiFormatBase::printText ( text  ) 

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:
$text string

Definition at line 191 of file ApiFormatBase.php.

References formatHTML(), and getIsHtml().

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

ApiFormatBase::setBufferResult ( value  ) 

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

Definition at line 218 of file ApiFormatBase.php.

ApiFormatBase::setHelp ( help = true  ) 

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

Parameters:
$help bool

Definition at line 226 of file ApiFormatBase.php.

ApiFormatBase::setUnescapeAmps ( b  ) 

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:
$b bool Whether or not ampersands should be escaped.

Definition at line 91 of file ApiFormatBase.php.


Member Data Documentation

ApiFormatBase::$mBuffer [private]

Definition at line 39 of file ApiFormatBase.php.

ApiFormatBase::$mBufferResult = false [private]

Definition at line 39 of file ApiFormatBase.php.

ApiFormatBase::$mCleared [private]

Definition at line 38 of file ApiFormatBase.php.

ApiFormatBase::$mFormat [private]

Definition at line 38 of file ApiFormatBase.php.

ApiFormatBase::$mHelp [private]

Definition at line 38 of file ApiFormatBase.php.

ApiFormatBase::$mIsHtml [private]

Definition at line 38 of file ApiFormatBase.php.

ApiFormatBase::$mUnescapeAmps [private]

Definition at line 38 of file ApiFormatBase.php.


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

Generated on Sat Apr 30 22:57:30 2011 for MediaWiki by  doxygen 1.5.9