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)
25 * @author Daniel Kinzler
28 namespace MediaWiki\Content
;
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.
40 class FallbackContent
extends AbstractContent
{
47 * @param string $model_id The model ID to handle
49 public function __construct( $data, $model_id ) {
50 parent
::__construct( $model_id );
56 * @return Content $this
58 public function copy() {
59 // FallbackContent is immutable, so no need to copy.
64 * Returns an empty string.
66 * @param int $maxlength
70 public function getTextForSummary( $maxlength = 250 ) {
75 * Returns the data size in bytes.
79 public function getSize() {
80 return strlen( $this->data
);
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.
91 public function isCountable( $hasLinks = null ) {
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() {
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() {
130 public function getWikitextForTransclusion() {
135 * @param string $toModel
136 * @param string $lossy
139 public function convert( $toModel, $lossy = '' ) {
143 protected function equalsInternal( Content
$that ) {
144 if ( !$that instanceof FallbackContent
) {
148 return $this->getData() == $that->getData();
152 /** @deprecated class alias since 1.43 */
153 class_alias( FallbackContent
::class, 'FallbackContent' );