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 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;
}
}
public function getParserOutput( Title $title,
$revId = null,
ParserOptions $options = null, $generateHtml = true );
+
// TODO: make RenderOutput and RenderOptions base classes
/**
* @since 1.21
*
* @param WikiPage $page The page to be saved.
- * @param int $flags bitfield for use with EDIT_XXX constants, see WikiPage::doEditContent()
- * @param int $baseRevId the ID of the current revision
- * @param User $user
+ * @param int $flags bitfield for use with EDIT_XXX constants, see WikiPage::doEditContent()
+ * @param int $baseRevId the ID of the current revision
+ * @param User $user
*
* @return Status A status object indicating whether the content was successfully prepared for saving.
* If the returned status indicates an error, a rollback will be performed and the
* Converts this content object into another content object with the given content model,
* if that is possible.
*
- * @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
* that conversion is not supported.
*/
public function convert( $toModel, $lossy = '' );
-
- // TODO: ImagePage and CategoryPage interfere with per-content action handlers
- // TODO: nice&sane integration of GeSHi syntax highlighting
+ // @todo ImagePage and CategoryPage interfere with per-content action handlers
+ // @todo nice&sane integration of GeSHi syntax highlighting
// [11:59] <vvv> Hooks are ugly; make CodeHighlighter interface and a
// config to set the class which handles syntax highlighting
// [12:00] <vvv> And default it to a DummyHighlighter
* not be unserialized using $format.
*/
public static function makeContent( $text, Title $title = null,
- $modelId = null, $format = null )
- {
+ $modelId = null, $format = null
+ ) {
if ( is_null( $modelId ) ) {
if ( is_null( $title ) ) {
throw new MWException( "Must provide a Title object or a content model ID." );
}
$handler = ContentHandler::getForModelID( $modelId );
+
return $handler->unserializeContent( $text, $format );
}
*/
public static function getForTitle( Title $title ) {
$modelId = $title->getContentModel();
+
return ContentHandler::getForModelID( $modelId );
}
*/
public static function getForContent( Content $content ) {
$modelId = $content->getModel();
+
return ContentHandler::getForModelID( $modelId );
}
}
wfDebugLog( 'ContentHandler', 'Created handler for ' . $modelId
- . ': ' . get_class( $handler ) );
+ . ': ' . get_class( $handler ) );
ContentHandler::$handlers[$modelId] = $handler;
+
return ContentHandler::$handlers[$modelId];
}
}
$formats = array_unique( $formats );
+
return $formats;
}
*
* @since 1.21
*
- * @param Title $title the page to determine the language for.
+ * @param Title $title the page to determine the language for.
* @param Content|null $content the page's content, if you have it handy, to avoid reloading it.
*
* @return Language the page's language
}
wfRunHooks( 'PageContentLanguage', array( $title, &$pageLang, $wgLang ) );
+
return wfGetLangObj( $pageLang );
}
*
* @since 1.21
*
- * @param Title $title the page to determine the language for.
+ * @param Title $title the page to determine the language for.
* @param Content|null $content the page's content, if you have it handy, to avoid reloading it.
*
* @return Language the page's language for viewing
if ( is_object( $rt ) ) {
if ( !is_object( $ot )
|| !$rt->equals( $ot )
- || $ot->getFragment() != $rt->getFragment() )
- {
+ || $ot->getFragment() != $rt->getFragment()
+ ) {
$truncatedtext = $newContent->getTextForSummary(
250
- - strlen( wfMessage( 'autoredircomment' )->inContentLanguage()->text() )
- - strlen( $rt->getFullText() ) );
+ - strlen( wfMessage( 'autoredircomment' )->inContentLanguage()->text() )
+ - strlen( $rt->getFullText() ) );
return wfMessage( 'autoredircomment', $rt->getFullText() )
- ->rawParams( $truncatedtext )->inContentLanguage()->text();
+ ->rawParams( $truncatedtext )->inContentLanguage()->text();
}
}
200 - strlen( wfMessage( 'autosumm-new' )->inContentLanguage()->text() ) );
return wfMessage( 'autosumm-new' )->rawParams( $truncatedtext )
- ->inContentLanguage()->text();
+ ->inContentLanguage()->text();
}
// Blanking auto-summaries
return wfMessage( 'autosumm-blank' )->inContentLanguage()->text();
} elseif ( !empty( $oldContent )
&& $oldContent->getSize() > 10 * $newContent->getSize()
- && $newContent->getSize() < 500 )
- {
+ && $newContent->getSize() < 500
+ ) {
// Removing more than 90% of the article
$truncatedtext = $newContent->getTextForSummary(
200 - strlen( wfMessage( 'autosumm-replace' )->inContentLanguage()->text() ) );
return wfMessage( 'autosumm-replace' )->rawParams( $truncatedtext )
- ->inContentLanguage()->text();
+ ->inContentLanguage()->text();
}
// If we reach this point, there's no applicable auto-summary for our
* Logs a deprecation warning, visible if $wgDevelopmentWarnings, but only if
* self::$enableDeprecationWarnings is set to true.
*
- * @param string $func The name of the deprecated function
- * @param string $version The version since the method is deprecated. Usually 1.21
- * for ContentHandler related stuff.
- * @param string|bool $component: Component to which the function belongs.
- * If false, it is assumed the function is in MediaWiki core.
+ * @param string $func The name of the deprecated function
+ * @param string $version The version since the method is deprecated. Usually 1.21
+ * for ContentHandler related stuff.
+ * @param string|bool $component : Component to which the function belongs.
+ * If false, it is assumed the function is in MediaWiki core.
*
* @see ContentHandler::$enableDeprecationWarnings
* @see wfDeprecated
* @see ContentHandler::$enableDeprecationWarnings
*/
public static function runLegacyHooks( $event, $args = array(),
- $warn = null ) {
+ $warn = null
+ ) {
if ( $warn === null ) {
$warn = self::$enableDeprecationWarnings;
protected $mMessage;
/**
- * @param Message|String $msg A Message object, or a message key
- * @param array|null $params An optional array of message parameters
+ * @param Message|String $msg A Message object, or a message key
+ * @param array|null $params An optional array of message parameters
*/
public function __construct( $msg, $params = null ) {
# XXX: messages may be wikitext, html or plain text! and maybe even something else entirely.
}
$po = new ParserOutput( $html );
+
return $po;
}
}
if ( $text === null || $text === false ) {
wfWarn( "TextContent constructed with \$text = " . var_export( $text, true ) . "! "
- . "This may indicate an error in the caller's scope." );
+ . "This may indicate an error in the caller's scope." );
$text = '';
}
*/
public function getSize() {
$text = $this->getNativeData();
+
return strlen( $text );
}
*/
public function getNativeData() {
$text = $this->mText;
+
return $text;
}
$nta = explode( "\n", $lang->segmentForDiff( $ntext ) );
$diff = new Diff( $ota, $nta );
+
return $diff;
}
}
$po->setText( $html );
+
return $po;
}
* This implementation provides lossless conversion between content models based
* on TextContent.
*
- * @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
*/
public function serializeContent( Content $content, $format = null ) {
$this->checkFormat( $format );
+
return $content->getNativeData();
}
}
$mergedContent = $this->unserializeContent( $result, $format );
+
return $mergedContent;
}
if ( $section === '' ) {
wfProfileOut( __METHOD__ );
+
return $with; # XXX: copy first?
- } if ( $section == 'new' ) {
+ }
+
+ if ( $section == 'new' ) {
# Inserting a new section
$subject = $sectionTitle ? wfMessage( 'newsectionheaderdefaultlevel' )
- ->rawParams( $sectionTitle )->inContentLanguage()->text() . "\n\n" : '';
+ ->rawParams( $sectionTitle )->inContentLanguage()->text() . "\n\n" : '';
if ( wfRunHooks( 'PlaceNewSection', array( $this, $oldtext, $subject, &$text ) ) ) {
$text = strlen( trim( $oldtext ) ) > 0
? "{$oldtext}\n\n{$subject}{$text}"
$newContent = new WikitextContent( $text );
wfProfileOut( __METHOD__ );
+
return $newContent;
}
if ( !$title instanceof Title || !$title->isValidRedirectTarget() ) {
return null;
}
+
return $title;
}
}
+
return null;
}
* Returns true if this content is not a redirect, and this content's text
* is countable according to the criteria defined by $wgArticleCountMethod.
*
- * @param bool $hasLinks if it is known whether this content contains
+ * @param bool $hasLinks if it is known whether this content contains
* links, provide this information here, to avoid redundant parsing to
* find out (default: null).
* @param $title Title: (default: null)
}
$po = $wgParser->parse( $this->getNativeData(), $title, $options, true, true, $revId );
+
return $po;
}