User:TeamChaos~metawiki/HtmlMaps

From Meta, a Wikimedia project coordination wiki
Jump to navigation Jump to search
Blue Glass Arrow.svg MediaWiki logo.png
This page should be moved to MediaWiki.org.
Please do not move the page by hand. It will be imported by a MediaWiki.org administrator with the full edit history. In the meantime, you may continue to edit the page as normal.

Introduction[edit]

This extension includes well known HTML Image-Maps to MediaWiki. Please note that i am a php beginner. Bugs might appear. I tested it with my Wiki, it works fine. But that doesn't mean it does for yours. Please report any bugs below. It should work with Version 1.4 and higher. Thanks.

Syntax[edit]

<htmlmap>[source|mapname|width|height]{shape|coords|url|alt}</htmlmap>
<htmlmap>[source|mapname|width|height]{shape|coords|url|alt}{shape|coords|url|alt}</htmlmap>
<htmlmap>[source|mapname|width|height]{shape|coords|url|alt}{shape|coords|url|alt}{shape|coords|url|alt}{shape|coords|url|alt}...</htmlmap>

  • [] - concerning the visible image, once
* source - where the image is located
* mapname - random name
* width - width of image
* height - of image
  • {}- concerning clickable points in image, unlimited (as much clickable points you want)
* shape - can be "rect", "circle" or "polygon"
* coords - "x,x,x,x" for rect; "x,x,x" for circle; "x,x,x,..." for polygon
* url - url where to link
* alt - alternative text

Maybe very confusing at the first time of use. Just look at any HTML Guide to ImageMaps for more Information. This extension just kind of translates the code, so u can use it in MediaWiki Software.

Example[edit]

<htmlmap>[http://petition.panzertierzone.de/images/petition.png|Petition|468|60]{rect|10,10,50,50|http://petition.panzertierzone.de|Petition}</htmlmap>

Result / further Information[edit]

Can not be shown here.

Source[edit]

<?php
 # HTMLMap by Steven Rose (webmaster@terrapedia.de)
 # 
 # visit www.terrapedia.de
 # 
 # special thanks to anea of #php.de @irc.quakenet.de
 # Note: htmlmap includes imagemaps to mediawiki software
 #       usage is shown here: www.terrapedia.de/ImageMaps
 # 
 # Have fun
 $wgExtensionFunctions[] = "wfHtmlMap";
 function wfHtmlMap() {
  global $wgParser;
  $wgParser->setHook( "htmlmap", "renderHtmlMap" );
 }
 function renderHtmlMap( $input ) {
  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]."\" coords=\"".$v[1]."\" href=\"".$v[2]."\" alt=\"".$v[3]."\">";
    }
  }
  $output = "<div><div><map name=\"".$var[0][1]."\">".$a."</map></div><p><img src=\"".$var[0][0]."\" width=\"".$var[0][2]."\" height=\"".$var[0][3]."\" alt=\"".$var[0][1]."\" usemap=\"#".$var[0][1]."\"></p></div>";
  return $output;
 }
?>

Bugs[edit]

It would be very nice if u would report any bugs here. Thanks.

  • (reported by Benutzer:TeamChaos) = I'm sorry i fogot ONE (1) little point in the code. By effect just one Link was created. I fixed this. Source above corrected.

Feedback[edit]

It would be nice too if u could post any feedback, where ur using my extension etc, in this discussions-page. Thanks.

Author[edit]

Steven Rose