MediaWiki master
FallbackContentHandler.php
Go to the documentation of this file.
1<?php
26namespace MediaWiki\Content;
27
34
44
57 public function __construct( $modelId, $formats = null ) {
58 parent::__construct(
59 $modelId,
60 $formats ?? [
61 'application/octet-stream',
62 'application/unknown',
63 'application/x-binary',
64 'text/unknown',
65 'unknown/unknown',
66 ]
67 );
68 }
69
78 public function serializeContent( Content $content, $format = null ) {
80 '@phan-var FallbackContent $content';
81 return $content->getData();
82 }
83
94 public function unserializeContent( $blob, $format = null ) {
95 return new FallbackContent( $blob, $this->getModelID() );
96 }
97
105 public function makeEmptyContent() {
106 return $this->unserializeContent( '' );
107 }
108
112 public function supportsDirectEditing() {
113 return false;
114 }
115
124 protected function fillParserOutput(
125 Content $content,
126 ContentParseParams $cpoParams,
127 ParserOutput &$output
128 ) {
129 '@phan-var FallbackContent $content';
130 $msg = wfMessage( 'unsupported-content-model', [ $content->getModel() ] );
131 $html = Html::rawElement( 'div', [ 'class' => 'error' ], $msg->inContentLanguage()->parse() );
132 $output->setRawText( $html );
133 }
134
140 protected function getSlotDiffRendererInternal( IContextSource $context ) {
141 return new UnsupportedSlotDiffRenderer( $context );
142 }
143}
145class_alias( FallbackContentHandler::class, 'FallbackContentHandler' );
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
A content handler knows how do deal with a specific type of content on a wiki page.
getModelID()
Returns the model id that identifies the content model this ContentHandler can handle.
Content handler implementation for unknown content.
makeEmptyContent()
Creates an empty FallbackContent object.
unserializeContent( $blob, $format=null)
Constructs an FallbackContent instance wrapping the given data.
fillParserOutput(Content $content, ContentParseParams $cpoParams, ParserOutput &$output)
Fills the ParserOutput with an error message.
serializeContent(Content $content, $format=null)
Returns the content's data as-is.
__construct( $modelId, $formats=null)
Constructs an FallbackContentHandler.
Content object implementation representing unknown content.
This class is a collection of static functions that serve two purposes:
Definition Html.php:56
ParserOutput is a rendering of a Content object or a message.
setRawText(?string $text)
Set the raw text of the ParserOutput.
Renders a diff for a single slot (that is, a diff between two content objects).
Produces a warning message about not being able to render a slot diff.
Base interface for representing page content.
Definition Content.php:39
getModel()
Returns the ID of the content model used by this Content object.
Interface for objects which can provide a MediaWiki context on request.