aboutsummaryrefslogtreecommitdiff
path: root/mod/opensearch/views/opensearch_rss
diff options
context:
space:
mode:
authorSem <sembrestels@riseup.net>2013-11-09 16:15:20 +0100
committerSem <sembrestels@riseup.net>2013-11-09 16:15:20 +0100
commit293fe873dcbedf45571807b722ce859e00a5a3a5 (patch)
tree4ce7adf3dbeed0a4ac2fbefd55f8844f504db499 /mod/opensearch/views/opensearch_rss
parentba0d506ade08ae46ba665474a8b9c81e838f2eee (diff)
parent853cb44b625cbe0e1cae3dff197d54645a1291a1 (diff)
downloadelgg-293fe873dcbedf45571807b722ce859e00a5a3a5.tar.gz
elgg-293fe873dcbedf45571807b722ce859e00a5a3a5.tar.bz2
Add 'mod/opensearch/' from commit '853cb44b625cbe0e1cae3dff197d54645a1291a1'
git-subtree-dir: mod/opensearch git-subtree-mainline: ba0d506ade08ae46ba665474a8b9c81e838f2eee git-subtree-split: 853cb44b625cbe0e1cae3dff197d54645a1291a1
Diffstat (limited to 'mod/opensearch/views/opensearch_rss')
-rw-r--r--mod/opensearch/views/opensearch_rss/page/default.php42
-rw-r--r--mod/opensearch/views/opensearch_rss/page/layouts/default.php5
-rw-r--r--mod/opensearch/views/opensearch_rss/search/layout.php5
-rw-r--r--mod/opensearch/views/opensearch_rss/search/list.php27
4 files changed, 79 insertions, 0 deletions
diff --git a/mod/opensearch/views/opensearch_rss/page/default.php b/mod/opensearch/views/opensearch_rss/page/default.php
new file mode 100644
index 000000000..79cd544c4
--- /dev/null
+++ b/mod/opensearch/views/opensearch_rss/page/default.php
@@ -0,0 +1,42 @@
+<?php
+/**
+ * Page shell for OpenSearch RSS feed
+ */
+
+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 = elgg_get_site_entity()->name;
+$title .= ' ' . elgg_echo('opensearch:title', array($search_terms));
+
+$description = elgg_echo('opensearch:description', array($search_terms));
+
+// Remove viewtype from URL
+$search_url = str_replace('&view=opensearch_rss', '', full_url());
+
+$os_url = elgg_normalize_url('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>
+ <atom:link rel="search" type="application/opensearchdescription+xml" href="<?php echo $os_url; ?>"/>
+ <opensearch:Query role="request" searchTerms="<?php echo addslashes($search_terms); ?>" startPage="1" />
+<?php
+
+ echo $vars['body'];
+
+?>
+</channel>
+</rss>
diff --git a/mod/opensearch/views/opensearch_rss/page/layouts/default.php b/mod/opensearch/views/opensearch_rss/page/layouts/default.php
new file mode 100644
index 000000000..488734f84
--- /dev/null
+++ b/mod/opensearch/views/opensearch_rss/page/layouts/default.php
@@ -0,0 +1,5 @@
+<?php
+/**
+ * OpenSearch RSS layout shell
+ */
+echo $vars['content']; \ No newline at end of file
diff --git a/mod/opensearch/views/opensearch_rss/search/layout.php b/mod/opensearch/views/opensearch_rss/search/layout.php
new file mode 100644
index 000000000..d5bb9fe57
--- /dev/null
+++ b/mod/opensearch/views/opensearch_rss/search/layout.php
@@ -0,0 +1,5 @@
+<?php
+/**
+ * OpenSearch search layout
+ */
+echo $vars['body']; \ No newline at end of file
diff --git a/mod/opensearch/views/opensearch_rss/search/list.php b/mod/opensearch/views/opensearch_rss/search/list.php
new file mode 100644
index 000000000..bc7b5574e
--- /dev/null
+++ b/mod/opensearch/views/opensearch_rss/search/list.php
@@ -0,0 +1,27 @@
+<?php
+/**
+ * OpenSearch serach results list
+ */
+
+global $OPEN_SEARCH_COUNT;
+if (!isset($OPEN_SEARCH_COUNT)) {
+ $OPEN_SEARCH_COUNT = 0;
+}
+
+$OPEN_SEARCH_COUNT += $vars['results']['count'];
+
+
+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