MediaWiki REL1_39
FallbackContentHandler.php
Go to the documentation of this file.
1<?php
27
37
50 public function __construct( $modelId, $formats = null ) {
51 parent::__construct(
52 $modelId,
53 $formats ?? [
54 'application/octet-stream',
55 'application/unknown',
56 'application/x-binary',
57 'text/unknown',
58 'unknown/unknown',
59 ]
60 );
61 }
62
71 public function serializeContent( Content $content, $format = null ) {
73 '@phan-var FallbackContent $content';
74 return $content->getData();
75 }
76
87 public function unserializeContent( $blob, $format = null ) {
88 return new FallbackContent( $blob, $this->getModelID() );
89 }
90
98 public function makeEmptyContent() {
99 return $this->unserializeContent( '' );
100 }
101
105 public function supportsDirectEditing() {
106 return false;
107 }
108
117 protected function fillParserOutput(
119 ContentParseParams $cpoParams,
120 ParserOutput &$output
121 ) {
122 '@phan-var FallbackContent $content';
123 $msg = wfMessage( 'unsupported-content-model', [ $content->getModel() ] );
124 $html = Html::rawElement( 'div', [ 'class' => 'error' ], $msg->inContentLanguage()->parse() );
125 $output->setText( $html );
126 }
127
133 protected function getSlotDiffRendererInternal( IContextSource $context ) {
134 return new UnsupportedSlotDiffRenderer( $context );
135 }
136}
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.
setText( $text)
Set the text of the ParserOutput.
Produces a warning message about not being able to render a slot diff.
Base interface for content objects.
Definition Content.php:35
Interface for objects which can provide a MediaWiki context on request.
$content
Definition router.php:76