ContentHandler: remove last wfRunHooks() call in includes
[lhc/web/wiklou.git] / includes / content / ContentHandler.php
index 9aa42dd..f8d0879 100644 (file)
@@ -201,7 +201,7 @@ abstract class ContentHandler {
                $model = MWNamespace::getNamespaceContentModel( $ns );
 
                // Hook can determine default model
-               if ( !wfRunHooks( 'ContentHandlerDefaultModelFor', array( $title, &$model ) ) ) {
+               if ( !Hooks::run( 'ContentHandlerDefaultModelFor', array( $title, &$model ) ) ) {
                        if ( !is_null( $model ) ) {
                                return $model;
                        }
@@ -214,7 +214,7 @@ abstract class ContentHandler {
                }
 
                // Hook can force JS/CSS
-               wfRunHooks( 'TitleIsCssOrJsPage', array( $title, &$isCssOrJsPage ), '1.25' );
+               Hooks::run( 'TitleIsCssOrJsPage', array( $title, &$isCssOrJsPage ), '1.25' );
 
                // Is this a .css subpage of a user page?
                $isJsCssSubpage = NS_USER == $ns
@@ -229,7 +229,7 @@ abstract class ContentHandler {
                $isWikitext = $isWikitext && !$isCssOrJsPage && !$isJsCssSubpage;
 
                // Hook can override $isWikitext
-               wfRunHooks( 'TitleIsWikitextPage', array( $title, &$isWikitext ), '1.25' );
+               Hooks::run( 'TitleIsWikitextPage', array( $title, &$isWikitext ), '1.25' );
 
                if ( !$isWikitext ) {
                        switch ( $ext ) {
@@ -318,7 +318,7 @@ abstract class ContentHandler {
                if ( empty( $wgContentHandlers[$modelId] ) ) {
                        $handler = null;
 
-                       wfRunHooks( 'ContentHandlerForModelID', array( $modelId, &$handler ) );
+                       Hooks::run( 'ContentHandlerForModelID', array( $modelId, &$handler ) );
 
                        if ( $handler === null ) {
                                throw new MWException( "No handler for model '$modelId' registered in \$wgContentHandlers" );
@@ -626,8 +626,15 @@ abstract class ContentHandler {
        public function createDifferenceEngine( IContextSource $context, $old = 0, $new = 0,
                $rcid = 0, //FIXME: Deprecated, no longer used
                $refreshCache = false, $unhide = false ) {
-               $diffEngineClass = $this->getDiffEngineClass();
 
+               // hook: get difference engine
+               $differenceEngine = null;
+               if ( !Hooks::run( 'GetDifferenceEngine',
+                       array( $context, $old, $new, $refreshCache, $unhide, &$differenceEngine )
+               ) ) {
+                       return $differenceEngine;
+               }
+               $diffEngineClass = $this->getDiffEngineClass();
                return new $diffEngineClass( $context, $old, $new, $rcid, $refreshCache, $unhide );
        }
 
@@ -660,7 +667,7 @@ abstract class ContentHandler {
                        $pageLang = wfGetLangObj( $lang );
                }
 
-               wfRunHooks( 'PageContentLanguage', array( $title, &$pageLang, $wgLang ) );
+               Hooks::run( 'PageContentLanguage', array( $title, &$pageLang, $wgLang ) );
 
                return wfGetLangObj( $pageLang );
        }
@@ -719,7 +726,7 @@ abstract class ContentHandler {
        public function canBeUsedOn( Title $title ) {
                $ok = true;
 
-               wfRunHooks( 'ContentModelCanBeUsedOn', array( $this->getModelID(), $title, &$ok ) );
+               Hooks::run( 'ContentModelCanBeUsedOn', array( $this->getModelID(), $title, &$ok ) );
 
                return $ok;
        }
@@ -1050,6 +1057,24 @@ abstract class ContentHandler {
                return false;
        }
 
+       /**
+        * Return true if this content model supports direct editing, such as via EditPage.
+        *
+        * @return bool Default is false, and true for TextContent and it's derivatives.
+        */
+       public function supportsDirectEditing() {
+               return false;
+       }
+
+       /**
+        * Whether or not this content model supports direct editing via ApiEditPage
+        *
+        * @return bool Default is false, and true for TextContent and derivatives.
+        */
+       public function supportsDirectApiEditing() {
+               return $this->supportsDirectEditing();
+       }
+
        /**
         * Logs a deprecation warning, visible if $wgDevelopmentWarnings, but only if
         * self::$enableDeprecationWarnings is set to true.
@@ -1151,7 +1176,7 @@ abstract class ContentHandler {
                }
 
                // call the hook functions
-               $ok = wfRunHooks( $event, $args );
+               $ok = Hooks::run( $event, $args );
 
                // see if the hook changed the text
                foreach ( $contentTexts as $k => $orig ) {