equal
deleted
inserted
replaced
10 } |
10 } |
11 **!*/ |
11 **!*/ |
12 |
12 |
13 // Hook into wikitext render flow |
13 // Hook into wikitext render flow |
14 $plugins->attachHook('render_wikiformat_pre', 'lbgallery_process_tags($text);'); |
14 $plugins->attachHook('render_wikiformat_pre', 'lbgallery_process_tags($text);'); |
15 $plugins->attachHook('html_attribute_whitelist', '$whitelist["lightboxgallery"] = array("maxwidth"); $whitelist["trigger"] = array();'); |
15 $plugins->attachHook('html_attribute_whitelist', '$whitelist["lightboxgallery"] = array("maxwidth"); $whitelist["trigger"] = array(); $whitelist["randomimage"] = array("/");'); |
16 |
16 |
17 function lbgallery_process_tags(&$text) |
17 function lbgallery_process_tags(&$text) |
18 { |
18 { |
19 if ( !preg_match_all('#<lightboxgallery(?: maxwidth="?([0-9]+)"?)>(.+?)</lightboxgallery>#s', $text, $matches) ) |
19 if ( !preg_match_all('#<lightboxgallery(?: maxwidth="?([0-9]+)"?)>(.+?)</lightboxgallery>#s', $text, $matches) ) |
20 return true; |
20 return true; |
110 } |
110 } |
111 } |
111 } |
112 |
112 |
113 if ( $text ) |
113 if ( $text ) |
114 { |
114 { |
115 $trigger = str_replace('<a>', $firstimagetag, trim($text)); |
115 $trigger = trim($text); |
116 } |
116 } |
117 else |
117 else |
118 { |
118 { |
119 list($image, $alt) = $imagelist[ array_rand($imagelist) ]; |
119 $trigger = '<a><randomimage /></a>'; |
120 $trigger = $firstimagetag . '<img alt="' . htmlspecialchars($alt) . '" src="' . makeUrlNS('Special', "DownloadFile/$image", "preview", true) . '" />' . '</a>'; |
|
121 } |
120 } |
|
121 |
|
122 $trigger = str_replace('<a>', $firstimagetag, $trigger); |
|
123 |
|
124 list($image, $alt) = $imagelist[ array_rand($imagelist) ]; |
|
125 $randomimage = '<img alt="' . htmlspecialchars($alt) . '" src="' . makeUrlNS('Special', "DownloadFile/$image", "preview", true) . '" />'; |
|
126 $trigger = str_replace(array('<randomimage>', '<randomimage/>', '<randomimage />'), $randomimage, $trigger); |
122 |
127 |
123 return "$trigger<nowiki> |
128 return "$trigger<nowiki> |
124 <div style=\"display: none;\">$inner</div> |
129 <div style=\"display: none;\">$inner</div> |
125 <script type=\"text/javascript\"> |
130 <script type=\"text/javascript\"> |
126 addOnloadHook(function() |
131 addOnloadHook(function() |