MediaWiki  1.34.0
UnknownContent.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 getTextForSearchIndex() {
113  return '';
114  }
115 
119  public function getWikitextForTransclusion() {
120  return false;
121  }
122 
126  protected function fillParserOutput( Title $title, $revId,
127  ParserOptions $options, $generateHtml, ParserOutput &$output
128  ) {
129  $msg = wfMessage( 'unsupported-content-model', [ $this->getModel() ] );
130  $html = Html::rawElement( 'div', [ 'class' => 'error' ], $msg->inContentLanguage()->parse() );
131  $output->setText( $html );
132  }
133 
137  public function convert( $toModel, $lossy = '' ) {
138  return false;
139  }
140 
141  protected function equalsInternal( Content $that ) {
142  if ( !$that instanceof UnknownContent ) {
143  return false;
144  }
145 
146  return $this->getData() == $that->getData();
147  }
148 
149 }
ParserOptions
Set options of the Parser.
Definition: ParserOptions.php:42
UnknownContent\equalsInternal
equalsInternal(Content $that)
Checks whether $that is logically equal to this Content object.
Definition: UnknownContent.php:141
ParserOutput
Definition: ParserOutput.php:25
UnknownContent\getTextForSearchIndex
getTextForSearchIndex()
Returns an empty string.
Definition: UnknownContent.php:112
UnknownContent\getTextForSummary
getTextForSummary( $maxlength=250)
Returns an empty string.
Definition: UnknownContent.php:68
UnknownContent\copy
copy()
Definition: UnknownContent.php:56
UnknownContent\getWikitextForTransclusion
getWikitextForTransclusion()
Returns false.
Definition: UnknownContent.php:119
UnknownContent\fillParserOutput
fillParserOutput(Title $title, $revId, ParserOptions $options, $generateHtml, ParserOutput &$output)
Fills the ParserOutput with an error message.
Definition: UnknownContent.php:126
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1264
UnknownContent\$data
string $data
Definition: UnknownContent.php:41
UnknownContent
Content object implementation representing unknown content.
Definition: UnknownContent.php:38
UnknownContent\__construct
__construct( $data, $model_id)
Definition: UnknownContent.php:47
UnknownContent\isCountable
isCountable( $hasLinks=null)
Returns false.
Definition: UnknownContent.php:89
$title
$title
Definition: testCompression.php:34
$output
$output
Definition: SyntaxHighlight.php:335
AbstractContent
Base implementation for content objects.
Definition: AbstractContent.php:34
Content
Base interface for content objects.
Definition: Content.php:34
AbstractContent\getModel
getModel()
Definition: AbstractContent.php:60
AbstractContent\$model_id
$model_id
Name of the content model this Content object represents.
Definition: AbstractContent.php:43
Title
Represents a title within MediaWiki.
Definition: Title.php:42
UnknownContent\convert
convert( $toModel, $lossy='')
Returns false.
Definition: UnknownContent.php:137
UnknownContent\getSize
getSize()
Returns the data size in bytes.
Definition: UnknownContent.php:77
UnknownContent\getNativeData
getNativeData()
Definition: UnknownContent.php:96
UnknownContent\getData
getData()
Definition: UnknownContent.php:103