* @ingroup Content
*/
abstract class AbstractContent implements Content {
-
/**
* Name of the content model this Content object represents.
* Use with CONTENT_MODEL_XXX constants
break;
}
// Redirects to some special pages are not permitted
- if ( $newtitle instanceOf Title && $newtitle->isValidRedirectTarget() ) {
+ if ( $newtitle instanceof Title && $newtitle->isValidRedirectTarget() ) {
// The new title passes the checks, so make that our current
// title so that further recursion can be checked
$title = $newtitle;
break;
}
}
+
return $titles;
}
*/
public function getUltimateRedirectTarget() {
$titles = $this->getRedirectChain();
+
return $titles ? array_pop( $titles ) : null;
}
* database after deletion.
*/
public function getDeletionUpdates( WikiPage $page,
- ParserOutput $parserOutput = null )
- {
+ ParserOutput $parserOutput = null
+ ) {
return array(
new LinksDeletionUpdate( $page ),
);
}
/**
- * This default implementation always returns false. Subclasses may override this to supply matching logic.
+ * This default implementation always returns false. Subclasses may override
+ * this to supply matching logic.
*
* @see Content::matchMagicWord
*
* This base implementation calls the hook ConvertContent to enable custom conversions.
* Subclasses may override this to implement conversion for "their" content model.
*
- * @param string $toModel the desired content model, use the CONTENT_MODEL_XXX flags.
- * @param string $lossy flag, set to "lossy" to allow lossy conversion. If lossy conversion is
+ * @param string $toModel the desired content model, use the CONTENT_MODEL_XXX flags.
+ * @param string $lossy flag, set to "lossy" to allow lossy conversion. If lossy conversion is
* not allowed, full round-trip conversion is expected to work without losing information.
*
* @return Content|bool A content object with the content model $toModel, or false if
$result = false;
wfRunHooks( 'ConvertContent', array( $this, $toModel, $lossy, &$result ) );
- return $result;
- }
-
- /**
- * Returns a ParserOutput object, filled by a call to fillParserOutput().
- * Subclasses that want to control the parser output may override this, or
- * they can override fillParserOutput(). If they override getParserOutput(),
- * itself, they should take care to call the ContentGetParserOutput hook.
- *
- * @param $title Title Context title for parsing
- * @param $revId int|null Revision ID (for {{REVISIONID}})
- * @param $options ParserOptions|null Parser options
- * @param $generateHtml bool Whether or not to generate HTML
- *
- * @return ParserOutput representing the HTML form of the text
- */
- public function getParserOutput( Title $title, $revId = null,
- ParserOptions $options = null, $generateHtml = true
- ) {
- # Generic implementation, relying on $this->getHtml()
-
- if ( $options === null ) {
- $options = $this->getContentHandler()->makeParserOptions( 'canonical' );
- }
- $po = new ParserOutput();
-
- if ( wfRunHooks( 'ContentGetParserOutput',
- array( $this, $title, $revId, $options, $generateHtml, &$po ) ) ) {
-
- $this->fillParserOutput( $title, $revId, $options, $generateHtml, $po );
- }
-
- return $po;
- }
-
- /**
- * Fills the provided ParserOutput object with the HTML returned by getHtml().
- * Subclasses should override this (or getParserOutput) appropriately.
- * This placeholder implementation always throws an exception.
- *
- * @param $title Title Context title for parsing
- * @param $revId int|null Revision ID (for {{REVISIONID}})
- * @param $options ParserOptions|null Parser options
- * @param $generateHtml bool Whether or not to generate HTML
- * @param &$output ParserOutput The output object to fill (reference).
- *
- * @throws MWException
- */
- protected function fillParserOutput( Title $title, $revId,
- ParserOptions $options, $generateHtml, ParserOutput &$output
- ) {
- // Don't make abstract, so subclasses that override getParserOutput() directly don't fail.
- throw new MWException( 'Subclasses of AbstractContent must override fillParserOutput!' );
+ return $result;
}
}