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.
 initPrinter ($isError)
 Initialize the printer function and prepare the output headers, etc.
 closePrinter ()
 Finish printing.
 printText ($text)
 The main format printing function.
 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


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


Member Function Documentation

ApiFormatBase::closePrinter (  ) 

Finish printing.

Closes HTML tags.

Definition at line 161 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 211 of file ApiFormatBase.php.

References $text, and $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 250 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 246 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 242 of file ApiFormatBase.php.

References ApiBase::getModuleName().

ApiFormatBase::getFormat (  ) 

Get the internal format name.

Returns:
string

Definition at line 77 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 100 of file ApiFormatBase.php.

Referenced by closePrinter(), ApiFormatXml::execute(), ApiFormatWddx::execute(), ApiFormatJson::execute(), getDescription(), 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 69 of file ApiFormatBase.php.

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

References $script, getIsHtml(), getMimeType(), is(), 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 180 of file ApiFormatBase.php.

References $text, formatHTML(), and getIsHtml().

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

ApiFormatBase::setHelp ( help = true  ) 

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

Parameters:
$help bool

Definition at line 201 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 90 of file ApiFormatBase.php.


Member Data Documentation

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 Sep 5 02:08:30 2009 for MediaWiki by  doxygen 1.5.9