4 A publically EditableInterMap implementation. Entries therein cannot
5 override the default entries of the bultin intermap array (or the one
6 from the list extension plugin).
7 All entries must be provided in the definition list form:
8 :WikiMoniker:httpz://www.example.net/cgi-bin/wiki.cgi/...
10 Set the _APPENDONLY page flag to restrict editing.
14 #-- load data from intermap page
15 $ewiki_plugins["init"][] = "ewiki_load_editable_intermap";
18 function ewiki_load_editable_intermap($uu=0, $uu=0, $uu=0) {
20 global $ewiki_plugins, $ewiki_config;
21 $inter = &$ewiki_config["interwiki"];
24 $id = "EditableInterMap";
25 if ($data = ewiki_db::GET($id)) {
28 if (preg_match_all('/^:(\w+):([^\s]+)/m', $data["content"], $uu)) {
29 foreach ($uu[1] as $i=>$moni) {
30 if (!isset($inter[$moni])) {
31 $inter[$moni] .= $uu[2][$i];
36 $refs = explode("\n", trim($data["refs"]));
37 for ($n=1; $n<count($refs); $n++) {
38 if (strpos($refs[$n], "://")) {
40 if (!isset($inter[$moni])) {
41 $inter[$moni] .= $refs[$n];
47 #-- enable _APPENDONLY part
48 if ($data["flags"] & EWIKI_DB_F_APPENDONLY) {
49 $ewiki_plugins["page"]["EditableInterMap"] = "ewiki_editable_intermap";
55 #-- provides an append-form to prevent total-editing (which
56 # otherwise allowed random removal of existing entries)
57 function ewiki_editable_intermap($id, $data, $action) {
63 if (($url = $_REQUEST["add_url"]) && ($moni = $_REQUEST["add_moniker"])) {
64 if (!preg_match('#^http[sz]?://(\w{2,}\.)+\w{2,}(:\d+)?[^\[\]\"\s]+$#', $url) || strpos($url, "example")) {
65 $o .= "URL was rejected.";
67 elseif (!preg_match('#^(['.EWIKI_CHARS_U.']+['.EWIKI_CHARS_L.']+){2,}['.EWIKI_CHARS.']+$#', $moni) || ($moni == "WikiName")) {
68 $o .= "Choosen InterWiki moniker not acceptable.";
71 if ($ewiki_config["interwiki"][$moni]) {
72 $o .= "(Note: eventually overriding earlier entry.)<br />";
76 trim($data["content"]) .
80 ewiki_data_update($data);
82 if (ewiki_db::WRITE($data)) {
83 $o .= "Map was updated.";
85 $o .= "Error occoured when saving your changes.";
91 $o .= ewiki_make_title($id, $id, 2);
92 $o .= ewiki_page_view($id, $data, $action, 0);
95 <form class="intermap-append" action="$_SERVER[REQUEST_URI]" method="POST" enctype="multipart/form-data">
97 <input type="hidden" name="id" value="$id">
98 :<input name="add_moniker" value="WikiName" size="16">:<input name="add_url" value="http://www.example.com/..." size="42">
100 <input type="submit" value="_{add}">