MediaWiki  master
FallbackContentHandler.php
Go to the documentation of this file.
1 <?php
28 
38 
51  public function __construct( $modelId, $formats = null ) {
52  parent::__construct(
53  $modelId,
54  $formats ?? [
55  'application/octet-stream',
56  'application/unknown',
57  'application/x-binary',
58  'text/unknown',
59  'unknown/unknown',
60  ]
61  );
62  }
63 
72  public function serializeContent( Content $content, $format = null ) {
74  '@phan-var FallbackContent $content';
75  return $content->getData();
76  }
77 
88  public function unserializeContent( $blob, $format = null ) {
89  return new FallbackContent( $blob, $this->getModelID() );
90  }
91 
99  public function makeEmptyContent() {
100  return $this->unserializeContent( '' );
101  }
102 
106  public function supportsDirectEditing() {
107  return false;
108  }
109 
118  protected function fillParserOutput(
120  ContentParseParams $cpoParams,
121  ParserOutput &$output
122  ) {
123  '@phan-var FallbackContent $content';
124  $msg = wfMessage( 'unsupported-content-model', [ $content->getModel() ] );
125  $html = Html::rawElement( 'div', [ 'class' => 'error' ], $msg->inContentLanguage()->parse() );
126  $output->setText( $html );
127  }
128 
134  protected function getSlotDiffRendererInternal( IContextSource $context ) {
135  return new UnsupportedSlotDiffRenderer( $context );
136  }
137 }
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:57
setText( $text)
Set the 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:39
Interface for objects which can provide a MediaWiki context on request.
$content
Definition: router.php:76