source: t29-www/lib/search.php @ 292

Last change on this file since 292 was 290, checked in by sven, 12 years ago
  • Falsche Übersetzungen in englische Navi gefixt
  • Kleine Korrektur des Opensearchdesc-Formulars (Bilingualität eingeführt)
  • CC-Icon verbessert
File size: 1.7 KB
Line 
1<?php
2
3class 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&amp;q={searchTerms}&amp;format=json" />
36                        <Url type="application/x-suggestions+xml" method="get" template="http://www.technikum29.de/<?=$path[$lang]; ?>?get=suggestions&amp;q={searchTerms}&amp;format=xml" />
37                        <moz:SearchForm>http://www.technikum29.de/<?=$path[$lang]; ?></moz:SearchForm>
38                </OpenSearchDescription>
39                <?php
40                exit;
41        }
42}
Note: See TracBrowser for help on using the repository browser.
© 2008 - 2013 technikum29 • Sven Köppel • Some rights reserved
Powered by Trac
Expect where otherwise noted, content on this site is licensed under a Creative Commons 3.0 License