diff --git a/ecrire/inc_presentation.php3 b/ecrire/inc_presentation.php3 index aecee545ad296a5a997e34a2c421b6ae158b834d..ad1b03c92dd263e38a58f6ece3798be50115aef2 100644 --- a/ecrire/inc_presentation.php3 +++ b/ecrire/inc_presentation.php3 @@ -1425,32 +1425,7 @@ function debut_html($titre = "", $rubrique="", $onLoad="") { ?> <script type="text/javascript" src="../mathmlinHTML.js"></script> - -<script type='text/javascript'><!-- -// Boolean variable to keep track of user's SVG support -var hasSVGSupport = false; - -// Boolean to determine if we need to use VB Script method or not to find SVG support -var useVBMethod = false; - -/* Internet Explorer returns 0 as the number of MIME types, - so this code will not be executed by it. This is our indication - to use VBScript to detect SVG support. */ -if (navigator.mimeTypes != null && navigator.mimeTypes.length > 0) { - if (navigator.mimeTypes["image/svg-xml"] != null) - hasSVGSupport = true; -}else{ - useVBMethod = true; -} ---></script> - -<script language="VBScript"><!-- -On Error Resume Next -If useVBMethod = true Then - hasSVGSupport = IsObject(CreateObject("Adobe.SVGCtl")) -End If ---></script> - +<script type="text/javascript" src="js_detectplugins.js"></script> <script type='text/javascript'><!-- var init_gauche = true; @@ -1653,12 +1628,13 @@ End If function verifForm() { - <?php - if (!$_COOKIE["spip_svg_support"]) { ?> - document.cookie = "spip_svg_support="+hasSVGSupport; - <?php } ?> + if (pluginlist.indexOf("SVG")!=-1) + document.cookie = "spip_svg_plugin=oui"; + else + document.cookie = "spip_svg_plugin=non"; + - convert2math(); + convert2math(); <?php // Hack pour forcer largeur des formo/forml sous Mozilla >= 1.7 // meme principe que le behavior win_width.htc pour MSIE diff --git a/ecrire/js_detectplugins.js b/ecrire/js_detectplugins.js new file mode 100644 index 0000000000000000000000000000000000000000..0b148208a09bf2e3d0b71b947c3c41fece0572ff --- /dev/null +++ b/ecrire/js_detectplugins.js @@ -0,0 +1,55 @@ +var agt=navigator.userAgent.toLowerCase(); +var ie = (agt.indexOf("msie") != -1); +var ns = (navigator.appName.indexOf("Netscape") != -1); +var win = ((agt.indexOf("win")!=-1) || (agt.indexOf("32bit")!=-1)); +var mac = (agt.indexOf("mac")!=-1); + +function detectIE(ClassID,name) { + result = false; + document.write('<SCRIPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject(CreateObject("' + ClassID + '"))</SCRIPT>\n'); + if (result) return name+','; + else return ''; +} + +function detectNS(ClassID,name) { + n = ""; + if (nse.indexOf(ClassID) != -1) + if (navigator.mimeTypes[ClassID].enabledPlugin != null) + n = name+","; + return n; +} + +if (ie && win) { + pluginlist = detectIE("Adobe.SVGCtl","SVG Viewer") + + detectIE("SWCtl.SWCtl.1","Shockwave Director") + + detectIE("ShockwaveFlash.ShockwaveFlash.1","Shockwave Flash") + + detectIE("rmocx.RealPlayer G2 Control.1","RealPlayer") + + detectIE("QuickTimeCheckObject.QuickTimeCheck.1","QuickTime") + + detectIE("MediaPlayer.MediaPlayer.1","Windows Media Player") + + detectIE("PDF.PdfCtrl.5","Acrobat Reader"); } + +if (ns || !win) { + nse = ""; + for (var i=0; i<navigator.mimeTypes.length; i++) + nse += navigator.mimeTypes[i].type.toLowerCase(); + + pluginlist = detectNS("image/svg-xml","SVG Viewer") + + detectNS("application/x-director","Shockwave Director") + + detectNS("application/x-shockwave-flash","Shockwave Flash") + + detectNS("audio/x-pn-realaudio-plugin","RealPlayer") + + detectNS("video/quicktime","QuickTime") + + detectNS("application/x-mplayer2","Windows Media Player") + + detectNS("application/pdf","Acrobat Reader"); + +} + + + + +pluginlist += navigator.javaEnabled() ? "Java," : ""; +if (pluginlist.length > 0) pluginlist = pluginlist.substring(0,pluginlist.length-1); + + +//SAMPLE USAGE- detect "Flash" +//if (pluginlist.indexOf("SVG")!=-1) + //alert(pluginlist) ; \ No newline at end of file diff --git a/ecrire/statistiques_visites.php3 b/ecrire/statistiques_visites.php3 index 601680f30b6c5ff16dcf410405132ee7a26508c8..afd2c6aa1da02a74f8e09ea7556d4ca504457973 100644 --- a/ecrire/statistiques_visites.php3 +++ b/ecrire/statistiques_visites.php3 @@ -304,7 +304,7 @@ if (!$origine) { if ($date_premier < $date_debut) echo "<a href='statistiques_visites.php3?aff_jours=$aff_jours_plus$pour_article'><img src='img_pack/loupe-moins.gif' border='0' valign='center'></a> "; if ( (($date_today - $date_debut) / (24*3600)) > 30) echo "<a href='statistiques_visites.php3?aff_jours=$aff_jours_moins$pour_article'><img src='img_pack/loupe-plus.gif' border='0' valign='center'></a> "; - if ($_COOKIE['spip_svg_support'] == true) { + if ($spip_svg_plugin == 'oui') { echo "<div>"; echo "<object data='statistiques_svg.php3?id_article=$id_article&aff_jours=$aff_jours' width='450' height='310' type='image/svg+xml'>"; echo "<embed src='statistiques_svg.php3?id_article=$id_article&aff_jours=$aff_jours' width='450' height='310' type='image/svg+xml' />";