From eda6563be1b9b100a362bc0aa93921529003917a Mon Sep 17 00:00:00 2001 From: Rob Church Date: Sun, 2 Jul 2006 21:54:34 +0000 Subject: [PATCH] * Introduce 'BadImage' hook; see docs/hooks.txt for more information --- RELEASE-NOTES | 1 + docs/hooks.txt | 7 +++++++ includes/ImageFunctions.php | 29 ++++++++++++++++++----------- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 809e00b894..a0ae8d912a 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -632,6 +632,7 @@ Some default configuration options have changed: * Rename "searchquery" to "searchsubtitle" and support wiki text in it * Introduce updateArticleCount maintenance script which uses a better check that reflects what Article::isCountable() tests for +* Introduce 'BadImage' hook; see docs/hooks.txt for more information == Compatibility == diff --git a/docs/hooks.txt b/docs/hooks.txt index 2e7db307d1..4dd68f5f25 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -289,6 +289,13 @@ $section: section # 'AutoAuthenticate': called to authenticate users on external/environmental means $user: writes user object to this parameter +'BadImage': When checking against the bad image list +$name: Image name being checked +&$bad: Whether or not the image is "bad" + +Change $bad and return false to override. If an image is "bad", it is not +rendered inline in wiki pages or galleries in category pages. + 'BlockIp': before an IP address or user is blocked $block: the Block object about to be saved $user: the user _doing_ the block (not the one being blocked) diff --git a/includes/ImageFunctions.php b/includes/ImageFunctions.php index c031d7ef7f..691d7c9699 100644 --- a/includes/ImageFunctions.php +++ b/includes/ImageFunctions.php @@ -217,20 +217,27 @@ function wfGetSVGsize( $filename ) { */ function wfIsBadImage( $name ) { static $titleList = false; - - if( !$titleList ) { - # Build the list now - $titleList = array(); - $lines = explode( "\n", wfMsgForContent( 'bad_image_list' ) ); - foreach( $lines as $line ) { - if( preg_match( '/^\*\s*\[\[:?(.*?)\]\]/i', $line, $matches ) ) { - $title = Title::newFromText( $matches[1] ); - if( is_object( $title ) && $title->getNamespace() == NS_IMAGE ) - $titleList[ $title->getDBkey() ] = true; + wfProfileIn( __METHOD__ ); + $bad = false; + if( wfRunHooks( 'BadImage', array( $name, &$bad ) ) { + if( !$titleList ) { + # Build the list now + $titleList = array(); + $lines = explode( "\n", wfMsgForContent( 'bad_image_list' ) ); + foreach( $lines as $line ) { + if( preg_match( '/^\*\s*\[\[:?(.*?)\]\]/i', $line, $matches ) ) { + $title = Title::newFromText( $matches[1] ); + if( is_object( $title ) && $title->getNamespace() == NS_IMAGE ) + $titleList[ $title->getDBkey() ] = true; + } } } + wfProfileOut( __METHOD__ ); + return array_key_exists( $name, $titleList ); + } else { + wfProfileOut( __METHOD__ ); + return $bad; } - return array_key_exists( $name, $titleList ); } /** -- 2.20.1