My GeoGebra extension helps to embed a GeoGebra Java applet into a MediaWiki page and to display a GeoGebra file. (GeoGebra is a dynamic geometry invironment.) In my extension I use $file->getURL() to retrieve the URL of a GeoGebra file (*.ggb) previously uploaded to the MediaWiki file repository.
My extension works fine at four sites (three of them for testing only): http://wiki.zum.de/Hilfe:GeoGebra http://www.fuemo.de/wiki/index.php?title=Benutzer:Rudolf.Grossmann/GeoGebra-... http://wiki.formelapplet.de/index.php5?title=GeoGebra-Demo Local installation of MediaWiki, using Apache, MySQL, PHP.
My extension fails at: http://robertfant.com/wiki/index.php?title=Extension:GeoGebra http://robertfant.com/ProjectWiki/index.php?title=User:Rudolf.Grossmann/Test...
Here is a PHP code snippet: ************* // retrieve URL of *.ggb file $ggbBinary = htmlspecialchars(strip_tags($args['filename'])); $ggbFile = Image::newFromName($ggbBinary); if (!($ggbFile->exists())) { $error_message = "File " . $ggbBinary . " not found."; } else { $ggbURL = $ggbFile->getURL(); // if URL doesn't start with slash, add starting slash. if (substr($ggbURL, 0, 1) != '/'){ $ggbURL = '/' . $ggbURL; } $ggbURL = $wgServer . $ggbURL; } // Add URL of *.ggb file to tag $output = $output . '<param name="filename" value="' . $ggbURL . '">' . $CRLF; **********************
Searching for the file Winkelhalbierende.ggb using Special:ListFiles leads to the page http://robertfant.com/ProjectWiki/index.php?title=File:Winkelhalbierende.ggb and there is a link to http://robertfant.com/ProjectWiki/images/c/cc/Winkelhalbierende.ggb
But my extension produces this output: <param name="filename" value="http://robertfant.com/images/c/cc/Winkelhalbierende.ggb"> This means, $ggbFile->getURL() results in a string where the leading "/ProjectWiki" is missing.
Why does the extension work at 4 sites, but not at 2 other? Is there a better (more reliable) function to retrieve the URL of a file stored in a MediaWiki repository, given the filename?
Thanks for help in advance, Rudi ******************************* GeoGebra: http://www.geogebra.org/cms/index.php?lang=en GeoGebra extension: http://www.mediawiki.org/wiki/Extension:GeoGebra
El 4/29/09 3:10 PM, Rudolf Großmann escribió:
Searching for the file Winkelhalbierende.ggb using Special:ListFiles leads to the page http://robertfant.com/ProjectWiki/index.php?title=File:Winkelhalbierende.ggb and there is a link to http://robertfant.com/ProjectWiki/images/c/cc/Winkelhalbierende.ggb
But my extension produces this output:
<param name="filename" value="http://robertfant.com/images/c/cc/Winkelhalbierende.ggb"> This means, $ggbFile->getURL() results in a string where the leading "/ProjectWiki" is missing.
$wgUploadUrl is set incorrectly on this site to "images" instead of "/ProjectWiki/images".
This relative URL is resolved by the browser from /ProjectWiki/index.php ok, but not by anything else -- your code snippet simply adds a "/" on the front, making it "/images". (Note this will also fail if $wgUploadUrl is a fully-qualified URL, such as on sites which serve their images from a separate domain.)
-- brion
wikitech-l@lists.wikimedia.org