aboutsummaryrefslogtreecommitdiff
path: root/mod/search
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-04-05 16:51:32 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-04-05 16:51:32 +0000
commit08d3f7f2820ed971ce5171c9ce9e15dbf452cf3f (patch)
tree75fd0261d5f92442fae934a58a9404bc3ed162f1 /mod/search
parent36ef345eb6425106f061fb866d9fa66d051e16df (diff)
downloadelgg-08d3f7f2820ed971ce5171c9ce9e15dbf452cf3f.tar.gz
elgg-08d3f7f2820ed971ce5171c9ce9e15dbf452cf3f.tar.bz2
Merged 5605:5622 from 1.7 to trunk.
git-svn-id: http://code.elgg.org/elgg/trunk@5623 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/search')
-rw-r--r--mod/search/languages/en.php1
-rw-r--r--mod/search/search_hooks.php2
-rw-r--r--mod/search/views/default/search/css.php11
-rw-r--r--mod/search/views/default/search/entity.php79
-rw-r--r--mod/search/views/rss/search/comments/entity.php53
5 files changed, 113 insertions, 33 deletions
diff --git a/mod/search/languages/en.php b/mod/search/languages/en.php
index 546a428a2..e3899500f 100644
--- a/mod/search/languages/en.php
+++ b/mod/search/languages/en.php
@@ -14,6 +14,7 @@ $english = array(
'search_types:comments' => 'Comments',
'search:comment_on' => 'Comment on "%s"',
+ 'search:comment_by' => 'by',
'search:unavailable_entity' => 'Unavailable Entity',
);
diff --git a/mod/search/search_hooks.php b/mod/search/search_hooks.php
index 0b606ac66..1af208d6e 100644
--- a/mod/search/search_hooks.php
+++ b/mod/search/search_hooks.php
@@ -257,7 +257,7 @@ function search_tags_hook($hook, $type, $value, $params) {
$tags_str = implode('. ', $matched_tags_strs);
$tags_str = search_get_highlighted_relevant_substrings($tags_str, $params['query']);
- $tags_str = "($tags_str)";
+ //$tags_str = "($tags_str)";
$entity->setVolatileData('search_matched_title', $title_str);
$entity->setVolatileData('search_matched_description', $desc_str);
diff --git a/mod/search/views/default/search/css.php b/mod/search/views/default/search/css.php
index 4eb07d323..72b696059 100644
--- a/mod/search/views/default/search/css.php
+++ b/mod/search/views/default/search/css.php
@@ -76,3 +76,14 @@
.searchMatchColor5 {
background-color: #4690d6;
}
+
+/* formatting for the search results */
+.search_listing .item_extra {
+ border: 1px solid #cccccc;
+ margin: 2px;
+ padding: 3px;
+}
+
+.search_listing .item_timestamp {
+ font-style: italic;
+} \ No newline at end of file
diff --git a/mod/search/views/default/search/entity.php b/mod/search/views/default/search/entity.php
index 2b08384d5..b65bad888 100644
--- a/mod/search/views/default/search/entity.php
+++ b/mod/search/views/default/search/entity.php
@@ -2,6 +2,14 @@
/**
* Elgg search entity
*
+ * Display largely controlled by a set of overrideable volatile data:
+ * - search_icon (defaults to entity icon)
+ * - search_matched_title
+ * - search_matched_description
+ * - search_matched_extra
+ * - search_url (defaults to entity->getURL())
+ * - search_time (defaults to entity->time_updated or entity->time_created)
+ *
* @package Elgg
* @subpackage Core
* @author Curverider Ltd
@@ -10,46 +18,53 @@
$entity = $vars['entity'];
-// display the entity's owner by default if available.
-// @todo allow an option to switch to displaying the entity's icon instead.
-$type = $entity->getType();
-if ($type == 'user' || $type == 'group') {
- $icon = elgg_view('profile/icon', array('entity' => $entity, 'size' => 'tiny'));
-} elseif ($owner = $entity->getOwnerEntity()) {
- $icon = elgg_view('profile/icon', array('entity' => $owner, 'size' => 'tiny'));
-} else {
- // display a generic icon if no owner, though there will probably be
- // other problems if the owner can't be found.
- $icon = elgg_view(
- 'graphics/icon', array(
- 'entity' => $entity,
- 'size' => 'tiny',
- ));
+$icon = $entity->getVolatileData('search_icon');
+if (!$icon) {
+ // display the entity's owner by default if available.
+ // @todo allow an option to switch to displaying the entity's icon instead.
+ $type = $entity->getType();
+ if ($type == 'user' || $type == 'group') {
+ $icon = elgg_view('profile/icon', array('entity' => $entity, 'size' => 'small'));
+ } elseif ($owner = $entity->getOwnerEntity()) {
+ $icon = elgg_view('profile/icon', array('entity' => $owner, 'size' => 'small'));
+ } else {
+ // display a generic icon if no owner, though there will probably be
+ // other problems if the owner can't be found.
+ $icon = elgg_view(
+ 'graphics/icon', array(
+ 'entity' => $entity,
+ 'size' => 'small',
+ ));
+ }
}
$title = $entity->getVolatileData('search_matched_title');
$description = $entity->getVolatileData('search_matched_description');
$extra_info = $entity->getVolatileData('search_matched_extra');
-$url = $entity->getURL();
-
-if (!$title) {
- $title = elgg_echo('untitled');
+$url = $entity->getVolatileData('search_url');
+if (!$url) {
+ $url = $entity->getURL();
}
-
$title = "<a href=\"$url\">$title</a>";
-$tc = $entity->time_created;
-$tu = $entity->time_updated;
-$time = friendly_time(($tu > $tc) ? $tu : $tc);
-
-echo <<<___END
+$time = $entity->getVolatileData('search_time');
+if (!$time) {
+ $tc = $entity->time_created;
+ $tu = $entity->time_updated;
+ $time = friendly_time(($tu > $tc) ? $tu : $tc);
+}
+?>
<div class="search_listing clearfloat">
- <div class="search_listing_icon">$icon</div>
+ <div class="search_listing_icon"><?php echo $icon; ?></div>
<div class="search_listing_info">
- <p class="entity_title">$title</p>$description
- <p class="entity_subtext">$time $extra_info</p>
+ <p class="item_title"><?php echo $title; ?></p>
+ <p class="item_description"><?php echo $description; ?></p>
+<?php
+if ($extra_info) {
+?>
+ <p class="item_extra"><?php echo $extra_info; ?></p>
+<?php
+}
+?>
+ <p class="item_timestamp"><?php echo $time; ?></p>
</div>
</div>
-___END;
-
-// php bug. must have close tag after heredocs
-?> \ No newline at end of file
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..1b788fbae
--- /dev/null
+++ b/mod/search/views/rss/search/comments/entity.php
@@ -0,0 +1,53 @@
+<?php
+/**
+ * Elgg search comment view
+ *
+ * @package Elgg
+ * @subpackage Core
+ * @author Curverider Ltd
+ * @link http://elgg.org/
+ */
+$entity = $vars['entity'];
+
+$author_name = '';
+$comment_author_guid = $entity->getVolatileData('search_matched_comment_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 = sprintf(elgg_echo('search:comment_on'), 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 = sprintf(elgg_echo('search:comment_on'), $title);
+ $title .= ' ' . elgg_echo('search:comment_by') . ' ' . $author_name;
+ $url = $entity->getURL() . '#annotation-' . $entity->getVolatileData('search_match_annotation_id');
+}
+
+$description = $entity->getVolatileData('search_matched_comment');
+$tc = $entity->getVolatileData('search_matched_comment_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>