| 1 | <?php |
| 2 | |
| 3 | use MediaWiki\Content\AbstractContent; |
| 4 | use MediaWiki\Content\Content; |
| 5 | |
| 6 | class DummyNonTextContent extends AbstractContent { |
| 7 | |
| 8 | /** @var mixed */ |
| 9 | private $data; |
| 10 | |
| 11 | public function __construct( $data ) { |
| 12 | parent::__construct( "testing-nontext" ); |
| 13 | |
| 14 | $this->data = $data; |
| 15 | } |
| 16 | |
| 17 | public function serialize( $format = null ) { |
| 18 | return $this->data; |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * @return string A string representing the content in a way useful for |
| 23 | * building a full text search index. If no useful representation exists, |
| 24 | * this method returns an empty string. |
| 25 | */ |
| 26 | public function getTextForSearchIndex() { |
| 27 | return ''; |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * @return string|bool The wikitext to include when another page includes this content, |
| 32 | * or false if the content is not includable in a wikitext page. |
| 33 | */ |
| 34 | public function getWikitextForTransclusion() { |
| 35 | return false; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Returns a textual representation of the content suitable for use in edit |
| 40 | * summaries and log messages. |
| 41 | * |
| 42 | * @param int $maxlength Maximum length of the summary text. |
| 43 | * @return string The summary text. |
| 44 | */ |
| 45 | public function getTextForSummary( $maxlength = 250 ) { |
| 46 | return ''; |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Returns native representation of the data. Interpretation depends on the data model used, |
| 51 | * as given by getDataModel(). |
| 52 | * |
| 53 | * @return mixed The native representation of the content. Could be a string, a nested array |
| 54 | * structure, an object, a binary blob... anything, really. |
| 55 | */ |
| 56 | public function getNativeData() { |
| 57 | return $this->data; |
| 58 | } |
| 59 | |
| 60 | /** |
| 61 | * returns the content's nominal size in bogo-bytes. |
| 62 | * |
| 63 | * @return int |
| 64 | */ |
| 65 | public function getSize() { |
| 66 | return strlen( $this->data ); |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Return a copy of this Content object. The following must be true for the object returned |
| 71 | * if $copy = $original->copy() |
| 72 | * |
| 73 | * * get_class($original) === get_class($copy) |
| 74 | * * $original->getModel() === $copy->getModel() |
| 75 | * * $original->equals( $copy ) |
| 76 | * |
| 77 | * If and only if the Content object is immutable, the copy() method can and should |
| 78 | * return $this. That is, $copy === $original may be true, but only for imutable content |
| 79 | * objects. |
| 80 | * |
| 81 | * @return Content A copy of this object |
| 82 | */ |
| 83 | public function copy() { |
| 84 | return $this; |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Returns true if this content is countable as a "real" wiki page, provided |
| 89 | * that it's also in a countable location (e.g. a current revision in the main namespace). |
| 90 | * |
| 91 | * @param bool|null $hasLinks If it is known whether this content contains links, |
| 92 | * provide this information here, to avoid redundant parsing to find out. |
| 93 | * @return bool |
| 94 | */ |
| 95 | public function isCountable( $hasLinks = null ) { |
| 96 | return false; |
| 97 | } |
| 98 | } |