MediaWiki  master
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 }
137 
138 class_alias( FallbackContentHandler::class, 'UnknownContentHandler' );
ContentHandler
A content handler knows how do deal with a specific type of content on a wiki page.
Definition: ContentHandler.php:62
FallbackContentHandler\serializeContent
serializeContent(Content $content, $format=null)
Returns the content's data as-is.
Definition: FallbackContentHandler.php:71
ParserOutput
Definition: ParserOutput.php:35
UnsupportedSlotDiffRenderer
Produces a warning message about not being able to render a slot diff.
Definition: UnsupportedSlotDiffRenderer.php:31
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1167
FallbackContentHandler\unserializeContent
unserializeContent( $blob, $format=null)
Constructs an UnknownContent instance wrapping the given data.
Definition: FallbackContentHandler.php:87
MediaWiki\Content\Renderer\ContentParseParams
Definition: ContentParseParams.php:11
FallbackContentHandler\supportsDirectEditing
supportsDirectEditing()
Definition: FallbackContentHandler.php:105
$blob
$blob
Definition: testCompression.php:70
FallbackContentHandler\fillParserOutput
fillParserOutput(Content $content, ContentParseParams $cpoParams, ParserOutput &$output)
Fills the ParserOutput with an error message.
Definition: FallbackContentHandler.php:117
ParserOutput\setText
setText( $text)
Definition: ParserOutput.php:810
FallbackContent
Content object implementation representing unknown content.
Definition: FallbackContent.php:38
$content
$content
Definition: router.php:76
IContextSource
Interface for objects which can provide a MediaWiki context on request.
Definition: IContextSource.php:58
Content
Base interface for content objects.
Definition: Content.php:35
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:213
FallbackContentHandler\getSlotDiffRendererInternal
getSlotDiffRendererInternal(IContextSource $context)
Definition: FallbackContentHandler.php:133
FallbackContentHandler
Content handler implementation for unknown content.
Definition: FallbackContentHandler.php:36
ContentHandler\getModelID
getModelID()
Returns the model id that identifies the content model this ContentHandler can handle.
Definition: ContentHandler.php:476
FallbackContentHandler\makeEmptyContent
makeEmptyContent()
Creates an empty UnknownContent object.
Definition: FallbackContentHandler.php:98
FallbackContentHandler\__construct
__construct( $modelId, $formats=null)
Constructs an UnknownContentHandler.
Definition: FallbackContentHandler.php:50