blob: 015fd3b1ec34232960161d8e0c1b76cd3e246267 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
<?php
/**
* OpenSearch plugin
*
* http://www.opensearch.org/Home
*
* @author Cash Costello
* @license http://opensource.org/licenses/gpl-2.0.php GPL 2
*/
register_elgg_event_handler('init', 'system', 'opensearch_init');
function opensearch_init() {
global $CONFIG;
register_page_handler('opensearch', 'opensearch_handler');
elgg_extend_view('metatags', 'opensearch/includes');
}
/**
* Handles OpenSearch requests
*
* @param array $page An array of URL elements
* @return boolean
*/
function opensearch_handler($page) {
global $CONFIG;
// file path to the page scripts
$base_path = $CONFIG->pluginspath . 'opensearch';
if (!isset($page[0])) {
require "$base_path/search.php";
return TRUE;
}
// select page based on first URL element after /pg/hello/
switch ($page[0]) {
case 'osd.xml':
elgg_set_viewtype('xml');
page_draw('', elgg_view('opensearch/description'));
return TRUE;
break;
}
}
|