5a28705feaffd9cadaf67e02e4ea4656cf02e672
[atutor.git] / mods / wiki / plugins / filter / f_msiepng.php
1 <?php
2
3 /*
4    This plugin enables the RedirectX workaround for M$IE 5.5+ browsers, to
5    make the alpha channel of .png graphics work. You must first set the
6    name of the 1-pixel-transparent gif graphic!
7 */
8
9
10 define("FIX_MSIE_NULL_GIF", "/img/null.gif");
11
12
13 $ewiki_plugins["view_final"][] = "fix_msie_png";
14
15
16 function fix_msie_png(&$html) {
17    $ua = $_SERVER["HTTP_USER_AGENT"];
18    if (strstr($ua, "MSIE") && !strstr($ua, "Opera")
19        && (strstr($ua, "5.5") || strstr($ua, "6.0"))
20       )
21    {
22       $html = preg_replace(
23          '/(<img[^>]*?)\ssrc="([^">]+?png[^>"]*)"([^>]*?>)/i',
24          '$1 src="'.FIX_MSIE_NULL_GIF.'" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'$2\', sizingMethod=\'scale\')"$3',
25          $html
26       );
27    }
28 }
29
30
31 ?>