New hook, AfterParserFetchFileAndTitle
authorMax Semenik <maxsem.wiki@gmail.com>
Fri, 13 Jun 2014 23:08:52 +0000 (16:08 -0700)
committerkaldari <rkaldari@wikimedia.org>
Wed, 2 Jul 2014 00:40:11 +0000 (17:40 -0700)
It is needed for PageImages to collect information about galleries, improving results
for Commons mainspace.

Bug: 66510
Change-Id: I3136d648ef2c1841767db0ab33855cd168e3de3e

docs/hooks.txt
includes/gallery/ImageGalleryBase.php
includes/parser/Parser.php

index 1673f06..b1ef47c 100644 (file)
@@ -326,6 +326,13 @@ $revCount: Number of revisions in the XML file
 $sRevCount: Number of successfully imported revisions
 $pageInfo: associative array of page information
 
+'AfterParserFetchFileAndTitle': After an image gallery is formed by Parser,
+just before adding its HTML to parser output.
+$parser: Parser object that called the hook
+$ig: Gallery, an object of one of the gallery classes (inheriting from
+ImageGalleryBase)
+$html: HTML generated by the gallery
+
 'AjaxAddScript': Called in output page just before the initialisation
 of the javascript ajax engine. The hook is only called when ajax
 is enabled ( $wgUseAjax = true; ).
index 8d2b949..837a731 100644 (file)
@@ -258,6 +258,14 @@ abstract class ImageGalleryBase extends ContextSource {
                array_unshift( $this->mImages, array( &$title, $html, $alt, $link, $handlerOpts ) );
        }
 
+       /**
+        * Returns the list of images this gallery contains
+        * @return array
+        */
+       public function getImages() {
+               return $this->mImages;
+       }
+
        /**
         * isEmpty() returns true if the gallery contains no images
         * @return bool
index eb7bd1b..89ed60d 100644 (file)
@@ -5369,6 +5369,7 @@ class Parser {
                        $ig->add( $title, $label, $alt, $link, $handlerOptions );
                }
                $html = $ig->toHTML();
+               wfRunHooks( 'AfterParserFetchFileAndTitle', array( $this, $ig, &$html ) );
                wfProfileOut( __METHOD__ );
                return $html;
        }