MediaWiki master
FallbackContentHandler.php
Go to the documentation of this file.
1<?php
26namespace MediaWiki\Content;
27
28use Content;
36
46
59 public function __construct( $modelId, $formats = null ) {
60 parent::__construct(
61 $modelId,
62 $formats ?? [
63 'application/octet-stream',
64 'application/unknown',
65 'application/x-binary',
66 'text/unknown',
67 'unknown/unknown',
68 ]
69 );
70 }
71
80 public function serializeContent( Content $content, $format = null ) {
82 '@phan-var FallbackContent $content';
83 return $content->getData();
84 }
85
96 public function unserializeContent( $blob, $format = null ) {
97 return new FallbackContent( $blob, $this->getModelID() );
98 }
99
107 public function makeEmptyContent() {
108 return $this->unserializeContent( '' );
109 }
110
114 public function supportsDirectEditing() {
115 return false;
116 }
117
126 protected function fillParserOutput(
127 Content $content,
128 ContentParseParams $cpoParams,
129 ParserOutput &$output
130 ) {
131 '@phan-var FallbackContent $content';
132 $msg = wfMessage( 'unsupported-content-model', [ $content->getModel() ] );
133 $html = Html::rawElement( 'div', [ 'class' => 'error' ], $msg->inContentLanguage()->parse() );
134 $output->setRawText( $html );
135 }
136
142 protected function getSlotDiffRendererInternal( IContextSource $context ) {
143 return new UnsupportedSlotDiffRenderer( $context );
144 }
145}
147class_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:37
getModel()
Returns the ID of the content model used by this Content object.
Interface for objects which can provide a MediaWiki context on request.