aboutsummaryrefslogtreecommitdiff
path: root/mod/search/views
diff options
context:
space:
mode:
Diffstat (limited to 'mod/search/views')
-rw-r--r--mod/search/views/default/page_elements/searchbox.php14
-rw-r--r--mod/search/views/default/search/comments/listing.php70
-rw-r--r--mod/search/views/default/search/css.php3
-rw-r--r--mod/search/views/default/search/listing.php55
4 files changed, 110 insertions, 32 deletions
diff --git a/mod/search/views/default/page_elements/searchbox.php b/mod/search/views/default/page_elements/searchbox.php
index cfc0b953b..f7746b0da 100644
--- a/mod/search/views/default/page_elements/searchbox.php
+++ b/mod/search/views/default/page_elements/searchbox.php
@@ -1,4 +1,16 @@
+<?php
+
+if (array_key_exists('value', $vars)) {
+ $value = $vars['value'];
+} elseif ($value = get_input('q', get_input('tag', NULL))) {
+ $value = $value;
+} else {
+ $value = elgg_echo('search');
+}
+
+?>
+
<form id="searchform" action="<?php echo $vars['url']; ?>pg/search/" method="get">
- <input type="text" size="21" name="q" value="<?php echo elgg_echo('search'); ?>" onclick="if (this.value=='<?php echo elgg_echo('search'); ?>') { this.value='' }" class="search_input" />
+ <input type="text" size="21" name="q" value="<?php echo $value; ?>" onclick="if (this.value=='<?php echo elgg_echo('search'); ?>') { this.value='' }" class="search_input" />
<input type="submit" value="<?php echo elgg_echo('search:go'); ?>" class="search_submit_button" />
</form>
diff --git a/mod/search/views/default/search/comments/listing.php b/mod/search/views/default/search/comments/listing.php
index 58353a110..13f368f2b 100644
--- a/mod/search/views/default/search/comments/listing.php
+++ b/mod/search/views/default/search/comments/listing.php
@@ -7,16 +7,12 @@
* @author Curverider Ltd
* @link http://elgg.org/
*/
-?>
-<div class="search_listing">
-<?php
if (!is_array($vars['entities']) || !count($vars['entities'])) {
return FALSE;
}
$title_str = elgg_echo('comments');
-$body = elgg_view_title($title_str);
$query = htmlspecialchars(http_build_query(
array(
@@ -30,9 +26,33 @@ $query = htmlspecialchars(http_build_query(
));
$url = "{$vars['url']}pg/search?$query";
-$more = "<a href=\"$url\">+$count more $title_str</a>";
-echo elgg_view('page_elements/contentwrapper', array('body' => $body));
+// 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 = "<a href=\"$url\">$more_str</a>";
+} else {
+ $more_link = '';
+}
+
+echo $nav;
+$body = elgg_view_title($title_str);
foreach ($vars['entities'] as $entity) {
if ($owner = $entity->getOwnerEntity()) {
@@ -41,22 +61,46 @@ foreach ($vars['entities'] as $entity) {
} else {
$icon = '';
}
- $title = "Comment on " . elgg_echo('item:' . $entity->getType() . ':' . $entity->getSubtype());
+
+ // @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');
- $url = $entity->getURL();
- $title = "<a href=\"$url\">$title</a>";
$tc = $entity->getVolatileData('search_matched_comment_time_created');;
$time = friendly_time($tc);
- echo <<<___END
+ $body .= <<<___END
<span class="searchListing">
<h3 class="searchTitle">$title</h3>
<span class="searchDetails">
<span class="searchDescription">$description</span><br />
- $icon $time - $more</a>
+ $icon $time - $more_link</a>
</span>
</span>
___END;
}
-?>
-</div>
+
+$body .= $nav;
+echo elgg_view('page_elements/contentwrapper', array('body' => $body));
diff --git a/mod/search/views/default/search/css.php b/mod/search/views/default/search/css.php
index 28dc82a4a..19cca02e8 100644
--- a/mod/search/views/default/search/css.php
+++ b/mod/search/views/default/search/css.php
@@ -38,7 +38,6 @@ margin: 6px;
background-color: #99FF99;
}
-
.searchTitle {
text-decoration: underline;
}
@@ -91,7 +90,7 @@ margin: 6px;
}
/* override the entity container piece */
-.search_listing .entity_listing {
+.search_listing .search_listing {
-webkit-border-radius: 0px;
-moz-border-radius: 0px;
background: transparent;
diff --git a/mod/search/views/default/search/listing.php b/mod/search/views/default/search/listing.php
index 37850c911..f947bd808 100644
--- a/mod/search/views/default/search/listing.php
+++ b/mod/search/views/default/search/listing.php
@@ -7,11 +7,8 @@
* @author Curverider Ltd
* @link http://elgg.org/
*/
-?>
-<div class="search_listing">
-<?php
$entities = $vars['entities'];
$count = $vars['count'] - count($vars['entities']);
@@ -19,24 +16,52 @@ if (!is_array($vars['entities']) || !count($vars['entities'])) {
return FALSE;
}
-$title_str = elgg_echo("item:{$vars['params']['type']}:{$vars['params']['subtype']}");
-$body = elgg_view_title($title_str);
+// figure out what we're deal with.
+if (array_key_exists('type', $vars['params']) && array_key_exists('subtype', $vars['params'])) {
+ $type_str = elgg_echo("item:{$vars['params']['type']}:{$vars['params']['subtype']}");
+} elseif (array_key_exists('type', $vars['params'])) {
+ $type_str = elgg_echo("item:{$vars['params']['type']}");
+} else {
+ $type_str = elgg_echo('search:unknown_entity');
+}
$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' => 'entities',
)
));
$url = "{$vars['url']}pg/search?$query";
-$more = "<a href=\"$url\">+$count more $title_str</a>";
-echo elgg_view('page_elements/contentwrapper', array('body' => $body));
+// get pagination
+if (array_key_exists('pagination', $vars['params']) && $vars['params']['pagination']) {
+ $nav .= elgg_view('navigation/pagination',array(
+ 'baseurl' => $url,
+ 'offset' => $vars['params']['offset'],
+ 'count' => $vars['count'],
+ 'limit' => $vars['params']['limit'],
+ ));
+} else {
+ $nav = '';
+}
+
+// get any 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'), $count, $type_str);
+ $more_link = "<a href=\"$url\">$more_str</a>";
+} else {
+ $more_link = '';
+}
+
+echo $nav;
+$body = elgg_view_title($title_str);
foreach ($entities as $entity) {
if ($owner = $entity->getOwnerEntity()) {
@@ -53,16 +78,14 @@ foreach ($entities as $entity) {
$tu = $entity->time_updated;
$time = friendly_time(($tu > $tc) ? $tu : $tc);
- echo <<<___END
+ $body .= <<<___END
<span class="searchListing">
<h3 class="searchTitle">$title</h3>
- <span class="searchDetails">
- <span class="searchDescription">$description</span><br />
- $icon $time - $more</a>
- </span>
+ <span class="searchDescription">$description</span><br />
+ <span class="searchInfo">$icon $time - $more_link</span>
</span>
___END;
}
-?>
-</div> \ No newline at end of file
+echo elgg_view('page_elements/contentwrapper', array('body' => $body));
+echo $nav; \ No newline at end of file