2 /////////////////////////////////////////////////
3 // PukiWiki - Yet another WikiWikiWeb clone.
5 // $Id: lookup.inc.php,v 1.13 2004/12/02 11:34:25 henoheno Exp $
9 define('PLUGIN_LOOKUP_USAGE', '#lookup(interwikiname[,button_name[,default]])');
10 function plugin_lookup_convert()
12 global $script, $vars;
14 $num = func_num_args();
15 if ($num == 0 || $num > 3) return PLUGIN_LOOKUP_USAGE;
17 $args = func_get_args();
18 $interwiki = htmlspecialchars(trim($args[0]));
19 $button = trim($args[1]);
20 $button = ($button != '') ? htmlspecialchars($button) : 'lookup';
21 $default = ($num > 2) ? htmlspecialchars(trim($args[2])) : '';
22 $s_page = htmlspecialchars($vars['page']);
25 <form action="$script" method="post">
27 <input type="hidden" name="plugin" value="lookup" />
28 <input type="hidden" name="refer" value="$s_page" />
29 <input type="hidden" name="inter" value="$interwiki" />
31 <input type="text" name="page" size="30" value="$default" />
32 <input type="submit" value="$button" />
39 function plugin_lookup_action()
41 global $post; // Deny GET method to avlid GET loop
43 $page = isset($post['page']) ? $post['page'] : '';
44 $inter = isset($post['inter']) ? $post['inter'] : '';
45 if ($page == '') return FALSE; // Do nothing
46 if ($inter == '') return array(msg=>'Invalid access', body=>'');
48 $url = get_interwiki_url($inter, $page);
50 $msg = sprintf('InterWikiName "%s" not found', $inter);
51 $msg = htmlspecialchars($msg);
52 return array(msg=>'Not found', body=>$msg);
56 header('Location: ' . $url); // Publish as GET method