Changed hook to render_wikiformat_posttemplates to allow templating galleries
authorDan
Tue, 26 May 2009 08:37:18 -0400
changeset 2 e7eb457efdff
parent 1 d2584c5a075c
child 3 b52509cf73af
Changed hook to render_wikiformat_posttemplates to allow templating galleries
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('#<lightboxgallery(?: maxwidth="?([0-9]+)"?)>(.+?)</lightboxgallery>#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 @@
     </script>');
 }
 
+// The actual function to build the HTML behind a gallery.
+
 function lbgallery_build_gallery($gallerytag, $width)
 {
   // parse out any text sections