MediaWiki master
FallbackContentHandler.php
Go to the documentation of this file.
1<?php
30
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}
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.
getSlotDiffRendererInternal(IContextSource $context)
serializeContent(Content $content, $format=null)
Returns the content's data as-is.
fillParserOutput(Content $content, ContentParseParams $cpoParams, ParserOutput &$output)
Fills the ParserOutput with an error message.
__construct( $modelId, $formats=null)
Constructs an FallbackContentHandler.
unserializeContent( $blob, $format=null)
Constructs an FallbackContent instance wrapping the given data.
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.
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.