Table of Contents
Routeplaner Plugin
Compatible with DokuWiki
No compatibility info given!
This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.
Description
You ever felt like offering an individual description of the journey to your habitat for your visitors - e.g. a company for customers. Some websites like Lycos.de offer this service even for private homepages.
The plugin uses this service.
- Documentation (in German)
Syntax / Usage
You have to fill in the destination address, where your visitor should go to. The address where the visitor starts from is filled into a form on the page itself.
{{routeplaner> Tim Taylor, Dreamlane 5, 123456, Hometown, Deutschland}}
Options:
- all information has to be preserved; the name (here: “Tim Taylor”) is actually not needed for calculating the journey.
- each single information is separated by a “,”
- countries: actually every country seen in the drop down menu should be supported. Lycos.de is just supporting the German country names.
Installation
Create two files: (charset: utf8)
- syntax.php
- style.css
And copy the shown source code into it.
This files should be copied to “/plugins/routeplaner/“.
DONE!
syntax.php
- syntax.php
<?php if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); require_once(DOKU_PLUGIN.'syntax.php'); /** * All DokuWiki plugins to extend the parser/rendering mechanism * need to inherit from this class */ class syntax_plugin_routeplaner extends DokuWiki_Syntax_Plugin { /** * return some info */ function getInfo(){ return array( 'author' => 'routeplaner', 'email' => 'deshi@web.de', 'date' => '16/01/2006', 'name' => 'Routeplaner Plugin', 'desc' => 'plan your route using lycos', 'url' => 'http://www.dokuwiki.org/plugin:routeplaner', ); } /** * Syntax-Beispiel: {{routeplaner> Hubert Meier, Mustergasse 3, 80756, München, Deutschland}} */ /** * Plugin Type */ function getType(){ return 'substition'; } function getSort(){ return 314; } function connectTo($mode) { $this->Lexer->addSpecialPattern("\{\{routeplaner>.*?\}\}",$mode,'plugin_routeplaner'); } /** * Handle the match */ function handle($match, $state, $pos, &$handler){ // strip markup $match = substr($match,14,-2); // split into pieces list($company,$street,$zip, $town, $country) = explode(',',$match,5); // beautify strings if (trim($company, " \t\n") != '') { $company = trim($company, " \t\n"); } else { $company = 'Ziel'; } if (trim($street, " \t\n") != '') { $street = trim($street, " \t\n"); } else { $street = 'missing street'; } if (trim($zip, " \t\n") != '') { $zip = trim($zip, " \t\n"); } else { $zip = 'missing zip'; } if (trim($town, " \t\n") != '') { $town = trim($town, " \t\n"); } else { $town = 'missing town'; } if (trim($country, " \t\n") != '') { $country = trim($country, " \t\n"); } else { $country = 'missing country'; } return array($company,$street,$zip,$town,$country); } /** * Create output */ function render($mode, &$renderer, $data) { if($mode == 'xhtml'){ $renderer->doc .= $this->_contact($data); return true; } return false; } /** * Does the contact form xhtml creation. Adds some javascript to validate the form * and creates the input form. */ /** * Does the contact form xhtml creation. Adds some javascript to validate the form * and creates the input form. */ function _contact($data){ global $lang; global $conf; global $ID; $ret = ''; $ret .= "<script type=\"text/javascript\"></script>"; $ret .= "<div class=\"columns1\">"; $ret .= "<form name=\"routenplaner2\" method=\"get\" target=\"_blank\" action=\"http://www.lycos.de/routenplaner/index.html\">"; $ret .= "<input type=\"hidden\" name=\"tocountry\" value=\"DEU\" />";//crv:20081026 Not nice to fix it with 'DEU', this is a greater fix, see http://jaloma.ac.googlepages.com/plugin%3Aroutenplaner for an idea $ret .= "<input type=\"hidden\" name=\"tostreet\" value=\"".$data[1]."\" />"; $ret .= "<input type=\"hidden\" name=\"toplz\" value=\"".$data[2]."\" />"; $ret .= "<input type=\"hidden\" name=\"tocity\" value=\"".$data[3]."\" />"; $ret .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"background-image:url(http://www.lycos.de/i/c/reise/routenplaner/box_partner.gif);background-repeat:no-repeat;width:379px;height:176px;\"><tr><td><br>"; $ret .= "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style='margin-left:15px;padding: 0px 0px 0px 0px;font: 12px \"Trebuchet MS\", Tahoma, Geneva, Arial, Helvetica, sans-serif;color: #000;'>"; $ret .= "<tr>"; $ret .= "<td width=\"47%\"> </td>"; $ret .= "<td width=\"6%\"> </td>"; $ret .= "<td width=\"47%\"><strong>Ziel:</strong></td>"; $ret .= "</tr>"; $ret .= "<tr>"; $ret .= "<td width=\"47%\"><strong>Start:</strong></td>"; $ret .= "<td width=\"6%\"> </td>"; $ret .= "<td width=\"47%\"><input type=\"text\" name=\"toname_\" value=\"".$data[0]."\" disabled=\"disabled\" style=\"width:155px;\" /></td>"; $ret .= "</tr>"; $ret .= "<tr>"; $ret .= "<td><input type=\"TEXT\" name=\"fromstreet\" value=\"Straße\" size=\"12\" style=\"width: 155px;\" tabindex=\"1\" onfocus=\"javascript:if (document.routenplaner.fromstreet.value == 'Straße') document.routenplaner.fromstreet.value = '';\"></td>"; $ret .= "<td> </td>"; $ret .= "<td><input type=\"TEXT\" name=\"tostreet_\" value=\"".$data[1]."\" size=\"12\" style=\"width: 155px;\" tabindex=\"5\" disabled=\"disabled\" /></td>"; $ret .= "</tr>"; $ret .= "<tr>"; $ret .= "<td><input type=\"TEXT\" name=\"fromplz\" value=\"PLZ\" size=\"5\" style=\"width: 45px;\" maxlength=\"10\" tabindex=\"2\" onfocus=\"javascript:if (document.routenplaner.fromplz.value == 'PLZ') document.routenplaner.fromplz.value = '';\"> "; $ret .= "<input type=\"TEXT\" name=\"fromcity\" value=\"Ort\" size=\"8\" style=\"width: 101px;\" tabindex=\"3\" onfocus=\"javascript:if (document.routenplaner.fromcity.value == 'Ort') document.routenplaner.fromcity.value = '';\"></td>"; $ret .= "<td></td>"; $ret .= "<td><input type=\"TEXT\" name=\"toplz_\" value=\"".$data[2]."\" tabindex=\"6\" size=\"5\" style=\"width: 45px;\" maxlength=\"10\" disabled=\"disabled\" /> "; $ret .= "<input type=\"TEXT\" name=\"tocity_\" value=\"".$data[3]."\" tabindex=\"7\" size=\"8\" style=\"width: 101px;\" disabled=\"disabled\" /></td>"; $ret .= "</tr>"; $ret .= "<tr>"; $ret .= "<td><select name=\"fromcountry\" tabindex=\"4\" style=\"width:155px;\">"; $ret .= " <option value=\"---\">Bitte wählen...</option>"; $ret .= " <option value=\"BEL\">Belgien</option>"; $ret .= " <option value=\"DNK\">Dänemark</option>"; $ret .= " <option value=\"DEU\">Deutschland</option>"; $ret .= " <option value=\"FRA\">Frankreich</option>"; $ret .= " <option value=\"GBR\">Großbritannien</option>"; $ret .= " <option value=\"ITA\">Italien</option>"; $ret .= " <option value=\"LIE\">Liechtenstein</option>"; $ret .= " <option value=\"LUX\">Luxemburg</option>"; $ret .= " <option value=\"NLD\">Niederlande</option>"; $ret .= " <option value=\"NOR\">Norwegen</option>"; $ret .= " <option value=\"AUT\">Österreich</option>"; $ret .= " <option value=\"PRT\">Portugal</option>"; $ret .= " <option value=\"SWE\">Schweden</option>"; $ret .= " <option value=\"CHE\">Schweiz</option>"; $ret .= " <option value=\"ESP\">Spanien</option>"; $ret .= "</select>"; $ret .= "</td>"; $ret .= "<td></td>"; $ret .= "<td><input type=\"text\" name=\"tocountry_\" value=\"".$data[4]."\" disabled=\"disabled\" style=\"width:155px;\" /></td>"; $ret .= "</tr>"; $ret .= "<tr>"; $ret .= " <td colspan=\"3\" align=\"right\" style=\"float:right;\"><div class=\"button\" style=\"width:110px;text-align:center;float:right;margin-top:5px;\"><div class=\"btnleft\"></div><div class=\"btncenter\" style=\"width:90px;text-align:center;\"><input type=\"Submit\" value=\"Berechnen\"></div><div class=\"btnright\"></div><div class=\"breaker\"></div></div></td>"; $ret .= "</tr>"; $ret .= "</table>"; $ret .= "</td></tr></table></form>"; $ret .= "<div class=\"breaker\"></div>"; $ret .= "</div>"; return $ret; } } //Setup VIM: ex: et ts=4 enc=utf-8 : ?>
style.css
- style.css
.breaker{overflow:hidden;height:1px;clear:both} .columns1{ text-align:left; margin:0px 9px; width:autopx; } h1{ font: bold 18px "Trebuchet MS", Tahoma, Geneva, Arial, Helvetica, sans-serif ;color: #000; height:19px; margin: 0px 0px 0px 0px; } div.button{margin:auto} div.button .btnleft, div.button .btnright{ height:20px; width:5px; background-image: url(http://static.lycos-europe.net/de/i_slim/button_left.gif); float:left; } div.button .btnright{background-image: url(http://static.lycos-europe.net/de/i_slim/button_right.gif)} div.button .btncenter{ float:left; height:20px; background-image: url(http://static.lycos-europe.net/de/i_slim/button_center.gif); overflow:hidden; } div.button .btncenter a{ text-decoration: none; line-height: 22px; padding: 0px 6px; } div.button .btncenter input{ text-decoration: none; border:0px solid #000; background: transparent; font: 12px "Trebuchet MS", Tahoma, Geneva, Arial, Helvetica, sans-serif;color: #000; cursor: pointer; margin-top:2px; height:19px; text-align:center; } .resulttable{width:100%;margin:0px 0px;} .resulttable th {font: 12px "Trebuchet MS", Tahoma, Geneva, Arial, Helvetica, sans-serif;color: #000;} .resulttable td {text-align:left;padding:3px 9px;font: 12px "Trebuchet MS", Tahoma, Geneva, Arial, Helvetica, sans-serif;color: #000;}
Compatibility with other Plugins
You can use the Plugin with other plugins. E.G. Esthers Folded-Plugin.
++++ Test | {{routeplaner> Tim Taylor, Dreamlane 5, 123456, Hometown, Deutschland}} ++++
Known Limitations
The following limitations are known:
- As I´m using lycos.de only German language names are supported - actually. But when you are forwarded to the lycospage any country different to “Deutschland” is reset to default. Maybe due to the internal code.
- lycos is using a charset different to utf8, so filled in information is displayed correct on your DokuWiki page. Coming to lycos.de “Umlaute” (like ß,ä,ö,ü) aren´t displayed correct. I tried utf8_decode()- without success.
- Firefox makes the loaded GIF disappear on mouse over.
Discussion
Feel free to modify and improve the code.
Neat idea! Can we see the plugin in action anywhere? — Christopher Smith 2006-01-17 12:26
Spelling
The plugin name is a misspelling. Unless that's intentional, it should be called “routeplanner”. — Magnus Holmgren 2008-08-12 18:22 CEST