From 4ee532af65dfbf7e0d4feb5ed0021040d0f9c579 Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Tue, 26 Feb 2008 17:20:39 +0000 Subject: [PATCH] Add new hook ImageBeforeProduceHTML, per request on Wikitech-l. If it sucks or is broken, please revert or fix. :) --- docs/hooks.txt | 16 +++++++++++++++- includes/Linker.php | 11 ++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index 9e27a8d059..21c955575e 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -602,10 +602,24 @@ $result: User permissions error to add. If none, return true. 'getUserPermissionsErrorsExpensive': Absolutely the same, but is called only if expensive checks are enabled. -'ImageOpenShowImageInlineBefore': Call potential extension just before showing the image on an image page +'ImageOpenShowImageInlineBefore': Call potential extension just before showing + the image on an image page $imagePage: ImagePage object ($this) $output: $wgOut +'ImageBeforeProduceHTML': Called before producing the HTML created by a wiki + image insertion. You can skip the default logic entirely by returning + false, or just modify a few things using call-by-reference. +&$this: Skin object +&$title: Title object of the image +&$file: File object, or false if it doesn't exist +&$frameParams: Various parameters with special meanings; see documentation in + includes/Linker.php for Linker::makeImageLink2 +&$handlerParams: Various parameters with special meanings; see documentation in + includes/Linker.php for Linker::makeImageLink2 +&$time: Timestamp of file in 'YYYYMMDDHHIISS' string form, or false for current +&$res: Final HTML output, used if you return false + 'InitPreferencesForm': called at the end of PreferencesForm's constructor $form: the PreferencesForm $request: the web request to initialized from diff --git a/includes/Linker.php b/includes/Linker.php index f1ae634126..105e24bb0b 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -496,7 +496,9 @@ class Linker { } /** - * Make an image link + * Given parameters derived from [[Image:Foo|options...]], generate the + * HTML that that syntax inserts in the page. + * * @param Title $title Title object * @param File $file File object, or false if it doesn't exist * @@ -519,8 +521,15 @@ class Linker { * @param array $handlerParams Associative array of media handler parameters, to be passed * to transform(). Typical keys are "width" and "page". * @param string $time, timestamp of the file, set as false for current + * @return string HTML for an image, with links, wrappers, etc. */ function makeImageLink2( Title $title, $file, $frameParams = array(), $handlerParams = array(), $time = false ) { + $res = null; + if( !wfRunHooks( 'ImageBeforeProduceHTML', array( &$this, &$title, + &$file, &$frameParams, &$handlerParams, &$time, &$res ) ) ) { + return $res; + } + global $wgContLang, $wgUser, $wgThumbLimits, $wgThumbUpright; if ( $file && !$file->allowInlineDisplay() ) { wfDebug( __METHOD__.': '.$title->getPrefixedDBkey()." does not allow inline display\n" ); -- 2.20.1