MediaWiki  REL1_24
JsonContent Class Reference

Represents the content of a JSON content. More...

Inheritance diagram for JsonContent:
Collaboration diagram for JsonContent:

List of all members.

Public Member Functions

 __construct ($text, $modelId=CONTENT_MODEL_JSON)
 beautifyJSON ()
 Pretty-print JSON.
 getJsonData ()
 Decodes the JSON into a PHP associative array.
 isValid ()
 preSaveTransform (Title $title, User $user, ParserOptions $popts)
 Beautifies JSON prior to save.

Protected Member Functions

 fillParserOutput (Title $title, $revId, ParserOptions $options, $generateHtml, ParserOutput &$output)
 Set the HTML and add the appropriate styles.
 objectRow ($key, $val)
 Constructs HTML representation of a single key-value pair.
 objectTable ($mapping)
 Constructs an HTML representation of a JSON object.

Detailed Description

Represents the content of a JSON content.

Since:
1.24

Definition at line 15 of file JsonContent.php.


Constructor & Destructor Documentation

JsonContent::__construct ( text,
model_id = CONTENT_MODEL_JSON 
)
Parameters:
string$text
string$model_id

Reimplemented from TextContent.

Definition at line 17 of file JsonContent.php.


Member Function Documentation

Pretty-print JSON.

Returns:
bool|null|string

Definition at line 41 of file JsonContent.php.

References FormatJson\decode(), FormatJson\encode(), and TextContent\getNativeData().

Referenced by preSaveTransform().

JsonContent::fillParserOutput ( Title title,
revId,
ParserOptions options,
generateHtml,
ParserOutput &$  output 
) [protected]

Set the HTML and add the appropriate styles.

Parameters:
Title$title
int$revId
ParserOptions$options
bool$generateHtml
ParserOutput$output

Reimplemented from TextContent.

Definition at line 71 of file JsonContent.php.

References $generateHtml, ParserOutput\addModuleStyles(), getJsonData(), objectTable(), and ParserOutput\setText().

Decodes the JSON into a PHP associative array.

Returns:
array

Definition at line 25 of file JsonContent.php.

References FormatJson\decode(), and TextContent\getNativeData().

Referenced by fillParserOutput(), and isValid().

Returns:
bool Whether content is valid JSON.

Reimplemented from AbstractContent.

Definition at line 32 of file JsonContent.php.

References getJsonData().

JsonContent::objectRow ( key,
val 
) [protected]

Constructs HTML representation of a single key-value pair.

Parameters:
string$key
mixed$val
Returns:
string HTML.

Definition at line 103 of file JsonContent.php.

References $key, array(), Xml\elementClean(), FormatJson\encode(), and Xml\tags().

Referenced by objectTable().

JsonContent::objectTable ( mapping) [protected]

Constructs an HTML representation of a JSON object.

Parameters:
array$mapping
Returns:
string HTML

Definition at line 86 of file JsonContent.php.

References $key, array(), as, objectRow(), and Xml\tags().

Referenced by fillParserOutput().

JsonContent::preSaveTransform ( Title title,
User user,
ParserOptions popts 
)

Beautifies JSON prior to save.

Parameters:
Title$titleTitle
User$userUser
ParserOptions$popts
Returns:
JsonContent

Reimplemented from TextContent.

Definition at line 57 of file JsonContent.php.

References beautifyJSON().


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