|
MediaWiki master
|
Base class for content handling. More...
Inherited by MediaWiki\Content\FallbackContentHandler, and MediaWiki\Content\TextContentHandler.
Public Member Functions | |
| __construct ( $modelId, $formats) | |
| Constructor, initializing the ContentHandler instance with its model ID and a list of supported formats. | |
| canBeUsedOn (Title $title) | |
| Determines whether the content type handled by this ContentHandler can be used for the main slot of the given page. | |
| createDifferenceEngine (IContextSource $context, $old=0, $new=0, $rcid=0, $refreshCache=false, $unhide=false) | |
| Factory for creating an appropriate DifferenceEngine for this content model. | |
| deserializeContentFromJsonArray (array $json) | |
| Deserializes a Content object of the type supported by this ContentHandler from a JsonCodecable array. | |
| exportTransform ( $blob, $format=null) | |
| Applies transformations on export (returns the blob unchanged by default). | |
| fillParserOutputInternal (Content $content, ContentParseParams $cpoParams, ParserOutput &$output) | |
| A temporary layer to move AbstractContent::fillParserOutput to ContentHandler::fillParserOutput. | |
| generateHTMLOnEdit () | |
| Whether an edit on the content should trigger an HTML render and ParserCache entry. | |
| getActionOverrides () | |
| Returns overrides for action handlers. | |
| getAutoDeleteReason (Title $title, &$hasHistory=false) | |
| Auto-generates a deletion reason. | |
| getAutosummary (?Content $oldContent=null, ?Content $newContent=null, $flags=0) | |
| Return an applicable auto-summary if one exists for the given edit. | |
| getChangeTag (?Content $oldContent=null, ?Content $newContent=null, $flags=0) | |
| Return an applicable tag if one exists for the given edit or return null. | |
| getDataForSearchIndex (WikiPage $page, ParserOutput $output, SearchEngine $engine, ?RevisionRecord $revision=null) | |
| Return fields to be indexed by search engine as representation of this document. | |
| getDefaultFormat () | |
| The format used for serialization/deserialization by default by this ContentHandler. | |
| getDeletionUpdates (Title $title, $role) | |
| Returns a list of DeferrableUpdate objects for removing information about content in some secondary data store. | |
| getFieldsForSearchIndex (SearchEngine $engine) | |
| Get fields definition for search index. | |
| getJsonFormat () | |
| Allow ContentHandler to chose a non-default format for JSON serialization. | |
| getModelID () | |
| Returns the model id that identifies the content model this ContentHandler can handle. | |
| getPageLanguage (Title $title, ?Content $content=null) | |
| Get the language in which the content of the given page is written. | |
| getPageViewLanguage (Title $title, ?Content $content=null) | |
| Get the language in which the content of this page is written when viewed by user. | |
| getParserOutput (Content $content, ContentParseParams $cpoParams) | |
| Returns a ParserOutput object containing information derived from this content. | |
| getParserOutputForIndexing (WikiPage $page, ?ParserCache $cache=null, ?RevisionRecord $revision=null) | |
| Produce page output suitable for indexing. | |
| getSecondaryDataUpdates (Title $title, Content $content, $role, SlotRenderingProvider $slotOutput) | |
| Returns a list of DeferrableUpdate objects for recording information about the given Content in some secondary data store. | |
| getSlotDiffRenderer (IContextSource $context, array $options=[]) | |
| Get an appropriate SlotDiffRenderer for this content model. | |
| getSupportedFormats () | |
| Returns a list of serialization formats supported by the serializeContent() and unserializeContent() methods of this ContentHandler. | |
| getUndoContent (Content $currentContent, Content $undoContent, Content $undoAfterContent, $undoIsLatest=false) | |
| Get the Content object that needs to be saved in order to undo all changes between $undo and $undoafter. | |
| importTransform ( $blob, $format=null) | |
| Apply import transformation (by default, returns $blob unchanged). | |
| isParserCacheSupported () | |
| Returns true for content models that support caching using the ParserCache mechanism. | |
| isSupportedFormat ( $format) | |
| Returns true if $format is a serialization format supported by this ContentHandler, and false otherwise. | |
| makeEmptyContent () | |
| Creates an empty Content object of the type supported by this ContentHandler. | |
| makeRedirectContent (Title $destination, $text='') | |
| Creates a new Content object that acts as a redirect to the given page, or null if redirects are not supported by this content model. | |
| merge3 (Content $oldContent, Content $myContent, Content $yourContent) | |
| Attempts to merge differences between three versions. | |
| preloadTransform (Content $content, PreloadTransformParams $pltParams) | |
| Returns a $content object with preload transformations applied (or the same object if no transformations apply). | |
| preSaveTransform (Content $content, PreSaveTransformParams $pstParams) | |
| Returns a $content object with pre-save transformations applied (or the same object if no transformations apply). | |
| serializeContent (Content $content, $format=null) | |
| Serializes a Content object of the type supported by this ContentHandler. | |
| serializeContentToJsonArray (Content $content) | |
| Serializes a Content object of the type supported by this ContentHandler to an array which is JsonCodecable. | |
| supportsCategories () | |
| Returns true if this content model supports categories. | |
| supportsDirectApiEditing () | |
| Whether or not this content model supports direct editing via ApiEditPage. | |
| supportsDirectEditing () | |
| Return true if this content model supports direct editing, such as via EditPage. | |
| supportsPreloadContent () | |
| If a non-existing page can be created with the contents from another (arbitrary) page being preloaded in the editor, see {. | |
| supportsRedirects () | |
| Returns true if this content model supports redirects. | |
| supportsSections () | |
| Returns true if this content model supports sections. | |
| unserializeContent ( $blob, $format=null) | |
| Unserializes a Content object of the type supported by this ContentHandler. | |
| validateSave (Content $content, ValidationParams $validationParams) | |
| Validate content for saving it. | |
Static Public Member Functions | |
| static | getLocalizedName ( $name, ?Language $lang=null) |
| Returns the localized name for a given content model. | |
| static | makeContent ( $text, ?Title $title=null, $modelId=null, $format=null) |
| Convenience function for creating a Content object from a given textual representation. | |
Protected Member Functions | |
| addSearchField (&$fields, SearchEngine $engine, $name, $type) | |
| Add new field definition to array. | |
| checkFormat ( $format) | |
| Convenient for checking whether a format provided as a parameter is actually supported. | |
| checkModelID ( $model_id) | |
| createTextSlotDiffRenderer (array $options=[]) | |
| Create a TextSlotDiffRenderer and inject dependencies. | |
| fillParserOutput (Content $content, ContentParseParams $cpoParams, ParserOutput &$output) | |
| Fills the provided ParserOutput with information derived from the content. | |
| getDiffEngineClass () | |
| Returns the name of the diff engine to use. | |
| getSlotDiffRendererInternal (IContextSource $context) | |
| Return the SlotDiffRenderer appropriate for this content handler. | |
| getSlotDiffRendererWithOptions (IContextSource $context, $options=[]) | |
| Return the SlotDiffRenderer appropriate for this content handler. | |
| latestRevision (WikiPage $page) | |
| Get the latest revision of the given $page, fetching it from the primary if necessary. | |
Protected Attributes | |
| string | $mModelID |
| string[] | $mSupportedFormats |
Base class for content handling.
A content handler knows how do deal with a specific type of content on a wiki page. Content is stored in the database in a serialized form (using a serialization format a.k.a. MIME type) and is unserialized into its native PHP representation (the content model), which is wrapped in an instance of the appropriate subclass of Content.
ContentHandler instances are stateless singletons that serve, among other things, as a factory for Content objects. Generally, there is one subclass of ContentHandler and one subclass of Content for every type of content model.
Some content types have a flat model, that is, their native representation is the same as their serialized form. Examples would be JavaScript and CSS code. As of now, this also applies to wikitext (MediaWiki's default content type), but wikitext content may be represented by a DOM or AST structure in the future.
Definition at line 76 of file ContentHandler.php.
| MediaWiki\Content\ContentHandler::__construct | ( | $modelId, | |
| $formats ) |
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.
| string | $modelId | (use CONTENT_MODEL_XXX constants). |
| string[] | $formats | List for supported serialization formats (typically as MIME types) |
Reimplemented in MediaWiki\Content\FallbackContentHandler, and MediaWiki\Content\TextContentHandler.
Definition at line 163 of file ContentHandler.php.
|
protected |
Add new field definition to array.
| SearchIndexField[] | &$fields | |
| SearchEngine | $engine | |
| string | $name | |
| string | $type |
Definition at line 1238 of file ContentHandler.php.
References MediaWiki\Search\SearchEngine\makeSearchFieldMapping().
| MediaWiki\Content\ContentHandler::canBeUsedOn | ( | Title | $title | ) |
Determines whether the content type handled by this ContentHandler can be used for the main slot of the given page.
This default implementation always returns true. Subclasses may override this to restrict the use of this content model to specific locations, typically based on the namespace or some other aspect of the title, such as a special suffix (e.g. ".svg" for SVG content).
| Title | $title | The page's title. |
Definition at line 673 of file ContentHandler.php.
|
protected |
Convenient for checking whether a format provided as a parameter is actually supported.
| string | $format | The serialization format to check |
| MWException | If the format is not supported by this content handler. |
Definition at line 391 of file ContentHandler.php.
Referenced by MediaWiki\Content\TextContentHandler\serializeContent(), and MediaWiki\Content\TextContentHandler\unserializeContent().
|
protected |
| string | $model_id | The model to check |
| MWException | If the provided model ID differs from this ContentHandler |
Definition at line 316 of file ContentHandler.php.
Referenced by MediaWiki\Content\TextContentHandler\merge3().
| MediaWiki\Content\ContentHandler::createDifferenceEngine | ( | IContextSource | $context, |
| $old = 0, | |||
| $new = 0, | |||
| $rcid = 0, | |||
| $refreshCache = false, | |||
| $unhide = false ) |
Factory for creating an appropriate DifferenceEngine for this content model.
Since 1.32, this is only used for page-level diffs; to diff two content objects, use getSlotDiffRenderer.
The DifferenceEngine subclass to use is selected in getDiffEngineClass(). The GetDifferenceEngine hook will receive the DifferenceEngine object and can replace or wrap it. (Note that in older versions of MediaWiki the hook documentation instructed extensions to return false from the hook; you should not rely on always being able to decorate the DifferenceEngine instance from the hook. If the owner of the content type wants to decorate the instance, overriding this method is a safer approach.)
| IContextSource | $context | Context to use, anything else will be ignored. |
| int | $old | Revision ID we want to show and diff with. |
| int | string | $new | Either a revision ID or one of the strings 'cur', 'prev' or 'next'. |
| int | $rcid | FIXME: Deprecated, no longer used. Defaults to 0. |
| bool | $refreshCache | If set, refreshes the diff cache. Defaults to false. |
| bool | $unhide | If set, allow viewing deleted revs. Defaults to false. |
Definition at line 450 of file ContentHandler.php.
|
finalprotected |
Create a TextSlotDiffRenderer and inject dependencies.
| array | $options | See getSlotDiffRenderer() |
Definition at line 535 of file ContentHandler.php.
| MediaWiki\Content\ContentHandler::deserializeContentFromJsonArray | ( | array | $json | ) |
Deserializes a Content object of the type supported by this ContentHandler from a JsonCodecable array.
| array | $json | Serialized form of the content |
| JsonException |
Reimplemented in MediaWiki\Content\WikitextContentHandler.
Definition at line 244 of file ContentHandler.php.
| MediaWiki\Content\ContentHandler::exportTransform | ( | $blob, | |
| $format = null ) |
Applies transformations on export (returns the blob unchanged by default).
Subclasses may override this to perform transformations such as conversion of legacy formats or filtering of internal meta-data.
| string | $blob | The blob to be exported |
| string | null | $format | The blob's serialization format |
Definition at line 213 of file ContentHandler.php.
|
protected |
Fills the provided ParserOutput with information derived from the content.
Unless $cpoParams->getGenerateHtml() was false, this includes an HTML representation of the content.
If $cpoParams->getGenerateHtml() is false, and you chose not to generate html, the ParserOutput must have a text of null. If the text of the ParserOutput object is anything other than null (even if ''), it is assumed that you don't support not generating html, and that it is safe to reuse the parser output for calls expecting that html was generated.
Subclasses are expected to override this method.
This placeholder implementation always throws an exception.
| Content | $content | |
| ContentParseParams | $cpoParams | |
| ParserOutput | &$output | The output object to fill (reference). Most implementations should modify the output object passed in here; if you choose to replace it with a fresh object instead, make sure you call ParserOutput::resetParseStartTime() on it. |
Reimplemented in MediaWiki\Content\CssContentHandler, MediaWiki\Content\FallbackContentHandler, MediaWiki\Content\JavaScriptContentHandler, MediaWiki\Content\TextContentHandler, MediaWiki\Content\VueContentHandler, MediaWiki\Content\JsonContentHandler, and MediaWiki\Content\WikitextContentHandler.
Definition at line 1642 of file ContentHandler.php.
| MediaWiki\Content\ContentHandler::fillParserOutputInternal | ( | Content | $content, |
| ContentParseParams | $cpoParams, | ||
| ParserOutput & | $output ) |
A temporary layer to move AbstractContent::fillParserOutput to ContentHandler::fillParserOutput.
| Content | $content | |
| ContentParseParams | $cpoParams | |
| ParserOutput | &$output | The output object to fill (reference). |
Definition at line 1609 of file ContentHandler.php.
| MediaWiki\Content\ContentHandler::generateHTMLOnEdit | ( | ) |
Whether an edit on the content should trigger an HTML render and ParserCache entry.
Definition at line 1170 of file ContentHandler.php.
| MediaWiki\Content\ContentHandler::getActionOverrides | ( | ) |
Returns overrides for action handlers.
Classes listed here will be used instead of the default one when (and only when) $wgActions[$action] === true. This allows subclasses to override the default action handlers.
Definition at line 419 of file ContentHandler.php.
| MediaWiki\Content\ContentHandler::getAutoDeleteReason | ( | Title | $title, |
| & | $hasHistory = false ) |
Auto-generates a deletion reason.
| Title | $title | The page's title |
| bool | &$hasHistory | Whether the page has a history |
Definition at line 927 of file ContentHandler.php.
References MediaWiki\Title\Title\getArticleID(), wfDeprecated(), and wfMessage().
| MediaWiki\Content\ContentHandler::getAutosummary | ( | ?Content | $oldContent = null, |
| ?Content | $newContent = null, | ||
| $flags = 0 ) |
Return an applicable auto-summary if one exists for the given edit.
| Content | null | $oldContent | The previous text of the page. |
| Content | null | $newContent | The submitted text of the page. |
| int | $flags | Bit mask: a bit mask of flags submitted for the edit. |
Definition at line 802 of file ContentHandler.php.
References wfMessage().
| MediaWiki\Content\ContentHandler::getChangeTag | ( | ?Content | $oldContent = null, |
| ?Content | $newContent = null, | ||
| $flags = 0 ) |
Return an applicable tag if one exists for the given edit or return null.
| Content | null | $oldContent | The previous text of the page. |
| Content | null | $newContent | The submitted text of the page. |
| int | $flags | Bit mask: a bit mask of flags submitted for the edit. |
Definition at line 890 of file ContentHandler.php.
| MediaWiki\Content\ContentHandler::getDataForSearchIndex | ( | WikiPage | $page, |
| ParserOutput | $output, | ||
| SearchEngine | $engine, | ||
| ?RevisionRecord | $revision = null ) |
Return fields to be indexed by search engine as representation of this document.
Overriding class should call parent function or take care of calling the SearchDataForIndex hook.
The $output must be the result of a call to getParserOutputForIndexing() on the same content handler. That method may return ParserOutput without HTML; this base implementation does not rely on the HTML being present, so it is safe to call even by subclasses that override getParserOutputForIndexing() to skip HTML generation. On the other hand, since the default implementation of getParserOutputForIndexing() does generate HTML, subclasses are free to rely on the HTML here if they do not override getParserOutputForIndexing().
| WikiPage | $page | Page to index |
| ParserOutput | $output | |
| SearchEngine | $engine | Search engine for which we are indexing |
| RevisionRecord | null | $revision | Revision content to fetch if provided or use the latest revision from WikiPage::getRevisionRecord() if not |
Reimplemented in MediaWiki\Content\TextContentHandler, MediaWiki\Content\FileContentHandler, and MediaWiki\Content\WikitextContentHandler.
Definition at line 1269 of file ContentHandler.php.
References MediaWiki\Page\WikiPage\getId(), and MediaWiki\Page\WikiPage\getRevisionRecord().
| MediaWiki\Content\ContentHandler::getDefaultFormat | ( | ) |
The format used for serialization/deserialization by default by this ContentHandler.
This default implementation will return the first element of the array of formats that was passed to the constructor.
Definition at line 348 of file ContentHandler.php.
Referenced by MediaWiki\Content\TextContentHandler\merge3().
| MediaWiki\Content\ContentHandler::getDeletionUpdates | ( | Title | $title, |
| $role ) |
Returns a list of DeferrableUpdate objects for removing information about content in some secondary data store.
This is used when a page is deleted, and also when a slot is removed from a page.
Application logic should not call this method directly. Instead, it should call WikiPage::getSecondaryDataUpdates().
| Title | $title | The title of the page to supply the updates for |
| string | $role | The role (slot) in which the content is being used. Which updates are performed should generally not depend on the role the content has, but the DeferrableUpdates themselves may need to know the role, to track to which slot the data refers, and to avoid overwriting data of the same kind from another slot. |
Definition at line 1445 of file ContentHandler.php.
|
protected |
Returns the name of the diff engine to use.
Definition at line 689 of file ContentHandler.php.
| MediaWiki\Content\ContentHandler::getFieldsForSearchIndex | ( | SearchEngine | $engine | ) |
Get fields definition for search index.
| SearchEngine | $engine |
Reimplemented in MediaWiki\Content\FileContentHandler, MediaWiki\Content\TextContentHandler, and MediaWiki\Content\WikitextContentHandler.
Definition at line 1197 of file ContentHandler.php.
References MediaWiki\Search\SearchEngine\makeSearchFieldMapping().
| MediaWiki\Content\ContentHandler::getJsonFormat | ( | ) |
Allow ContentHandler to chose a non-default format for JSON serialization.
In most cases will return the same as ::getDefaultFormat().
Definition at line 358 of file ContentHandler.php.
|
static |
Returns the localized name for a given content model.
Model names are localized using system messages. Message keys have the form content-model-$name, where $name is getContentModelName( $id ).
| string | $name | The content model ID, as given by a CONTENT_MODEL_XXX constant or returned by Content::getModel() or SlotRecord::getModel(). |
| Language | null | $lang | The language to parse the message in (since 1.26) |
Definition at line 126 of file ContentHandler.php.
References wfMessage().
| MediaWiki\Content\ContentHandler::getModelID | ( | ) |
Returns the model id that identifies the content model this ContentHandler can handle.
Use with the CONTENT_MODEL_XXX constants.
Definition at line 307 of file ContentHandler.php.
Referenced by MediaWiki\Content\FallbackContentHandler\unserializeContent().
Get the language in which the content of the given page is written.
This default implementation just returns the content language (except for pages in the MediaWiki namespace)
Note that the page's language is not cacheable, since it may in some cases depend on user settings.
Also note that the page language may or may not depend on the actual content of the page, that is, this method may load the content in order to determine the language.
| Title | $title | The page to determine the language for. |
| Content | null | $content | The page's content, if you have it handy, to avoid reloading it. |
Reimplemented in MediaWiki\Content\CodeContentHandler.
Definition at line 596 of file ContentHandler.php.
References MediaWiki\Title\Title\getText(), MediaWiki\Title\Title\inNamespace(), and NS_MEDIAWIKI.
Referenced by MediaWiki\Content\TextContentHandler\getDataForSearchIndex().
Get the language in which the content of this page is written when viewed by user.
Defaults to $this->getPageLanguage(), but if the user specified a preferred variant, the variant will be used.
This default implementation just returns $this->getPageLanguage( $title, $content ) unless the user specified a preferred variant.
Note that the pages view language is not cacheable, since it depends on user settings.
Also note that the page language may or may not depend on the actual content of the page, that is, this method may load the content in order to determine the language.
| Title | $title | The page to determine the language for. |
| Content | null | $content | The page's content, if you have it handy, to avoid reloading it. |
Reimplemented in MediaWiki\Content\CodeContentHandler.
Definition at line 637 of file ContentHandler.php.
References MediaWiki\Title\Title\getNamespace(), and NS_MEDIAWIKI.
| MediaWiki\Content\ContentHandler::getParserOutput | ( | Content | $content, |
| ContentParseParams | $cpoParams ) |
Returns a ParserOutput object containing information derived from this content.
Most importantly, unless $cpoParams->getGenerateHtml was false, the return value contains an HTML representation of the content.
Subclasses that want to control the parser output may override fillParserOutput() instead.
| Content | $content | |
| ContentParseParams | $cpoParams |
Definition at line 1536 of file ContentHandler.php.
References MediaWiki\Content\Renderer\ContentParseParams\getGenerateHtml(), MediaWiki\Content\Renderer\ContentParseParams\getPage(), MediaWiki\Content\Renderer\ContentParseParams\getParserOptions(), MediaWiki\Content\Content\getRedirectTarget(), and MediaWiki\Content\Renderer\ContentParseParams\getRevId().
| MediaWiki\Content\ContentHandler::getParserOutputForIndexing | ( | WikiPage | $page, |
| ?ParserCache | $cache = null, | ||
| ?RevisionRecord | $revision = null ) |
Produce page output suitable for indexing.
Typically used with getDataForSearchIndex().
Specific content handlers may override it if they need different content handling.
The default implementation returns output with HTML, but callers should not rely on this, and subclasses may override this method and skip HTML generation if it is not needed for indexing. (In that case, they should not attempt to store the output in the $cache.)
| WikiPage | $page | |
| ParserCache | null | $cache | deprecated since 1.38 and won't have any effect |
| RevisionRecord | null | $revision |
Definition at line 1331 of file ContentHandler.php.
References MediaWiki\Page\WikiPage\makeParserOptions().
| MediaWiki\Content\ContentHandler::getSecondaryDataUpdates | ( | Title | $title, |
| Content | $content, | ||
| $role, | |||
| SlotRenderingProvider | $slotOutput ) |
Returns a list of DeferrableUpdate objects for recording information about the given Content in some secondary data store.
Application logic should not call this method directly. Instead, it should call DerivedPageDataUpdater::getSecondaryDataUpdates().
| Title | $title | The title of the page to supply the updates for |
| Content | $content | The content to generate data updates for. |
| string | $role | The role (slot) in which the content is being used. Which updates are performed should generally not depend on the role the content has, but the DeferrableUpdates themselves may need to know the role, to track to which slot the data refers, and to avoid overwriting data of the same kind from another slot. |
| SlotRenderingProvider | $slotOutput | A provider that can be used to gain access to a ParserOutput of $content by calling $slotOutput->getSlotParserOutput( $role, false ). |
Definition at line 1406 of file ContentHandler.php.
|
final |
Get an appropriate SlotDiffRenderer for this content model.
| IContextSource | $context | |
| array | $options | An associative array of options passed to the SlotDiffRenderer:
|
Definition at line 477 of file ContentHandler.php.
|
protected |
Return the SlotDiffRenderer appropriate for this content handler.
| IContextSource | $context |
Definition at line 504 of file ContentHandler.php.
|
protected |
Return the SlotDiffRenderer appropriate for this content handler.
| IContextSource | $context | |
| array | $options | See getSlotDiffRenderer() |
Reimplemented in MediaWiki\Content\FallbackContentHandler.
Definition at line 517 of file ContentHandler.php.
References wfDeprecated().
| MediaWiki\Content\ContentHandler::getSupportedFormats | ( | ) |
Returns a list of serialization formats supported by the serializeContent() and unserializeContent() methods of this ContentHandler.
Definition at line 333 of file ContentHandler.php.
| MediaWiki\Content\ContentHandler::getUndoContent | ( | Content | $currentContent, |
| Content | $undoContent, | ||
| Content | $undoAfterContent, | ||
| $undoIsLatest = false ) |
Get the Content object that needs to be saved in order to undo all changes between $undo and $undoafter.
| Content | $currentContent | The current text |
| Content | $undoContent | The content of the revision to undo |
| Content | $undoAfterContent | Must be from an earlier revision than $undo |
| bool | $undoIsLatest | Set true if $undo is from the current revision (since 1.32) |
Definition at line 1048 of file ContentHandler.php.
References MediaWiki\Content\Content\equals(), and MediaWiki\Content\Content\getModel().
| MediaWiki\Content\ContentHandler::importTransform | ( | $blob, | |
| $format = null ) |
Apply import transformation (by default, returns $blob unchanged).
This gives subclasses an opportunity to transform data blobs on import.
| string | $blob | |
| string | null | $format |
Definition at line 264 of file ContentHandler.php.
| MediaWiki\Content\ContentHandler::isParserCacheSupported | ( | ) |
Returns true for content models that support caching using the ParserCache mechanism.
See WikiPage::shouldCheckParserCache().
Reimplemented in MediaWiki\Content\WikitextContentHandler.
Definition at line 1089 of file ContentHandler.php.
| MediaWiki\Content\ContentHandler::isSupportedFormat | ( | $format | ) |
Returns true if $format is a serialization format supported by this ContentHandler, and false otherwise.
Note that if $format is null, this method always returns true, because null means "use the default format".
| string | $format | The serialization format to check |
Definition at line 376 of file ContentHandler.php.
|
protected |
Get the latest revision of the given $page, fetching it from the primary if necessary.
| WikiPage | $page |
Definition at line 1357 of file ContentHandler.php.
References MediaWiki\Page\WikiPage\getRevisionRecord(), MediaWiki\Page\WikiPage\getTitle(), and MediaWiki\Page\WikiPage\loadPageData().
|
static |
Convenience function for creating a Content object from a given textual representation.
$text will be deserialized into a Content object of the model specified by $modelId (or, if that is not given, $title->getContentModel()) using the given format.
| string | $text | The textual representation, will be unserialized to create the Content object |
| Title | null | $title | The title of the page this text belongs to. Required if $modelId is not provided. |
| string | null | $modelId | The model to deserialize to. If not provided, $title->getContentModel() is used. |
| string | null | $format | The format to use for deserialization. If not given, the model's default format is used. |
| MWContentSerializationException | |
| MWUnknownContentModelException |
Definition at line 102 of file ContentHandler.php.
References MediaWiki\MediaWikiServices\getInstance().
|
abstract |
Creates an empty Content object of the type supported by this ContentHandler.
Reimplemented in MediaWiki\Content\FallbackContentHandler, MediaWiki\Content\JsonContentHandler, MediaWiki\Content\TextContentHandler, and MediaWiki\Content\VueContentHandler.
| MediaWiki\Content\ContentHandler::makeRedirectContent | ( | Title | $destination, |
| $text = '' ) |
Creates a new Content object that acts as a redirect to the given page, or null if redirects are not supported by this content model.
This default implementation always returns null. Subclasses supporting redirects must override this method.
Note that subclasses that override this method to return a Content object should also override supportsRedirects() to return true.
| Title | $destination | The page to redirect to. |
| string | $text | Text to include in the redirect, if possible. |
Reimplemented in MediaWiki\Content\CssContentHandler, MediaWiki\Content\JavaScriptContentHandler, and MediaWiki\Content\WikitextContentHandler.
Definition at line 296 of file ContentHandler.php.
| MediaWiki\Content\ContentHandler::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.
This default implementation always returns false.
| Content | $oldContent | The page's previous content. |
| Content | $myContent | One of the page's conflicting contents. |
| Content | $yourContent | One of the page's conflicting contents. |
Reimplemented in MediaWiki\Content\TextContentHandler.
Definition at line 708 of file ContentHandler.php.
| MediaWiki\Content\ContentHandler::preloadTransform | ( | Content | $content, |
| PreloadTransformParams | $pltParams ) |
Returns a $content object with preload transformations applied (or the same object if no transformations apply).
| Content | $content | |
| PreloadTransformParams | $pltParams |
Reimplemented in MediaWiki\Content\WikitextContentHandler.
Definition at line 1484 of file ContentHandler.php.
| MediaWiki\Content\ContentHandler::preSaveTransform | ( | Content | $content, |
| PreSaveTransformParams | $pstParams ) |
Returns a $content object with pre-save transformations applied (or the same object if no transformations apply).
| Content | $content | |
| PreSaveTransformParams | $pstParams |
Reimplemented in MediaWiki\Content\CssContentHandler, MediaWiki\Content\JavaScriptContentHandler, MediaWiki\Content\JsonContentHandler, MediaWiki\Content\TextContentHandler, and MediaWiki\Content\WikitextContentHandler.
Definition at line 1463 of file ContentHandler.php.
|
abstract |
Serializes a Content object of the type supported by this ContentHandler.
| Content | $content | The Content object to serialize |
| string | null | $format | The desired serialization format |
Reimplemented in MediaWiki\Content\FallbackContentHandler, MediaWiki\Content\TextContentHandler, and MediaWiki\Content\WikitextContentHandler.
| MediaWiki\Content\ContentHandler::serializeContentToJsonArray | ( | Content | $content | ) |
Serializes a Content object of the type supported by this ContentHandler to an array which is JsonCodecable.
| Content | $content | The Content object to serialize |
Reimplemented in MediaWiki\Content\WikitextContentHandler.
Definition at line 192 of file ContentHandler.php.
| MediaWiki\Content\ContentHandler::supportsCategories | ( | ) |
Returns true if this content model supports categories.
The default implementation returns true.
Definition at line 1116 of file ContentHandler.php.
| MediaWiki\Content\ContentHandler::supportsDirectApiEditing | ( | ) |
Whether or not this content model supports direct editing via ApiEditPage.
Definition at line 1181 of file ContentHandler.php.
| MediaWiki\Content\ContentHandler::supportsDirectEditing | ( | ) |
Return true if this content model supports direct editing, such as via EditPage.
This should return true for TextContent and its derivatives, and return false for structured data content.
Reimplemented in MediaWiki\Content\FallbackContentHandler, and MediaWiki\Content\TextContentHandler.
Definition at line 1144 of file ContentHandler.php.
| MediaWiki\Content\ContentHandler::supportsPreloadContent | ( | ) |
If a non-existing page can be created with the contents from another (arbitrary) page being preloaded in the editor, see {.
Reimplemented in MediaWiki\Content\JsonContentHandler, and MediaWiki\Content\WikitextContentHandler.
Definition at line 1158 of file ContentHandler.php.
| MediaWiki\Content\ContentHandler::supportsRedirects | ( | ) |
Returns true if this content model supports redirects.
This default implementation returns false.
Content models that return true here should also implement ContentHandler::makeRedirectContent to return a Content object.
Reimplemented in MediaWiki\Content\CssContentHandler, MediaWiki\Content\JavaScriptContentHandler, and MediaWiki\Content\WikitextContentHandler.
Definition at line 1131 of file ContentHandler.php.
| MediaWiki\Content\ContentHandler::supportsSections | ( | ) |
Returns true if this content model supports sections.
This default implementation returns false.
Content models that return true here should also implement Content::getSection, Content::replaceSection, etc. to handle sections.
Reimplemented in MediaWiki\Content\WikitextContentHandler.
Definition at line 1104 of file ContentHandler.php.
|
abstract |
Unserializes a Content object of the type supported by this ContentHandler.
| string | $blob | Serialized form of the content |
| string | null | $format | The format used for serialization |
| MWContentSerializationException |
Reimplemented in MediaWiki\Content\FallbackContentHandler, and MediaWiki\Content\TextContentHandler.
| MediaWiki\Content\ContentHandler::validateSave | ( | Content | $content, |
| ValidationParams | $validationParams ) |
Validate content for saving it.
This may be used to check the content's consistency with global state. This function should NOT write any information to the database.
Note that this method will usually be called inside the same transaction bracket that will be used to save the new revision, so the revision passed in is probably unsaved (has no id) and might belong to unsaved page.
| Content | $content | |
| ValidationParams | $validationParams |
Reimplemented in MediaWiki\Content\JsonContentHandler, and MediaWiki\Content\VueContentHandler.
Definition at line 1509 of file ContentHandler.php.
References MediaWiki\Content\Content\isValid().
|
protected |
Definition at line 145 of file ContentHandler.php.
|
protected |
Definition at line 150 of file ContentHandler.php.