Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / content / FallbackContent.php
blobb4dbf7c854193689f3c34485d28b82a4cf6290f3
1 <?php
2 /**
3 * Content object implementation for representing unknown content.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @since 1.36 (As UnknownContent in 1.34)
22 * @file
23 * @ingroup Content
25 * @author Daniel Kinzler
28 namespace MediaWiki\Content;
30 /**
31 * Content object implementation representing unknown content.
33 * This can be used to handle content for which no ContentHandler exists on the system,
34 * perhaps because the extension that provided it has been removed.
36 * FallbackContent instances are immutable.
38 * @ingroup Content
40 class FallbackContent extends AbstractContent {
42 /** @var string */
43 private $data;
45 /**
46 * @param string $data
47 * @param string $model_id The model ID to handle
49 public function __construct( $data, $model_id ) {
50 parent::__construct( $model_id );
52 $this->data = $data;
55 /**
56 * @return Content $this
58 public function copy() {
59 // FallbackContent is immutable, so no need to copy.
60 return $this;
63 /**
64 * Returns an empty string.
66 * @param int $maxlength
68 * @return string
70 public function getTextForSummary( $maxlength = 250 ) {
71 return '';
74 /**
75 * Returns the data size in bytes.
77 * @return int
79 public function getSize() {
80 return strlen( $this->data );
83 /**
84 * Returns false.
86 * @param bool|null $hasLinks If it is known whether this content contains links,
87 * provide this information here, to avoid redundant parsing to find out.
89 * @return bool
91 public function isCountable( $hasLinks = null ) {
92 return false;
95 /**
96 * @return string data of unknown format and meaning
98 public function getNativeData() {
99 return $this->getData();
103 * @return string data of unknown format and meaning
105 public function getData() {
106 return $this->data;
110 * @param string|null $format
112 * @return string data of unknown format and meaning
114 public function serialize( $format = null ) {
115 return $this->getData();
119 * Returns an empty string.
121 * @return string The raw text.
123 public function getTextForSearchIndex() {
124 return '';
128 * @return false
130 public function getWikitextForTransclusion() {
131 return false;
135 * @param string $toModel
136 * @param string $lossy
137 * @return false
139 public function convert( $toModel, $lossy = '' ) {
140 return false;
143 protected function equalsInternal( Content $that ) {
144 if ( !$that instanceof FallbackContent ) {
145 return false;
148 return $this->getData() == $that->getData();
152 /** @deprecated class alias since 1.43 */
153 class_alias( FallbackContent::class, 'FallbackContent' );