1 | <?php |
---|
2 | |
---|
3 | class t29Search { |
---|
4 | static $actions = array( |
---|
5 | 'opensearch-desc' => 'print_opensearch_desc', |
---|
6 | ); |
---|
7 | |
---|
8 | function page_handler() { |
---|
9 | if(!isset($_GET['action'])) |
---|
10 | return; |
---|
11 | $action = $_GET['action']; |
---|
12 | if(array_key_exists($action, self::$actions)) { |
---|
13 | $method_name = self::$actions[$action]; |
---|
14 | $this->$method_name(); |
---|
15 | } else { |
---|
16 | print "<b>Page action $action unkown!\n"; |
---|
17 | } |
---|
18 | } |
---|
19 | |
---|
20 | |
---|
21 | function print_opensearch_desc($lang=null) { |
---|
22 | $path = array('de' => '/de/suche.php', 'en' => '/en/search.php'); |
---|
23 | // assure a valid given language |
---|
24 | if(!$lang && isset($_GET['lang'])) $lang = $_GET['lang']; |
---|
25 | if(!isset($path[$lang])) $lang = 'de'; |
---|
26 | |
---|
27 | header('Content-Type: application/opensearchdescription+xml'); |
---|
28 | print '<?xml version="1.0"?>'.PHP_EOL; |
---|
29 | ?> |
---|
30 | <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/"> |
---|
31 | <ShortName>technikum29 (<?=$lang; ?>)</ShortName> |
---|
32 | <Description>technikum29 (<?=$lang; ?>)</Description> |
---|
33 | <Image height="16" width="16" type="image/x-icon">http://www.technikum29.de/favicon.ico</Image> |
---|
34 | <Url type="text/html" method="get" template="http://www.technikum29.de/<?=$path[$lang]; ?>?q={searchTerms}" /> |
---|
35 | <Url type="application/x-suggestions+json" method="get" template="http://www.technikum29.de/<?=$path[$lang]; ?>?get=suggestions&q={searchTerms}&format=json" /> |
---|
36 | <Url type="application/x-suggestions+xml" method="get" template="http://www.technikum29.de/<?=$path[$lang]; ?>?get=suggestions&q={searchTerms}&format=xml" /> |
---|
37 | <moz:SearchForm>http://www.technikum29.de/<?=$path[$lang]; ?></moz:SearchForm> |
---|
38 | </OpenSearchDescription> |
---|
39 | <?php |
---|
40 | exit; |
---|
41 | } |
---|
42 | } |
---|