MediaWiki  REL1_24
TextContentHandler Class Reference

Base content handler implementation for flat text contents. More...

Inheritance diagram for TextContentHandler:
Collaboration diagram for TextContentHandler:

List of all members.

Public Member Functions

 __construct ($modelId=CONTENT_MODEL_TEXT, $formats=array(CONTENT_FORMAT_TEXT))
 Constructor, initializing the ContentHandler instance with its model ID and a list of supported formats.
 makeEmptyContent ()
 Creates an empty TextContent object.
 merge3 (Content $oldContent, Content $myContent, Content $yourContent)
 Attempts to merge differences between three versions.
 serializeContent (Content $content, $format=null)
 Returns the content's text as-is.
 unserializeContent ($text, $format=null)
 Unserializes a Content object of the type supported by this ContentHandler.

Protected Member Functions

 getContentClass ()
 Returns the name of the associated Content class, to be used when creating new objects.

Detailed Description

Base content handler implementation for flat text contents.

Definition at line 31 of file TextContentHandler.php.


Constructor & Destructor Documentation

Constructor, initializing the ContentHandler instance with its model ID and a list of supported formats.

Values for the parameters are typically provided as literals by subclass's constructors.

Parameters:
string$modelId(use CONTENT_MODEL_XXX constants).
string[]$formats List for supported serialization formats (typically as MIME types)

Reimplemented from ContentHandler.

Definition at line 34 of file TextContentHandler.php.


Member Function Documentation

Returns the name of the associated Content class, to be used when creating new objects.

Override expected by subclasses.

Since:
1.24
Returns:
string

Reimplemented in CodeContentHandler, CssContentHandler, JavaScriptContentHandler, WikitextContentHandler, and JsonContentHandler.

Definition at line 104 of file TextContentHandler.php.

Referenced by makeEmptyContent(), and unserializeContent().

Creates an empty TextContent object.

Since:
1.21
Returns:
Content A new TextContent object with empty text.

Reimplemented from ContentHandler.

Reimplemented in RevisionTestModifyableContentHandler.

Definition at line 132 of file TextContentHandler.php.

References getContentClass().

Referenced by merge3().

TextContentHandler::merge3 ( Content oldContent,
Content myContent,
Content yourContent 
)

Attempts to merge differences between three versions.

Returns a new Content object for a clean merge and false for failure or a conflict.

All three Content objects passed as parameters must have the same content model.

This text-based implementation uses wfMerge().

Parameters:
Content$oldContentThe page's previous content.
Content$myContentOne of the page's conflicting contents.
Content$yourContentOne of the page's conflicting contents.
Returns:
Content|bool

Reimplemented from ContentHandler.

Definition at line 69 of file TextContentHandler.php.

References $ok, $result, ContentHandler\checkModelID(), ContentHandler\getDefaultFormat(), Content\getModel(), makeEmptyContent(), serializeContent(), unserializeContent(), and wfMerge().

TextContentHandler::serializeContent ( Content content,
format = null 
)

Returns the content's text as-is.

Parameters:
Content$content
string$formatThe serialization format to check
Returns:
mixed

Reimplemented from ContentHandler.

Definition at line 48 of file TextContentHandler.php.

References ContentHandler\checkFormat(), and Content\getNativeData().

Referenced by merge3().

TextContentHandler::unserializeContent ( text,
format = null 
)

Unserializes a Content object of the type supported by this ContentHandler.

Since:
1.21
Parameters:
string$textSerialized form of the content
string$formatThe format used for serialization
Returns:
Content The TextContent object wrapping $text

Reimplemented from ContentHandler.

Reimplemented in RevisionTestModifyableContentHandler.

Definition at line 118 of file TextContentHandler.php.

References ContentHandler\checkFormat(), and getContentClass().

Referenced by merge3().


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