mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Scribunto
synced 2025-01-22 10:37:16 +00:00
8c66ac25c9
Prepare override for ScribuntoContentHandler, remove usage in ScribuntoContent. Bug: T287158 Change-Id: I91f6a077f5cc0de25f83bea26d9f1772af0d3d68
41 lines
840 B
PHP
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() );
|
|
}
|
|
}
|