diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2014-03-15 14:46:48 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2014-03-15 14:46:48 -0300 |
commit | a89ba6df7133bc7f0b8ea96d4a5673887b267af4 (patch) | |
tree | e6850ce6c3f894b3867d172cbdea6cd75031ab26 /mod/cool_theme/views/default/search | |
parent | 0d860aca4fda73fce303dad41003e61f040acca8 (diff) | |
parent | 5041c6c48153453ed597206d08eeff37cf20e676 (diff) | |
download | elgg-a89ba6df7133bc7f0b8ea96d4a5673887b267af4.tar.gz elgg-a89ba6df7133bc7f0b8ea96d4a5673887b267af4.tar.bz2 |
Merge commit '5041c6c48153453ed597206d08eeff37cf20e676' as 'mod/cool_theme'
Diffstat (limited to 'mod/cool_theme/views/default/search')
-rw-r--r-- | mod/cool_theme/views/default/search/css.php | 11 | ||||
-rw-r--r-- | mod/cool_theme/views/default/search/entity.php | 57 | ||||
-rw-r--r-- | mod/cool_theme/views/default/search/search_box.php | 27 |
3 files changed, 95 insertions, 0 deletions
diff --git a/mod/cool_theme/views/default/search/css.php b/mod/cool_theme/views/default/search/css.php new file mode 100644 index 000000000..3e0c5f379 --- /dev/null +++ b/mod/cool_theme/views/default/search/css.php @@ -0,0 +1,11 @@ +<?php +/** + * Elgg Search css + * + */ +?> +/* <style> +/********************************** +Search plugin +***********************************/ +.elgg-search {width: 330px;background: white url(<?php echo elgg_get_site_url(); ?>_graphics/elgg_sprites.png) no-repeat 335px -934px;border: 1px solid #AAA;border-radius: 1px;height: 20px;padding: 0 23px 0 0;}.elgg-search .search-input {padding: 1px 0 1px 3px;margin: 2px 0 2px 2px;outline: none;font-size: 11px;border: 0;border-right: 1px solid #e9e9e9;}.elgg-search input[type=submit] {display: none;}.elgg-search .search-input:focus {background-position: 2px -700px;}.elgg-page-header .elgg-search {bottom: 5px;position: absolute;right: 0;border-color: black;}.elgg-page-topbar .elgg-search {margin: 4px 0 4px 181px;position: relative;}.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;}
\ No newline at end of file diff --git a/mod/cool_theme/views/default/search/entity.php b/mod/cool_theme/views/default/search/entity.php new file mode 100644 index 000000000..287ce4512 --- /dev/null +++ b/mod/cool_theme/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, 'small'); + } elseif ($owner = $entity->getOwnerEntity()) { + $icon = elgg_view_entity_icon($owner, '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_entity($entity, 'small'); + } +} + +$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/cool_theme/views/default/search/search_box.php b/mod/cool_theme/views/default/search/search_box.php new file mode 100644 index 000000000..36cceef4a --- /dev/null +++ b/mod/cool_theme/views/default/search/search_box.php @@ -0,0 +1,27 @@ +<?php +/** + * Search box + * + * @uses $vars['value'] Current search query + * + * @todo Move javascript into something that extends elgg.js + */ + +$value = ''; +if (array_key_exists('value', $vars)) { + $value = $vars['value']; +} elseif ($value = get_input('q', get_input('tag', NULL))) { + $value = $value; +} + +// @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 +$display_query = mb_convert_encoding($value, 'HTML-ENTITIES', 'UTF-8'); +$display_query = htmlspecialchars($display_query, ENT_QUOTES, 'UTF-8', false); + + +?> +<form class="elgg-search" action="<?php echo elgg_get_site_url(); ?>search" method="get"><fieldset><input type="text" size="21" name="q" placeholder="<?php echo elgg_echo('search'); ?>" class="search-input" value="<?php echo $value; ?>"/><input type="submit" value="<?php echo elgg_echo('search:go'); ?>" class="search-submit-button" /></fieldset></form>
\ No newline at end of file |