X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fcontent%2FContentHandler.php;h=9ab11f3b68307d4a6635a09ba30e78a5567bdac1;hb=27d3f08d4e41ca5745c80a57afd441f9250db7e1;hp=acaa288f432d06c0fa09f806ff007958edf1840f;hpb=ff9f2fa33719753ff0c708f9b4a84c57593b9e58;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/content/ContentHandler.php b/includes/content/ContentHandler.php index acaa288f43..9ab11f3b68 100644 --- a/includes/content/ContentHandler.php +++ b/includes/content/ContentHandler.php @@ -227,7 +227,7 @@ abstract class ContentHandler { $model = MWNamespace::getNamespaceContentModel( $ns ); // Hook can determine default model - if ( !Hooks::run( 'ContentHandlerDefaultModelFor', array( $title, &$model ) ) ) { + if ( !Hooks::run( 'ContentHandlerDefaultModelFor', [ $title, &$model ] ) ) { if ( !is_null( $model ) ) { return $model; } @@ -240,7 +240,7 @@ abstract class ContentHandler { } // Hook can force JS/CSS - Hooks::run( 'TitleIsCssOrJsPage', array( $title, &$isCodePage ), '1.25' ); + Hooks::run( 'TitleIsCssOrJsPage', [ $title, &$isCodePage ], '1.25' ); // Is this a user subpage containing code? $isCodeSubpage = NS_USER == $ns @@ -255,7 +255,7 @@ abstract class ContentHandler { $isWikitext = $isWikitext && !$isCodePage && !$isCodeSubpage; // Hook can override $isWikitext - Hooks::run( 'TitleIsWikitextPage', array( $title, &$isWikitext ), '1.25' ); + Hooks::run( 'TitleIsWikitextPage', [ $title, &$isWikitext ], '1.25' ); if ( !$isWikitext ) { switch ( $ext ) { @@ -347,7 +347,7 @@ abstract class ContentHandler { if ( empty( $wgContentHandlers[$modelId] ) ) { $handler = null; - Hooks::run( 'ContentHandlerForModelID', array( $modelId, &$handler ) ); + Hooks::run( 'ContentHandlerForModelID', [ $modelId, &$handler ] ); if ( $handler === null ) { throw new MWUnknownContentModelException( $modelId ); @@ -357,11 +357,16 @@ abstract class ContentHandler { throw new MWException( "ContentHandlerForModelID must supply a ContentHandler instance" ); } } else { - $class = $wgContentHandlers[$modelId]; - $handler = new $class( $modelId ); + $classOrCallback = $wgContentHandlers[$modelId]; + + if ( is_callable( $classOrCallback ) ) { + $handler = call_user_func( $classOrCallback, $modelId ); + } else { + $handler = new $classOrCallback( $modelId ); + } if ( !( $handler instanceof ContentHandler ) ) { - throw new MWException( "$class from \$wgContentHandlers is not " . + throw new MWException( "$classOrCallback from \$wgContentHandlers is not " . "compatible with ContentHandler" ); } } @@ -409,7 +414,7 @@ abstract class ContentHandler { public static function getAllContentFormats() { global $wgContentHandlers; - $formats = array(); + $formats = []; foreach ( $wgContentHandlers as $model => $class ) { $handler = ContentHandler::getForModelID( $model ); @@ -639,7 +644,7 @@ abstract class ContentHandler { * @return array Always an empty array. */ public function getActionOverrides() { - return array(); + return []; } /** @@ -663,7 +668,7 @@ abstract class ContentHandler { // hook: get difference engine $differenceEngine = null; if ( !Hooks::run( 'GetDifferenceEngine', - array( $context, $old, $new, $refreshCache, $unhide, &$differenceEngine ) + [ $context, $old, $new, $refreshCache, $unhide, &$differenceEngine ] ) ) { return $differenceEngine; } @@ -700,7 +705,7 @@ abstract class ContentHandler { $pageLang = wfGetLangObj( $lang ); } - Hooks::run( 'PageContentLanguage', array( $title, &$pageLang, $wgLang ) ); + Hooks::run( 'PageContentLanguage', [ $title, &$pageLang, $wgLang ] ); return wfGetLangObj( $pageLang ); } @@ -759,7 +764,7 @@ abstract class ContentHandler { public function canBeUsedOn( Title $title ) { $ok = true; - Hooks::run( 'ContentModelCanBeUsedOn', array( $this->getModelID(), $title, &$ok ) ); + Hooks::run( 'ContentModelCanBeUsedOn', [ $this->getModelID(), $title, &$ok ] ); return $ok; } @@ -918,12 +923,12 @@ abstract class ContentHandler { // Find out if there was only one contributor // Only scan the last 20 revisions $res = $dbw->select( 'revision', 'rev_user_text', - array( + [ 'rev_page' => $title->getArticleID(), $dbw->bitAnd( 'rev_deleted', Revision::DELETED_USER ) . ' = 0' - ), + ], __METHOD__, - array( 'LIMIT' => 20 ) + [ 'LIMIT' => 20 ] ); if ( $res === false ) { @@ -1077,6 +1082,16 @@ abstract class ContentHandler { return false; } + /** + * Returns true if this content model supports categories. + * The default implementation returns true. + * + * @return bool Always true. + */ + public function supportsCategories() { + return true; + } + /** * Returns true if this content model supports redirects. * This default implementation returns false. @@ -1144,7 +1159,7 @@ abstract class ContentHandler { * * @see ContentHandler::$enableDeprecationWarnings */ - public static function runLegacyHooks( $event, $args = array(), + public static function runLegacyHooks( $event, $args = [], $warn = null ) { @@ -1161,7 +1176,7 @@ abstract class ContentHandler { // so we can find and fix them. $handlers = Hooks::getHandlers( $event ); - $handlerInfo = array(); + $handlerInfo = []; MediaWiki\suppressWarnings(); @@ -1193,8 +1208,8 @@ abstract class ContentHandler { } // convert Content objects to text - $contentObjects = array(); - $contentTexts = array(); + $contentObjects = []; + $contentTexts = []; foreach ( $args as $k => $v ) { if ( $v instanceof Content ) {