From 6d496263bbcc662282a059aee76d74784ac44479 Mon Sep 17 00:00:00 2001 From: Cash Costello Date: Sun, 23 May 2010 19:37:12 -0400 Subject: First version of an OpenSearch endpoint for Elgg --- config.ini.sample | 45 ++++++++++++++++++++++ manifest.xml | 10 +++++ start.php | 47 +++++++++++++++++++++++ views/default/opensearch/includes.php | 7 ++++ views/opensearch_rss/page_shells/default.php | 42 ++++++++++++++++++++ views/opensearch_rss/search/layout.php | 2 + views/opensearch_rss/search/listing.php | 25 ++++++++++++ views/xml/opensearch/description.php | 57 ++++++++++++++++++++++++++++ 8 files changed, 235 insertions(+) create mode 100644 config.ini.sample create mode 100644 manifest.xml create mode 100644 start.php create mode 100644 views/default/opensearch/includes.php create mode 100644 views/opensearch_rss/page_shells/default.php create mode 100644 views/opensearch_rss/search/layout.php create mode 100644 views/opensearch_rss/search/listing.php create mode 100644 views/xml/opensearch/description.php diff --git a/config.ini.sample b/config.ini.sample new file mode 100644 index 000000000..770023186 --- /dev/null +++ b/config.ini.sample @@ -0,0 +1,45 @@ +; OpenSearch configuration + +; ShortName +; Contains a brief human-readable title that identifies this search engine. +; 16 characters or less of plain text. +; Required +shortname = "Elgg" + +; Description +; Contains a human-readable text description of the search engine. +; 1024 characters or less of plain text. +; Required +description = "Elgg search engine" + +; LongName +; Contains an extended human-readable title that identifies this search engine. +; 48 characters or less of plain text. +;longname = "" + +; Image +; Contains a URL that identifies the location of an image that can be used +; in association with this search content. Can be either a 16x16 ico or +; 64x64 png or both. Clients will choose the image that best fits the +; display area. The value should be relative to your Elgg root. +ico = "_graphics/favicon.ico" +;png = "" + +; Tags +; Contains a set of words that are used as keywords to identify and categorize +; this search content. Tags must be a single word and are delimited by the +; space character (' '). +; 256 characters or less, space delimited tags +;tags = "test search elgg" + +; Language +; Contains a string that indicates that the search engine supports search +; results in the specified language. +; * or codes according to XML 1.0 Language Identification +lang[] = "en-us" + +; Query +; Test query available to clients. +; Clients can submit this as a test query to ensure that the OpenSearch +; interface works. +;query = "test" diff --git a/manifest.xml b/manifest.xml new file mode 100644 index 000000000..0038dc168 --- /dev/null +++ b/manifest.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/start.php b/start.php new file mode 100644 index 000000000..015fd3b1e --- /dev/null +++ b/start.php @@ -0,0 +1,47 @@ +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; + } + +} diff --git a/views/default/opensearch/includes.php b/views/default/opensearch/includes.php new file mode 100644 index 000000000..57e56723f --- /dev/null +++ b/views/default/opensearch/includes.php @@ -0,0 +1,7 @@ +sitename; +?> + + diff --git a/views/opensearch_rss/page_shells/default.php b/views/opensearch_rss/page_shells/default.php new file mode 100644 index 000000000..52aa8854c --- /dev/null +++ b/views/opensearch_rss/page_shells/default.php @@ -0,0 +1,42 @@ +\n"; + +// Set title +$search_terms = get_input('q'); +$title = $vars['config']->sitename; +$title .= " Search: $search_terms"; + +$description = "Search results for \"$search_terms\""; + +// Remove viewtype from URL +$search_url = str_replace('&view=opensearch_rss','', full_url()); + +$os_url = "{$vars['url']}pg/opensearch/osd.xml"; + + +?> + + + <?php echo $title; ?> + + + + 1 + 10 + + diff --git a/views/opensearch_rss/search/layout.php b/views/opensearch_rss/search/layout.php new file mode 100644 index 000000000..4cd2ff050 --- /dev/null +++ b/views/opensearch_rss/search/layout.php @@ -0,0 +1,2 @@ + $entity, + 'params' => $vars['params'], + 'results' => $vars['results'] + )); + } +} +elgg_set_viewtype('opensearch_rss'); + +echo $body; \ No newline at end of file diff --git a/views/xml/opensearch/description.php b/views/xml/opensearch/description.php new file mode 100644 index 000000000..f8eb0b040 --- /dev/null +++ b/views/xml/opensearch/description.php @@ -0,0 +1,57 @@ +site_guid); +$email = $site->email; + +$rss_url = "{$vars['url']}pg/opensearch/?q={searchTerms}&pw={startPage?}&format=rss"; +$html_url = "{$vars['url']}pg/search/?q={searchTerms}"; + +?> + + + + + + + email; ?> + + + + + + + + + + + + + + + + + + open + false + UTF-8 + UTF-8 + -- cgit v1.2.3