From 7ed75c87caace88a43d70b9b09918f02acf38c7d Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Tue, 2 Aug 2011 15:40:27 +0000 Subject: [PATCH] Introduce a hook so extensions can customize what's considered to be a CSS/JS page. This is needed for the Gadgets extension in the RL2 branch --- docs/hooks.txt | 4 ++++ includes/Title.php | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index c74dbd8a1f..7e4eb0a1d7 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1743,6 +1743,10 @@ $res: database result used to create the object $title: The title in question. &$types: The types of protection available. +'TitleIsCssOrJsPage': Called when determining if a page is a CSS or JS page +$title: Title object that is being checked +$result: Boolean; whether MediaWiki currently thinks this is a CSS/JS page. Hooks may change this value to override the return value of Title::isCssOrJsPage() + 'TitleMoveComplete': after moving an article (title) $old: old title $nt: new title diff --git a/includes/Title.php b/includes/Title.php index 3eae96048a..ca0838acb8 100644 --- a/includes/Title.php +++ b/includes/Title.php @@ -1949,8 +1949,10 @@ class Title { * @return Bool */ public function isCssOrJsPage() { - return $this->mNamespace == NS_MEDIAWIKI + $retval = $this->mNamespace == NS_MEDIAWIKI && preg_match( '!\.(?:css|js)$!u', $this->mTextform ) > 0; + wfRunHooks( 'TitleIsCssOrJsPage', array( $this, &$retval ) ); + return $retval; } /** -- 2.20.1