# HG changeset patch # User Dan # Date 1243341438 14400 # Node ID e7eb457efdff02d03a59bccafad11d557b71afd9 # Parent d2584c5a075c71aedbd9a3b6468c66fd6b579c1f Changed hook to render_wikiformat_posttemplates to allow templating galleries diff -r d2584c5a075c -r e7eb457efdff LightboxGallery.php --- a/LightboxGallery.php Tue May 26 01:58:15 2009 -0400 +++ b/LightboxGallery.php Tue May 26 08:37:18 2009 -0400 @@ -11,11 +11,12 @@ **!*/ // Hook into wikitext render flow -$plugins->attachHook('render_wikiformat_pre', 'lbgallery_process_tags($text);'); +$plugins->attachHook('render_wikiformat_posttemplates', 'lbgallery_process_tags($text);'); $plugins->attachHook('html_attribute_whitelist', '$whitelist["lightboxgallery"] = array("maxwidth"); $whitelist["trigger"] = array(); $whitelist["randomimage"] = array("/");'); function lbgallery_process_tags(&$text) { + // if there are no galleries in this blob, just get out here. also pulls all the matches we need. if ( !preg_match_all('#(.+?)#s', $text, $matches) ) return true; @@ -23,6 +24,7 @@ foreach ( $matches[0] as $i => $match ) { + // actual parser loop is pretty simple. $gallery = lbgallery_build_gallery($matches[2][$i], $matches[1][$i]); $text = str_replace($match, $gallery, $text); } @@ -59,6 +61,8 @@ '); } +// The actual function to build the HTML behind a gallery. + function lbgallery_build_gallery($gallerytag, $width) { // parse out any text sections