aboutsummaryrefslogtreecommitdiff
path: root/start.php
diff options
context:
space:
mode:
authorCash Costello <cash.costello@gmail.com>2010-05-23 19:37:12 -0400
committerCash Costello <cash.costello@gmail.com>2010-05-23 19:37:12 -0400
commit6d496263bbcc662282a059aee76d74784ac44479 (patch)
tree8a1a2e751912c6f3cd46409d872dd13d1d7186df /start.php
downloadelgg-6d496263bbcc662282a059aee76d74784ac44479.tar.gz
elgg-6d496263bbcc662282a059aee76d74784ac44479.tar.bz2
First version of an OpenSearch endpoint for Elgg
Diffstat (limited to 'start.php')
-rw-r--r--start.php47
1 files changed, 47 insertions, 0 deletions
diff --git a/start.php b/start.php
new file mode 100644
index 000000000..015fd3b1e
--- /dev/null
+++ b/start.php
@@ -0,0 +1,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;
+ }
+
+}