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
25 * @author Daniel Kinzler
29 * Content object implementation representing unknown content.
31 * This can be used to handle content for which no ContentHandler exists on the system,
32 * perhaps because the extension that provided it has been removed.
34 * UnknownContent instances are immutable.
38 class UnknownContent
extends AbstractContent
{
45 * @param string $model_id The model ID to handle
47 public function __construct( $data, $model_id ) {
48 parent
::__construct( $model_id );
54 * @return Content $this
56 public function copy() {
57 // UnknownContent is immutable, so no need to copy.
62 * Returns an empty string.
64 * @param int $maxlength
68 public function getTextForSummary( $maxlength = 250 ) {
73 * Returns the data size in bytes.
77 public function getSize() {
78 return strlen( $this->data
);
84 * @param bool|null $hasLinks If it is known whether this content contains links,
85 * provide this information here, to avoid redundant parsing to find out.
89 public function isCountable( $hasLinks = null ) {
94 * @return string data of unknown format and meaning
96 public function getNativeData() {
97 return $this->getData();
101 * @return string data of unknown format and meaning
103 public function getData() {
108 * Returns an empty string.
110 * @return string The raw text.
112 public function getTextForSearchIndex() {
119 public function getWikitextForTransclusion() {
124 * Fills the ParserOutput with an error message.
126 protected function fillParserOutput( Title
$title, $revId,
127 ParserOptions
$options, $generateHtml, ParserOutput
&$output
129 $msg = wfMessage( 'unsupported-content-model', [ $this->getModel() ] );
130 $html = Html
::rawElement( 'div', [ 'class' => 'error' ], $msg->inContentLanguage()->parse() );
131 $output->setText( $html );
137 public function convert( $toModel, $lossy = '' ) {
141 protected function equalsInternal( Content
$that ) {
142 if ( !$that instanceof UnknownContent
) {
146 return $this->getData() == $that->getData();