Add new hook ImageBeforeProduceHTML, per request on Wikitech-l. If it sucks or is...
authorAryeh Gregor <simetrical@users.mediawiki.org>
Tue, 26 Feb 2008 17:20:39 +0000 (17:20 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Tue, 26 Feb 2008 17:20:39 +0000 (17:20 +0000)
docs/hooks.txt
includes/Linker.php

index 9e27a8d..21c9555 100644 (file)
@@ -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
index f1ae634..105e24b 100644 (file)
@@ -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" );