diff options
author | Cash Costello <cash.costello@gmail.com> | 2010-05-23 19:37:12 -0400 |
---|---|---|
committer | Cash Costello <cash.costello@gmail.com> | 2010-05-23 19:37:12 -0400 |
commit | 6d496263bbcc662282a059aee76d74784ac44479 (patch) | |
tree | 8a1a2e751912c6f3cd46409d872dd13d1d7186df /views/opensearch_rss | |
download | elgg-6d496263bbcc662282a059aee76d74784ac44479.tar.gz elgg-6d496263bbcc662282a059aee76d74784ac44479.tar.bz2 |
First version of an OpenSearch endpoint for Elgg
Diffstat (limited to 'views/opensearch_rss')
-rw-r--r-- | views/opensearch_rss/page_shells/default.php | 42 | ||||
-rw-r--r-- | views/opensearch_rss/search/layout.php | 2 | ||||
-rw-r--r-- | views/opensearch_rss/search/listing.php | 25 |
3 files changed, 69 insertions, 0 deletions
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 @@ +<?php + +global $OPEN_SEARCH_COUNT; + +header("Content-Type: application/rss+xml"); + +// allow caching as required by stupid MS products for https feeds. +header('Pragma: public', TRUE); + +echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\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"; + + +?> +<rss version="2.0" xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"> +<channel> + <title><?php echo $title; ?></title> + <link><?php echo $search_url; ?></link> + <description><?php echo $description; ?></description> + <opensearch:totalResults><?php echo $OPEN_SEARCH_COUNT; ?></opensearch:totalResults> + <opensearch:startIndex>1</opensearch:startIndex> + <opensearch:itemsPerPage>10</opensearch:itemsPerPage> + <atom:link rel="search" type="application/opensearchdescription+xml" href="<?php echo $os_url; ?>"/> + <opensearch:Query role="request" searchTerms="<?php echo $search_terms; ?>" startPage="1" /> +<?php + + echo $vars['body']; + +?> +</channel> +</rss> 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 @@ +<?php +echo $vars['body'];
\ No newline at end of file diff --git a/views/opensearch_rss/search/listing.php b/views/opensearch_rss/search/listing.php new file mode 100644 index 000000000..367bf332f --- /dev/null +++ b/views/opensearch_rss/search/listing.php @@ -0,0 +1,25 @@ +<?php + +global $OPEN_SEARCH_COUNT; +if (!isset($OPEN_SEARCH_COUNT)) { + $OPEN_SEARCH_COUNT = 0; +} + +$OPEN_SEARCH_COUNT += $vars['results']['count']; + +//var_dump($vars['results']); + +elgg_set_viewtype('rss'); +$entities = $vars['results']['entities']; +foreach ($entities as $entity) { + if ($view = search_get_search_view($vars['params'], 'entity')) { + $body .= elgg_view($view, array( + 'entity' => $entity, + 'params' => $vars['params'], + 'results' => $vars['results'] + )); + } +} +elgg_set_viewtype('opensearch_rss'); + +echo $body;
\ No newline at end of file |