MediaWiki master
FallbackContentHandler.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Content;
8
15
26
39 public function __construct( $modelId, $formats = null ) {
40 parent::__construct(
41 $modelId,
42 $formats ?? [
43 'application/octet-stream',
44 'application/unknown',
45 'application/x-binary',
46 'text/unknown',
47 'unknown/unknown',
48 ]
49 );
50 }
51
60 public function serializeContent( Content $content, $format = null ) {
62 '@phan-var FallbackContent $content';
63 return $content->getData();
64 }
65
76 public function unserializeContent( $blob, $format = null ) {
77 return new FallbackContent( $blob, $this->getModelID() );
78 }
79
87 public function makeEmptyContent() {
88 return $this->unserializeContent( '' );
89 }
90
94 public function supportsDirectEditing() {
95 return false;
96 }
97
105 protected function fillParserOutput(
106 Content $content,
107 ContentParseParams $cpoParams,
108 ParserOutput &$output
109 ) {
110 '@phan-var FallbackContent $content';
111 $msg = wfMessage( 'unsupported-content-model', [ $content->getModel() ] );
112 $html = Html::rawElement( 'div', [ 'class' => 'error' ], $msg->inContentLanguage()->parse() );
113 $output->setRawText( $html );
114 }
115
122 protected function getSlotDiffRendererWithOptions( IContextSource $context, $options = [] ) {
123 return new UnsupportedSlotDiffRenderer( $context );
124 }
125}
127class_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.
getSlotDiffRendererWithOptions(IContextSource $context, $options=[])
Content object implementation representing unknown content.
This class is a collection of static functions that serve two purposes:
Definition Html.php:43
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:28
getModel()
Get the content model ID.
Interface for objects which can provide a MediaWiki context on request.