MediaWiki  master
FallbackContent.php
Go to the documentation of this file.
1 <?php
39 
41  private $data;
42 
47  public function __construct( $data, $model_id ) {
48  parent::__construct( $model_id );
49 
50  $this->data = $data;
51  }
52 
56  public function copy() {
57  // UnknownContent is immutable, so no need to copy.
58  return $this;
59  }
60 
68  public function getTextForSummary( $maxlength = 250 ) {
69  return '';
70  }
71 
77  public function getSize() {
78  return strlen( $this->data );
79  }
80 
89  public function isCountable( $hasLinks = null ) {
90  return false;
91  }
92 
96  public function getNativeData() {
97  return $this->getData();
98  }
99 
103  public function getData() {
104  return $this->data;
105  }
106 
112  public function serialize( $format = null ) {
113  return $this->getData();
114  }
115 
121  public function getTextForSearchIndex() {
122  return '';
123  }
124 
128  public function getWikitextForTransclusion() {
129  return false;
130  }
131 
140  protected function fillParserOutput( Title $title, $revId,
141  ParserOptions $options, $generateHtml, ParserOutput &$output
142  ) {
143  $msg = wfMessage( 'unsupported-content-model', [ $this->getModel() ] );
144  $html = Html::rawElement( 'div', [ 'class' => 'error' ], $msg->inContentLanguage()->parse() );
145  $output->setText( $html );
146  }
147 
153  public function convert( $toModel, $lossy = '' ) {
154  return false;
155  }
156 
157  protected function equalsInternal( Content $that ) {
158  if ( !$that instanceof FallbackContent ) {
159  return false;
160  }
161 
162  return $this->getData() == $that->getData();
163  }
164 
165 }
166 
167 class_alias( FallbackContent::class, 'UnknownContent' );
ParserOptions
Set options of the Parser.
Definition: ParserOptions.php:44
FallbackContent\$data
string $data
Definition: FallbackContent.php:41
ParserOutput
Definition: ParserOutput.php:25
FallbackContent\convert
convert( $toModel, $lossy='')
Definition: FallbackContent.php:153
FallbackContent\copy
copy()
Definition: FallbackContent.php:56
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1220
FallbackContent\__construct
__construct( $data, $model_id)
Definition: FallbackContent.php:47
FallbackContent\getWikitextForTransclusion
getWikitextForTransclusion()
Definition: FallbackContent.php:128
FallbackContent\getNativeData
getNativeData()
Definition: FallbackContent.php:96
FallbackContent\getTextForSummary
getTextForSummary( $maxlength=250)
Returns an empty string.
Definition: FallbackContent.php:68
FallbackContent\fillParserOutput
fillParserOutput(Title $title, $revId, ParserOptions $options, $generateHtml, ParserOutput &$output)
Fills the ParserOutput with an error message.
Definition: FallbackContent.php:140
$title
$title
Definition: testCompression.php:38
ParserOutput\setText
setText( $text)
Definition: ParserOutput.php:701
FallbackContent\isCountable
isCountable( $hasLinks=null)
Returns false.
Definition: FallbackContent.php:89
FallbackContent
Content object implementation representing unknown content.
Definition: FallbackContent.php:38
FallbackContent\equalsInternal
equalsInternal(Content $that)
Checks whether $that is logically equal to this Content object.
Definition: FallbackContent.php:157
FallbackContent\serialize
serialize( $format=null)
Definition: FallbackContent.php:112
AbstractContent
Base implementation for content objects.
Definition: AbstractContent.php:39
Content
Base interface for content objects.
Definition: Content.php:35
AbstractContent\getModel
getModel()
Definition: AbstractContent.php:67
AbstractContent\$model_id
string $model_id
Name of the content model this Content object represents.
Definition: AbstractContent.php:48
Title
Represents a title within MediaWiki.
Definition: Title.php:41
Html\rawElement
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
Definition: Html.php:209
FallbackContent\getTextForSearchIndex
getTextForSearchIndex()
Returns an empty string.
Definition: FallbackContent.php:121
FallbackContent\getSize
getSize()
Returns the data size in bytes.
Definition: FallbackContent.php:77
FallbackContent\getData
getData()
Definition: FallbackContent.php:103