SkipperGuide:Interne Dokumentation/ImageMaps
Zur Navigation springen
Zur Suche springen
HTMLMap.php
<?php # HTMLMap by Steven Rose (webmaster@terrapedia.de) # Extentions made by Peter Schrey (pschrey (at) googlemail.com) # # visit http://www.skipperguide.de # # CUSTOM Settings $articlePath="/wiki/"; $imagePath="/mediawiki/images/"; # # $wgExtensionFunctions[] = "wfHtmlMap"; function wfHtmlMap() { global $wgParser; $wgParser->setHook( "htmlmap", "renderHtmlMap" ); } function renderHtmlMap( $input ) { $version = "1.2ps"; preg_match_all('/([\[\]{}])(.*?)([\[\]{}])/', $input, $matches, PREG_SET_ORDER); foreach($matches as $match) { $var[] = explode('|', $match[2]); } foreach($var as $k=>$v) { if($k>0) { $a .= "<area shape=\"".$v[0]."\" "; $a .= "coords=\"".$v[1]."\" href=\"".$v[2]."\" "; $a .= "title=\"".$v[3]."\" alt=\"".$v[3]."\" "; if ( isset($v[4]) ) { $a .= "onmouseover=\"showHighlight('".$v[4]."');\" onmouseout=\"hideHighlight();\" "; } $a .= ">"; } } $output = ""; $output .= "<script type=\"text/javascript\">"; $output .= ""; $output .= "var default_image;"; $output .= "highlightImages = new Array();"; $output .= ""; $output .= "function showHighlight(Name) {"; $output .= " window.document.images[imageName].src = highlightImages[Name].src;"; $output .= "}"; $output .= ""; $output .= "function hideHighlight() {"; $output .= " window.document.images[imageName].src = default_image.src;"; $output .= "}"; $output .= ""; $output .= "function initImage(Name) {"; $output .= " highlightImages[Name] = new Image();"; $output .= " highlightImages[Name].src = Name;"; $output .= "}"; $output .= "</script>"; $output = $output . "<script type=\"text/javascript\">"; ## DOM-Name of the Image of the ImageMap $output = $output . "var imageName = \"".$var[0][0]."\"; "; ## Init default Image $output = $output . "initImage(\"".$var[0][0]."\"); "; $output = $output . "default_image = highlightImages[\"".$var[0][0]."\"]; "; ## Init highlightImages foreach($var as $k=>$v) { if($k>0) { $output .= "initImage(\"".$v[4]."\"); "; } } $output = $output . "</script>";
$output = $output . "
<map name=\"".$var[0][1]."\">".$a."</map>
<img name=\"".$var[0][0]."\" src=\"".$var[0][0]."\" width=\"".$var[0][2]."\" height=\"".$var[0][3]."\" alt=\"".$var[0][1]."\" usemap=\"#".$var[0][1]."\">
";
return $output; } ?>
Ergänzung in LocalSettings.php
include("extensions/HTMLMap.php");