New hook, AfterParserFetchFileAndTitle

It is needed for PageImages to collect information about galleries, improving results
for Commons mainspace.

Bug: 66510
Change-Id: I3136d648ef2c1841767db0ab33855cd168e3de3e
This commit is contained in:
Max Semenik 2014-06-13 16:08:52 -07:00 committed by kaldari
parent 460213619e
commit 467f4affd1
3 changed files with 16 additions and 0 deletions

View 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; ).

View 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

View 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;
}