DummyContentForTesting.php 3.5 KB

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