MediaWiki master
FallbackContentHandler.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Content;
22
29
40
53 public function __construct( $modelId, $formats = null ) {
54 parent::__construct(
55 $modelId,
56 $formats ?? [
57 'application/octet-stream',
58 'application/unknown',
59 'application/x-binary',
60 'text/unknown',
61 'unknown/unknown',
62 ]
63 );
64 }
65
74 public function serializeContent( Content $content, $format = null ) {
76 '@phan-var FallbackContent $content';
77 return $content->getData();
78 }
79
90 public function unserializeContent( $blob, $format = null ) {
91 return new FallbackContent( $blob, $this->getModelID() );
92 }
93
101 public function makeEmptyContent() {
102 return $this->unserializeContent( '' );
103 }
104
108 public function supportsDirectEditing() {
109 return false;
110 }
111
120 protected function fillParserOutput(
121 Content $content,
122 ContentParseParams $cpoParams,
123 ParserOutput &$output
124 ) {
125 '@phan-var FallbackContent $content';
126 $msg = wfMessage( 'unsupported-content-model', [ $content->getModel() ] );
127 $html = Html::rawElement( 'div', [ 'class' => 'error' ], $msg->inContentLanguage()->parse() );
128 $output->setRawText( $html );
129 }
130
136 protected function getSlotDiffRendererInternal( IContextSource $context ) {
137 return new UnsupportedSlotDiffRenderer( $context );
138 }
139}
141class_alias( FallbackContentHandler::class, 'FallbackContentHandler' );
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Base class for content handling.
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:57
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.
Content objects represent page content, e.g.
Definition Content.php:42
getModel()
Get the content model ID.
Interface for objects which can provide a MediaWiki context on request.