aboutsummaryrefslogtreecommitdiff
path: root/mod/search/views/rss
diff options
context:
space:
mode:
Diffstat (limited to 'mod/search/views/rss')
-rw-r--r--mod/search/views/rss/search/comments/entity.php54
-rw-r--r--mod/search/views/rss/search/entity.php24
-rw-r--r--mod/search/views/rss/search/layout.php6
-rw-r--r--mod/search/views/rss/search/list.php25
4 files changed, 109 insertions, 0 deletions
diff --git a/mod/search/views/rss/search/comments/entity.php b/mod/search/views/rss/search/comments/entity.php
new file mode 100644
index 000000000..e47afec4a
--- /dev/null
+++ b/mod/search/views/rss/search/comments/entity.php
@@ -0,0 +1,54 @@
+<?php
+/**
+ * Search comment view for RSS feeds.
+ *
+ * @uses $vars['entity']
+ */
+
+$entity = $vars['entity'];
+$comments_data = $entity->getVolatileData('search_comments_data');
+$comment_data = array_shift($comments_data);
+$entity->setVolatileData('search_comments_data', $comments_data);
+
+$author_name = '';
+$comment_author_guid = $comment_data['owner_guid'];
+$author = get_user($comment_author_guid);
+if ($author) {
+ $author_name = $author->name;
+}
+
+// @todo Sometimes we find comments on entities we can't display...
+if ($entity->getVolatileData('search_unavailable_entity')) {
+ $title = elgg_echo('search:comment_on', array(elgg_echo('search:unavailable_entity')));
+} else {
+ if ($entity->getType() == 'object') {
+ $title = $entity->title;
+ } else {
+ $title = $entity->name;
+ }
+
+ if (!$title) {
+ $title = elgg_echo('item:' . $entity->getType() . ':' . $entity->getSubtype());
+ }
+
+ if (!$title) {
+ $title = elgg_echo('item:' . $entity->getType());
+ }
+
+ $title = elgg_echo('search:comment_on', array($title));
+ $title .= ' ' . elgg_echo('search:comment_by') . ' ' . $author_name;
+ $url = $entity->getURL() . '#annotation-' . $comment_data['annotation_id'];
+}
+
+$description = $comment_data['text'];
+$tc = $comment_data['time_created'];
+
+?>
+
+<item>
+ <guid isPermaLink='true'><?php echo htmlspecialchars($url); ?></guid>
+ <pubDate><?php echo date("r", $tc) ?></pubDate>
+ <link><?php echo htmlspecialchars($url); ?></link>
+ <title><![CDATA[<?php echo $title; ?>]]></title>
+ <description><![CDATA[<?php echo $description; ?>]]></description>
+</item>
diff --git a/mod/search/views/rss/search/entity.php b/mod/search/views/rss/search/entity.php
new file mode 100644
index 000000000..10d28e8e1
--- /dev/null
+++ b/mod/search/views/rss/search/entity.php
@@ -0,0 +1,24 @@
+<?php
+/**
+ * Search entity view for RSS feeds.
+ *
+ * @uses $vars['entity']
+ */
+
+if (!array_key_exists('entity', $vars) || !($vars['entity'] instanceof ElggEntity)) {
+ return FALSE;
+}
+
+// title cannot contain HTML but descriptions can.
+$title = strip_tags($vars['entity']->getVolatileData('search_matched_title'));
+$description = $vars['entity']->getVolatileData('search_matched_description');
+
+?>
+
+<item>
+ <guid isPermaLink='true'><?php echo htmlspecialchars($vars['entity']->getURL()); ?></guid>
+ <pubDate><?php echo date("r", $vars['entity']->time_created) ?></pubDate>
+ <link><?php echo htmlspecialchars($vars['entity']->getURL()); ?></link>
+ <title><![CDATA[<?php echo $title; ?>]]></title>
+ <description><![CDATA[<?php echo $description; ?>]]></description>
+</item>
diff --git a/mod/search/views/rss/search/layout.php b/mod/search/views/rss/search/layout.php
new file mode 100644
index 000000000..2c255a9cc
--- /dev/null
+++ b/mod/search/views/rss/search/layout.php
@@ -0,0 +1,6 @@
+<?php
+/**
+ * Search layout for RSS
+ */
+
+echo $vars['body'];
diff --git a/mod/search/views/rss/search/list.php b/mod/search/views/rss/search/list.php
new file mode 100644
index 000000000..32082fd31
--- /dev/null
+++ b/mod/search/views/rss/search/list.php
@@ -0,0 +1,25 @@
+<?php
+/**
+ * List a section of search results for RSS feeds.
+ *
+ * @uses $vars['results']
+ * @uses $vars['params']
+ */
+
+$entities = $vars['results']['entities'];
+
+if (!is_array($entities) || !count($entities)) {
+ return FALSE;
+}
+
+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']
+ ));
+ }
+}
+
+echo $body; \ No newline at end of file