$modelId = $title->getContentModel();
}
- $handler = ContentHandler::getForModelID( $modelId );
+ $handler = self::getForModelID( $modelId );
return $handler->unserializeContent( $text, $format );
}
public static function getForTitle( Title $title ) {
$modelId = $title->getContentModel();
- return ContentHandler::getForModelID( $modelId );
+ return self::getForModelID( $modelId );
}
/**
public static function getForContent( Content $content ) {
$modelId = $content->getModel();
- return ContentHandler::getForModelID( $modelId );
+ return self::getForModelID( $modelId );
}
/**
public static function getForModelID( $modelId ) {
global $wgContentHandlers;
- if ( isset( ContentHandler::$handlers[$modelId] ) ) {
- return ContentHandler::$handlers[$modelId];
+ if ( isset( self::$handlers[$modelId] ) ) {
+ return self::$handlers[$modelId];
}
if ( empty( $wgContentHandlers[$modelId] ) ) {
wfDebugLog( 'ContentHandler', 'Created handler for ' . $modelId
. ': ' . get_class( $handler ) );
- ContentHandler::$handlers[$modelId] = $handler;
+ self::$handlers[$modelId] = $handler;
- return ContentHandler::$handlers[$modelId];
+ return self::$handlers[$modelId];
}
/**
public static function getContentModels() {
global $wgContentHandlers;
- return array_keys( $wgContentHandlers );
+ $models = array_keys( $wgContentHandlers );
+ Hooks::run( 'GetContentModels', [ &$models ] );
+ return $models;
}
public static function getAllContentFormats() {
$formats = [];
foreach ( $wgContentHandlers as $model => $class ) {
- $handler = ContentHandler::getForModelID( $model );
+ $handler = self::getForModelID( $model );
$formats = array_merge( $formats, $handler->getSupportedFormats() );
}
*/
public function createDifferenceEngine( IContextSource $context, $old = 0, $new = 0,
$rcid = 0, // FIXME: Deprecated, no longer used
- $refreshCache = false, $unhide = false ) {
-
+ $refreshCache = false, $unhide = false
+ ) {
// hook: get difference engine
$differenceEngine = null;
if ( !Hooks::run( 'GetDifferenceEngine',
$onlyAuthor = $row->rev_user_text;
// Try to find a second contributor
foreach ( $res as $row ) {
- if ( $row->rev_user_text != $onlyAuthor ) { // Bug 22999
+ if ( $row->rev_user_text != $onlyAuthor ) { // T24999
$onlyAuthor = false;
break;
}
* @return ParserOptions
*/
public function makeParserOptions( $context ) {
- global $wgContLang, $wgEnableParserLimitReporting;
+ global $wgContLang;
if ( $context instanceof IContextSource ) {
- $options = ParserOptions::newFromContext( $context );
+ $user = $context->getUser();
+ $lang = $context->getLanguage();
} elseif ( $context instanceof User ) { // settings per user (even anons)
- $options = ParserOptions::newFromUser( $context );
+ $user = $context;
+ $lang = null;
} elseif ( $context === 'canonical' ) { // canonical settings
- $options = ParserOptions::newFromUserAndLang( new User, $wgContLang );
+ $user = new User;
+ $lang = $wgContLang;
} else {
throw new MWException( "Bad context for parser options: $context" );
}
- $options->enableLimitReport( $wgEnableParserLimitReporting ); // show inclusion/loop reports
- $options->setTidy( true ); // fix bad HTML
-
- return $options;
+ return ParserOptions::newCanonical( $user, $lang );
}
/**
'category',
SearchIndexField::INDEX_TYPE_TEXT
);
-
$fields['category']->setFlag( SearchIndexField::FLAG_CASEFOLD );
$fields['external_link'] = $engine->makeSearchFieldMapping(
'template',
SearchIndexField::INDEX_TYPE_KEYWORD
);
-
$fields['template']->setFlag( SearchIndexField::FLAG_CASEFOLD );
+ $fields['content_model'] = $engine->makeSearchFieldMapping(
+ 'content_model',
+ SearchIndexField::INDEX_TYPE_KEYWORD
+ );
+
return $fields;
}
* @return array Map of name=>value for fields
* @since 1.28
*/
- public function getDataForSearchIndex( WikiPage $page, ParserOutput $output,
- SearchEngine $engine ) {
+ public function getDataForSearchIndex(
+ WikiPage $page,
+ ParserOutput $output,
+ SearchEngine $engine
+ ) {
$fieldData = [];
$content = $page->getContent();
$fieldData['text'] = $text;
$fieldData['source_text'] = $text;
$fieldData['text_bytes'] = $content->getSize();
+ $fieldData['content_model'] = $content->getModel();
}
Hooks::run( 'SearchDataForIndex', [ &$fieldData, $this, $page, $output, $engine ] );