X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fcontent%2FContentHandler.php;h=a188e488220975fedbf282582fceaeed6d31a835;hb=4e90d55fdc9d31d93e24cf05687eb7d180806f44;hp=8c806c65172f6fb8e0a0de893b48674f07522ca8;hpb=a756c3b753e34a479da69a88a3176fd2d3e7cfa2;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/content/ContentHandler.php b/includes/content/ContentHandler.php index 8c806c6517..a188e48822 100644 --- a/includes/content/ContentHandler.php +++ b/includes/content/ContentHandler.php @@ -207,26 +207,26 @@ abstract class ContentHandler { } } - // Could this page contain custom CSS or JavaScript, based on the title? - $isCssOrJsPage = NS_MEDIAWIKI == $ns && preg_match( '!\.(css|js)$!u', $title->getText(), $m ); - if ( $isCssOrJsPage ) { + // Could this page contain code based on the title? + $isCodePage = NS_MEDIAWIKI == $ns && preg_match( '!\.(css|js|json)$!u', $title->getText(), $m ); + if ( $isCodePage ) { $ext = $m[1]; } // Hook can force JS/CSS - Hooks::run( 'TitleIsCssOrJsPage', array( $title, &$isCssOrJsPage ), '1.25' ); + Hooks::run( 'TitleIsCssOrJsPage', array( $title, &$isCodePage ), '1.25' ); - // Is this a .css subpage of a user page? - $isJsCssSubpage = NS_USER == $ns - && !$isCssOrJsPage - && preg_match( "/\\/.*\\.(js|css)$/", $title->getText(), $m ); - if ( $isJsCssSubpage ) { + // Is this a user subpage containing code? + $isCodeSubpage = NS_USER == $ns + && !$isCodePage + && preg_match( "/\\/.*\\.(js|css|json)$/", $title->getText(), $m ); + if ( $isCodeSubpage ) { $ext = $m[1]; } // Is this wikitext, according to $wgNamespaceContentModels or the DefaultModelFor hook? $isWikitext = is_null( $model ) || $model == CONTENT_MODEL_WIKITEXT; - $isWikitext = $isWikitext && !$isCssOrJsPage && !$isJsCssSubpage; + $isWikitext = $isWikitext && !$isCodePage && !$isCodeSubpage; // Hook can override $isWikitext Hooks::run( 'TitleIsWikitextPage', array( $title, &$isWikitext ), '1.25' ); @@ -237,6 +237,8 @@ abstract class ContentHandler { return CONTENT_MODEL_JAVASCRIPT; case 'css': return CONTENT_MODEL_CSS; + case 'json': + return CONTENT_MODEL_JSON; default: return is_null( $model ) ? CONTENT_MODEL_TEXT : $model; } @@ -626,8 +628,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 ); } @@ -1050,6 +1059,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.