aboutsummaryrefslogtreecommitdiff
path: root/mod/search/views/default/search/comments
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-01-11 22:58:55 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-01-11 22:58:55 +0000
commit23594f5a78f4557b183d5cc2a045b684cf32cc74 (patch)
treed354462c702524775a48439dc66c7036e9ec2d7d /mod/search/views/default/search/comments
parenta69015e09a9627c63be577d10c99143190648b7b (diff)
downloadelgg-23594f5a78f4557b183d5cc2a045b684cf32cc74.tar.gz
elgg-23594f5a78f4557b183d5cc2a045b684cf32cc74.tar.bz2
Pulling out entity views in search.
Adding dev documentation. git-svn-id: http://code.elgg.org/elgg/trunk@3795 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/search/views/default/search/comments')
-rw-r--r--mod/search/views/default/search/comments/entity.php59
-rw-r--r--mod/search/views/default/search/comments/listing.php107
2 files changed, 59 insertions, 107 deletions
diff --git a/mod/search/views/default/search/comments/entity.php b/mod/search/views/default/search/comments/entity.php
new file mode 100644
index 000000000..8b4d286c9
--- /dev/null
+++ b/mod/search/views/default/search/comments/entity.php
@@ -0,0 +1,59 @@
+<?php
+/**
+ * Elgg search entity
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @author Curverider Ltd
+ * @link http://elgg.org/
+ */
+$entity = $vars['entity'];
+
+$owner = get_entity($entity->getVolatileData('search_matched_comment_owner_guid'));
+
+if ($owner instanceof ElggUser) {
+ $icon = elgg_view('profile/icon', array('entity' => $owner, 'size' => 'small'));
+} else {
+ $icon = '';
+}
+
+// @todo Sometimes we find comments on entities we can't display...
+if ($entity->getVolatileData('search_unavailable_entity')) {
+ $title = sprintf(elgg_echo('search:comment_on'), elgg_echo('search:unavailable_entity'));
+ // keep anchor for formatting.
+ $title = "<a>$title</a>";
+} 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 = sprintf(elgg_echo('search:comment_on'), $title);
+ $url = $entity->getURL() . '#annotation-' . $entity->getVolatileData('search_match_annotation_id');
+ $title = "<a href=\"$url\">$title</a>";
+}
+
+$description = $entity->getVolatileData('search_matched_comment');
+$tc = $entity->getVolatileData('search_matched_comment_time_created');;
+$time = friendly_time($tc);
+
+echo <<<___END
+ <div class="search_listing">
+ <div class="search_listing_icon">$icon</div>
+ <div class="search_listing_info">
+ <p class="ItemTitle">$title</p>$description
+ <p class="ItemTimestamp">$time</p>
+ </div>
+ </div>
+___END;
+
+?> \ No newline at end of file
diff --git a/mod/search/views/default/search/comments/listing.php b/mod/search/views/default/search/comments/listing.php
deleted file mode 100644
index 34456bde8..000000000
--- a/mod/search/views/default/search/comments/listing.php
+++ /dev/null
@@ -1,107 +0,0 @@
-<?php
-/**
- * Elgg comments search listing
- *
- * @package Elgg
- * @subpackage Core
- * @author Curverider Ltd
- * @link http://elgg.org/
- */
-
-if (!is_array($vars['entities']) || !count($vars['entities'])) {
- return FALSE;
-}
-
-$title_str = elgg_echo('comments');
-
-$query = htmlspecialchars(http_build_query(
- array(
- 'q' => $vars['params']['query'],
- 'entity_type' => $vars['params']['type'],
- 'entity_subtype' => $vars['params']['subtype'],
- 'limit' => get_input('limit', 10),
- 'offset' => get_input('offset', 0),
- 'search_type' => 'comments',
- )
-));
-
-$url = "{$vars['url']}pg/search?$query";
-
-// get pagination
-if (array_key_exists('pagination', $vars) && $vars['pagination']) {
- $nav .= elgg_view('navigation/pagination',array(
- 'baseurl' => $url,
- 'offset' => $vars['params']['offset'],
- 'count' => $vars['count'],
- 'limit' => $vars['params']['limit'],
- ));
-} else {
- $nav = '';
-}
-
-// get more links
-$more_check = $vars['count'] - ($vars['params']['offset'] + $vars['params']['limit']);
-$more = ($more_check > 0) ? $more_check : 0;
-
-if ($more) {
- $title_key = ($more == 1) ? 'comment' : 'comments';
- $more_str = sprintf(elgg_echo('search:more'), $vars['count'], elgg_echo($title_key));
- $more_link = "<div class='search_listing'><a href=\"$url\">$more_str</a></div>";
-} else {
- $more_link = '';
-}
-
-$body = elgg_view_title($title_str);
-
-foreach ($vars['entities'] as $entity) {
- $owner = get_entity($entity->getVolatileData('search_matched_comment_owner_guid'));
-
- if ($owner instanceof ElggUser) {
- $icon = elgg_view('profile/icon', array('entity' => $owner, 'size' => 'small'));
- } else {
- $icon = '';
- }
-
- // @todo Sometimes we find comments on entities we can't display...
- if ($entity->getVolatileData('search_unavailable_entity')) {
- $title = sprintf(elgg_echo('search:comment_on'), elgg_echo('search:unavailable_entity'));
- // keep anchor for formatting.
- $title = "<a>$title</a>";
- } 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 = sprintf(elgg_echo('search:comment_on'), $title);
- $url = $entity->getURL() . '#annotation-' . $entity->getVolatileData('search_match_annotation_id');
- $title = "<a href=\"$url\">$title</a>";
- }
-
- $description = $entity->getVolatileData('search_matched_comment');
- $tc = $entity->getVolatileData('search_matched_comment_time_created');;
- $time = friendly_time($tc);
-
- $body .= <<<___END
- <div class="search_listing">
- <div class="search_listing_icon">$icon</div>
- <div class="search_listing_info">
- <p class="ItemTitle">$title</p>$description
- <p class="ItemTimestamp">$time</p>
- </div>
- </div>
-___END;
-}
-
-echo $body;
-echo $more_link;
-echo $nav;