I'm trying to fix McNaught's <ImageMap> extension to work with MW1.9.2 and a Wiki family.
The input is a file [[Media:World-map.map]] which contains the map information in HTML format. The purpose of the code below is to read the .map file and write it to output. A snippet of the content of the map file looks like:
<map name="map"> <AREA SHAPE="POLY" COORDS = "168,117,139,125,120,108,151,104" HREF = "http://kw.org/index.php/Caribbean" TITLE="Caribbean"> </map>
The following code taken from imagemap.php is interspersed with comments that show the actual values as found from dumping the info to error.log. The **OK** means it's what I expect. The ***?????*** is what I don't understand.
$html = $localParser->parse($MapURL,$wgTitle,$parserOptions);
= <p><a href="http://pool.kw.org/images/4/47/World-map.map" class="internal" title="World-map.map">Media:World-map.map</a> </p> **OK**
$MapUrl=preg_replace('/^.*<a[\s]+href=*"(.*?)".*$/is','\1',html->mText);
= http://pool.kw.org/images/4/47/World-map.map **OK**
$mapData = file($MapUrl);
= <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> ***?????*** <html><head> <title>Menu for /images/4/47/World-map.map</title> </head><body> <h1>Menu for /images/4/47/World-map.map</h1> <hr />
<pre> <a href="http://pool.kw.org/images/4/47/name=%22map%22%3E%22%3Ename=%22map%22%3E </a></pre> <pre> <a href="http://pool.kw.org/images/4/47/SHAPE=%22POLY%22%22%3E SHAPE="POLY"</a></pre>
etc. It looks like the file has been preprocessed to generate HTML in some way. Is this normal for file()? Is there a way to tell it to just give me the content of the file?
Mike
Michael Daly wrote:
Well, part of my brain defrosted enough to figure this out:
If the thing is referenced as http, it's going to be served as http. I have the following by default in httpd.conf: AddHandler imap-file map
Is this "safe" to remove and use "text/plain map" in the mime.types file? I'm not sure what imap-file is used for. Will this force file() to read the file as text/plain?
Or should I convert the URL to local file system path? Is there a standard way of doing this? I.e. if the input is [[Media:file.ext]], how do I get the file path instead of the URL (assuming it is on the same server - as it is in my case)?
As you can probably guess, PHP is new to me.
Mike
mediawiki-l@lists.wikimedia.org