mediawiki-extensions-Scribunto/includes/common/ScribuntoContent.php
Roman Stolar 8c66ac25c9 Override ContentHandler::fillParserOutput instead of Content::fillParserOutput.
Prepare override for ScribuntoContentHandler, remove usage in ScribuntoContent.

Bug: T287158
Change-Id: I91f6a077f5cc0de25f83bea26d9f1772af0d3d68
2021-10-19 14:08:17 +00:00

41 lines
840 B
PHP

<?php
/**
* Scribunto Content Model
*
* @file
* @ingroup Extensions
* @ingroup Scribunto
*
* @author Brad Jorsch <bjorsch@wikimedia.org>
*/
/**
* Represents the content of a Scribunto script page
*/
class ScribuntoContent extends TextContent {
/**
* @param string $text
*/
public function __construct( $text ) {
parent::__construct( $text, CONTENT_MODEL_SCRIBUNTO );
}
/**
* Checks whether the script is valid
*
* @param Title $title
* @return Status
*/
public function validate( Title $title ) {
$engine = Scribunto::newDefaultEngine();
$engine->setTitle( $title );
return $engine->validate( $this->getText(), $title->getPrefixedDBkey() );
}
/** @inheritDoc */
public function prepareSave( WikiPage $page, $flags, $parentRevId, User $user ) {
return $this->validate( $page->getTitle() );
}
}