diff options
Diffstat (limited to 'mod/search/views/default')
-rw-r--r-- | mod/search/views/default/search/comments/entity.php | 55 | ||||
-rw-r--r-- | mod/search/views/default/search/css.php | 67 | ||||
-rw-r--r-- | mod/search/views/default/search/entity.php | 57 | ||||
-rw-r--r-- | mod/search/views/default/search/header.php | 6 | ||||
-rw-r--r-- | mod/search/views/default/search/layout.php | 8 | ||||
-rw-r--r-- | mod/search/views/default/search/list.php | 115 | ||||
-rw-r--r-- | mod/search/views/default/search/no_results.php | 6 | ||||
-rw-r--r-- | mod/search/views/default/search/search_box.php | 43 | ||||
-rw-r--r-- | mod/search/views/default/search/startblurb.php | 6 |
9 files changed, 363 insertions, 0 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..77e950843 --- /dev/null +++ b/mod/search/views/default/search/comments/entity.php @@ -0,0 +1,55 @@ +<?php +/** + * Default search view for a comment + * + * @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); + +$owner = get_entity($comment_data['owner_guid']); + +if ($owner instanceof ElggUser) { + $icon = elgg_view_entity_icon($owner, 'tiny'); +} else { + $icon = ''; +} + +// @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'))); + // 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 = elgg_echo('search:comment_on', array($title)); + + // @todo this should use something like $comment->getURL() + $url = $entity->getURL() . '#comment_' . $comment_data['annotation_id']; + $title = "<a href=\"$url\">$title</a>"; +} + +$description = $comment_data['text']; +$tc = $comment_data['time_created']; +$time = elgg_view_friendly_time($tc); + +$body = "<p class=\"mbn\">$title</p>$description"; +$body .= "<p class=\"elgg-subtext\">$time</p>"; + +echo elgg_view_image_block($icon, $body); diff --git a/mod/search/views/default/search/css.php b/mod/search/views/default/search/css.php new file mode 100644 index 000000000..30ff45172 --- /dev/null +++ b/mod/search/views/default/search/css.php @@ -0,0 +1,67 @@ +<?php +/** + * Elgg Search css + * + */ +?> + +/********************************** +Search plugin +***********************************/ +.elgg-search-header { + bottom: 5px; + height: 23px; + position: absolute; + right: 0; +} +.elgg-search input[type=text] { + width: 230px; +} +.elgg-search input[type=submit] { + display: none; +} +.elgg-search input[type=text] { + -webkit-border-radius: 10px; + -moz-border-radius: 10px; + border-radius: 10px; + + border: 1px solid #71b9f7; + color: white; + font-size: 12px; + font-weight: bold; + padding: 2px 4px 2px 26px; + background: transparent url(<?php echo elgg_get_site_url(); ?>_graphics/elgg_sprites.png) no-repeat 2px -934px; +} +.elgg-search input[type=text]:focus, .elgg-search input[type=text]:active { + background-color: white; + background-position: 2px -916px; + border: 1px solid white; + color: #0054A7; +} + +.search-list li { + padding: 5px 0 0; +} +.search-heading-category { + margin-top: 20px; + color: #666666; +} + +.search-highlight { + background-color: #bbdaf7; +} +.search-highlight-color1 { + background-color: #bbdaf7; +} +.search-highlight-color2 { + background-color: #A0FFFF; +} +.search-highlight-color3 { + background-color: #FDFFC3; +} +.search-highlight-color4 { + background-color: #ccc; +} +.search-highlight-color5 { + background-color: #4690d6; +} diff --git a/mod/search/views/default/search/entity.php b/mod/search/views/default/search/entity.php new file mode 100644 index 000000000..e04d08836 --- /dev/null +++ b/mod/search/views/default/search/entity.php @@ -0,0 +1,57 @@ +<?php +/** + * Default view for an entity returned in a search + * + * 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) + * + * @uses $vars['entity'] Entity returned in a search + */ + +$entity = $vars['entity']; + +$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_entity_icon($entity, 'tiny'); + } elseif ($owner = $entity->getOwnerEntity()) { + $icon = elgg_view_entity_icon($owner, '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_entity_icon($entity, 'tiny'); + } +} + +$title = $entity->getVolatileData('search_matched_title'); +$description = $entity->getVolatileData('search_matched_description'); +$extra_info = $entity->getVolatileData('search_matched_extra'); +$url = $entity->getVolatileData('search_url'); + +if (!$url) { + $url = $entity->getURL(); +} + +$title = "<a href=\"$url\">$title</a>"; +$time = $entity->getVolatileData('search_time'); +if (!$time) { + $tc = $entity->time_created; + $tu = $entity->time_updated; + $time = elgg_view_friendly_time(($tu > $tc) ? $tu : $tc); +} + +$body = "<p class=\"mbn\">$title</p>$description"; +if ($extra_info) { + $body .= "<p class=\"elgg-subtext\">$extra_info</p>"; +} +$body .= "<p class=\"elgg-subtext\">$time</p>"; + +echo elgg_view_image_block($icon, $body); diff --git a/mod/search/views/default/search/header.php b/mod/search/views/default/search/header.php new file mode 100644 index 000000000..6f8654c13 --- /dev/null +++ b/mod/search/views/default/search/header.php @@ -0,0 +1,6 @@ +<?php +/** + * Search box in page header + */ + +echo elgg_view('search/search_box', array('class' => 'elgg-search-header'));
\ No newline at end of file diff --git a/mod/search/views/default/search/layout.php b/mod/search/views/default/search/layout.php new file mode 100644 index 000000000..eb597836e --- /dev/null +++ b/mod/search/views/default/search/layout.php @@ -0,0 +1,8 @@ +<?php +/** + * The default search layout + * + * @uses $vars['body'] + */ + +echo elgg_view_layout('one_sidebar', array('content' => $vars['body']));
\ No newline at end of file diff --git a/mod/search/views/default/search/list.php b/mod/search/views/default/search/list.php new file mode 100644 index 000000000..90aa28989 --- /dev/null +++ b/mod/search/views/default/search/list.php @@ -0,0 +1,115 @@ +<?php +/** + * List a section of search results corresponding in a particular type/subtype + * or search type (comments for example) + * + * @uses $vars['results'] Array of data related to search results including: + * - 'entities' Array of entities to be displayed + * - 'count' Total number of results + * @uses $vars['params'] Array of parameters including: + * - 'type' Entity type + * - 'subtype' Entity subtype + * - 'search_type' Type of search: 'entities', 'comments', 'tags' + * - 'offset' Offset in search results + * - 'limit' Number of results per page + * - 'pagination' Display pagination? + */ + +$entities = $vars['results']['entities']; +$count = $vars['results']['count'] - count($entities); + +if (!is_array($entities) || !count($entities)) { + return FALSE; +} + +$query = http_build_query( + array( + 'q' => $vars['params']['query'], + 'entity_type' => $vars['params']['type'], + 'entity_subtype' => $vars['params']['subtype'], + 'limit' => $vars['params']['limit'], + 'offset' => $vars['params']['offset'], + 'search_type' => $vars['params']['search_type'], + //@todo include vars for sorting, order, and friend-only. + ) +); + +$url = elgg_get_site_url() . "search?$query"; + +$more_items = $vars['results']['count'] - ($vars['params']['offset'] + $vars['params']['limit']); + +// get pagination +if (array_key_exists('pagination', $vars['params']) && $vars['params']['pagination']) { + $nav = elgg_view('navigation/pagination', array( + 'base_url' => $url, + 'offset' => $vars['params']['offset'], + 'count' => $vars['results']['count'], + 'limit' => $vars['params']['limit'], + )); + $show_more = false; +} else { + // faceted search page so no pagination + $nav = ''; + $show_more = $more_items > 0; +} + +// figure out what we're dealing with. +$type_str = NULL; + +if (array_key_exists('type', $vars['params']) && array_key_exists('subtype', $vars['params'])) { + $type_str_tmp = "item:{$vars['params']['type']}:{$vars['params']['subtype']}"; + $type_str_echoed = elgg_echo($type_str_tmp); + if ($type_str_echoed != $type_str_tmp) { + $type_str = $type_str_echoed; + } +} + +if (!$type_str && array_key_exists('type', $vars['params'])) { + $type_str = elgg_echo("item:{$vars['params']['type']}"); +} + +if (!$type_str) { + $type_str = elgg_echo('search:unknown_entity'); +} + +// allow overrides for titles +$search_type_str = elgg_echo("search_types:{$vars['params']['search_type']}"); +if (array_key_exists('search_type', $vars['params']) + && $search_type_str != "search_types:{$vars['params']['search_type']}") { + + $type_str = $search_type_str; +} + +if ($show_more) { + $more_str = elgg_echo('search:more', array($count, $type_str)); + $more_url = elgg_http_remove_url_query_element($url, 'limit'); + $more_link = "<li class='elgg-item'><a href=\"$more_url\">$more_str</a></li>"; +} else { + $more_link = ''; +} + +// @todo once elgg_view_title() supports passing a $vars array use it +$body = elgg_view('page/elements/title', array( + 'title' => $type_str, + 'class' => 'search-heading-category', +)); + +$view = search_get_search_view($vars['params'], 'entity'); +if ($view) { + $body .= '<ul class="elgg-list search-list">'; + foreach ($entities as $entity) { + $id = "elgg-{$entity->getType()}-{$entity->getGUID()}"; + $body .= "<li id=\"$id\" class=\"elgg-item\">"; + $body .= elgg_view($view, array( + 'entity' => $entity, + 'params' => $vars['params'], + 'results' => $vars['results'] + )); + $body .= '</li>'; + } + $body .= $more_link; + $body .= '</ul>'; +} + +echo $body; +echo $nav; diff --git a/mod/search/views/default/search/no_results.php b/mod/search/views/default/search/no_results.php new file mode 100644 index 000000000..0e9a5e295 --- /dev/null +++ b/mod/search/views/default/search/no_results.php @@ -0,0 +1,6 @@ +<?php +/** + * No results from search + */ + +echo elgg_autop(elgg_echo('search:no_results')); diff --git a/mod/search/views/default/search/search_box.php b/mod/search/views/default/search/search_box.php new file mode 100644 index 000000000..7474a280c --- /dev/null +++ b/mod/search/views/default/search/search_box.php @@ -0,0 +1,43 @@ +<?php +/** + * Search box + * + * @uses $vars['value'] Current search query + * @uses $vars['class'] Additional class + */ + +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'); +} + +$class = "elgg-search"; +if (isset($vars['class'])) { + $class = "$class {$vars['class']}"; +} + +// @todo - why the strip slashes? +$value = stripslashes($value); + +// @todo - create function for sanitization of strings for display in 1.8 +// encode <,>,&, quotes and characters above 127 +if (function_exists('mb_convert_encoding')) { + $display_query = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8'); +} else { + // if no mbstring extension, we just strip characters + $display_query = preg_replace("/[^\x01-\x7F]/", "", $value); +} +$display_query = htmlspecialchars($display_query, ENT_QUOTES, 'UTF-8', false); + +?> + +<form class="<?php echo $class; ?>" action="<?php echo elgg_get_site_url(); ?>search" method="get"> + <fieldset> + <input type="text" class="search-input" size="21" name="q" value="<?php echo $display_query; ?>" onblur="if (this.value=='') { this.value='<?php echo elgg_echo('search'); ?>' }" onfocus="if (this.value=='<?php echo elgg_echo('search'); ?>') { this.value='' };" /> + <input type="hidden" name="search_type" value="all" /> + <input type="submit" value="<?php echo elgg_echo('search:go'); ?>" class="search-submit-button" /> + </fieldset> +</form> diff --git a/mod/search/views/default/search/startblurb.php b/mod/search/views/default/search/startblurb.php new file mode 100644 index 000000000..d6394da0d --- /dev/null +++ b/mod/search/views/default/search/startblurb.php @@ -0,0 +1,6 @@ +<?php +/** + * @todo This doesn't appear to be called by anything. Look into removing. + */ + +echo elgg_echo("tag:search:startblurb", array($vars['query'])); |