From 2aaf2d80f1cbc2a6ad4a1b4b5ef97c3494d6a0bd Mon Sep 17 00:00:00 2001 From: cash Date: Tue, 8 Feb 2011 12:23:04 +0000 Subject: updated search plugin for new html/css git-svn-id: http://code.elgg.org/elgg/trunk@8075 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/search/start.php | 11 +-- .../views/default/search/comments/entity.php | 17 ++--- mod/search/views/default/search/css.php | 78 +++++----------------- mod/search/views/default/search/entity.php | 22 ++---- mod/search/views/default/search/list.php | 44 ++++++------ 5 files changed, 55 insertions(+), 117 deletions(-) diff --git a/mod/search/start.php b/mod/search/start.php index 4f57a64c5..401bf84a5 100644 --- a/mod/search/start.php +++ b/mod/search/start.php @@ -249,8 +249,8 @@ function search_highlight_words($words, $string) { $replace_html = array( 'strong' => rand(10000, 99999), 'class' => rand(10000, 99999), - 'searchMatch' => rand(10000, 99999), - 'searchMatchColor' => rand(10000, 99999) + 'search-highlight' => rand(10000, 99999), + 'search-highlight-color' => rand(10000, 99999) ); foreach ($words as $word) { @@ -262,16 +262,17 @@ function search_highlight_words($words, $string) { $search = "/($word)/i"; + // @todo // must replace with placeholders in case one of the search terms is // in the html string. // later, will replace the placeholders with the actual html. // Yeah this is hacky. I'm tired. $strong = $replace_html['strong']; $class = $replace_html['class']; - $searchMatch = $replace_html['searchMatch']; - $searchMatchColor = $replace_html['searchMatchColor']; + $highlight = $replace_html['search-highlight']; + $color = $replace_html['search-highlight-color']; - $replace = "<$strong $class=\"$searchMatch $searchMatchColor{$i}\">$1"; + $replace = "<$strong $class=\"$highlight $color{$i}\">$1"; $string = preg_replace($search, $replace, $string); $i++; } diff --git a/mod/search/views/default/search/comments/entity.php b/mod/search/views/default/search/comments/entity.php index eddb36547..005bb270c 100644 --- a/mod/search/views/default/search/comments/entity.php +++ b/mod/search/views/default/search/comments/entity.php @@ -1,6 +1,6 @@ getVolatileData('search_matched_comment'); $tc = $entity->getVolatileData('search_matched_comment_time_created');; $time = elgg_view_friendly_time($tc); -echo <<<___END -
-
$icon
-
-

$title

$description -

$time

-
-
-___END; - -?> \ No newline at end of file +$body = "

$title

$description"; +$body .= "

$time

"; + +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 index d6e905bf0..02e43bf8b 100644 --- a/mod/search/views/default/search/css.php +++ b/mod/search/views/default/search/css.php @@ -2,10 +2,12 @@ /** * Elgg Search css * - * @package search */ ?> +/********************************** + Search plugin +***********************************/ .elgg-page-header .elgg-search { bottom: 5px; height: 23px; @@ -15,6 +17,9 @@ .elgg-page-header .elgg-search input[type=text] { width: 198px; } +.elgg-page-header .elgg-search input[type=submit] { + display: none; +} .elgg-search input[type=text] { -webkit-border-radius: 10px; -moz-border-radius: 10px; @@ -34,79 +39,30 @@ border: 1px solid white; background-position: 2px -257px; } -.elgg-page-header .elgg-search input[type=submit] { - display: none; -} -.search_listing { - background:none; - border-bottom:1px dotted #CCCCCC; - clear:both; - display:block; - margin:0; - padding:5px 0 7px; - position:relative; -} -.search_listing_icon { - float:left; - margin-left:3px; - margin-top:3px; -} -.search_listing_icon .avatar_menu_button img { - width: 15px; - margin:0; -} -.search_listing_info { - float:left; - margin-left:7px; - min-height:28px; - width:693px; +.search-list li { + padding: 5px 0 0; } -.search_listing_info p { - margin:0; -} -.search_listing_category_title { - margin-top:20px; -} -.search_listing_category_title h2 { - color:#666666; -} -.search_listing.more { - display: block; +.search-heading-category { + margin-top: 20px; + color: #666666; } - -/* search matches */ -.searchtype { - background: #FFFACD; - color: black; -} -.searchtypes { - border: 1px #EEEEEE solid; - padding: 4px; - margin: 6px; -} -.searchMatch { +.search-highlight { background-color: #bbdaf7; } -.searchMatchColor1 { +.search-highlight-color1 { background-color: #bbdaf7; } -.searchMatchColor2 { +.search-highlight-color2 { background-color: #A0FFFF; } -.searchMatchColor3 { +.search-highlight-color3 { background-color: #FDFFC3; } -.searchMatchColor4 { +.search-highlight-color4 { background-color: #cccccc; } -.searchMatchColor5 { +.search-highlight-color5 { background-color: #4690d6; } - -/* formatting for the search results */ - -.search_listing .item_timestamp { - font-style: italic; -} diff --git a/mod/search/views/default/search/entity.php b/mod/search/views/default/search/entity.php index ae3d43e01..2193a70d8 100644 --- a/mod/search/views/default/search/entity.php +++ b/mod/search/views/default/search/entity.php @@ -47,21 +47,11 @@ if (!$time) { $tu = $entity->time_updated; $time = elgg_view_friendly_time(($tu > $tc) ? $tu : $tc); } -?> -
-
- -
-
-

- -$title

$description"; if ($extra_info) { -?> -

-$extra_info

"; } -?> -

-
-
+$body .= "

$time

"; + +echo elgg_view_image_block($icon, $body); diff --git a/mod/search/views/default/search/list.php b/mod/search/views/default/search/list.php index 27916a363..6f09ae521 100644 --- a/mod/search/views/default/search/list.php +++ b/mod/search/views/default/search/list.php @@ -10,8 +10,8 @@ * - 'type' Entity type * - 'subtype' Entity subtype * - 'search_type' Type of search: 'entities', 'comments', 'tags' - * - 'offset' - * - 'limit' + * - 'offset' Offset in search results + * - 'limit' Number of results per page * - 'pagination' Display pagination? */ @@ -22,14 +22,13 @@ if (!is_array($entities) || !count($entities)) { return FALSE; } -// @todo why are limit and offset pulled from input here and from $vars['params'] later $query = 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), + 'limit' => $vars['params']['limit'], + 'offset' => $vars['params']['offset'], 'search_type' => $vars['params']['search_type'], //@todo include vars for sorting, order, and friend-only. ) @@ -76,18 +75,6 @@ if (array_key_exists('search_type', $vars['params']) $type_str = $search_type_str; } -// 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['results']['count'], - 'limit' => $vars['params']['limit'], - )); -} else { - $nav = ''; -} - // get any more links. $more_check = $vars['results']['count'] - ($vars['params']['offset'] + $vars['params']['limit']); $more = ($more_check > 0) ? $more_check : 0; @@ -95,22 +82,33 @@ $more = ($more_check > 0) ? $more_check : 0; if ($more) { $title_key = ($more == 1) ? 'comment' : 'comments'; $more_str = elgg_echo('search:more', array($count, $type_str)); - $more_link = "
$more_str
"; + $more_link = "
  • $more_str
  • "; } else { $more_link = ''; } -$body = "
    " . elgg_view_title($type_str) . "
    "; - -foreach ($entities as $entity) { - if ($view = search_get_search_view($vars['params'], 'entity')) { +// @todo once elgg_view_title() supports passing a $vars array use it +$body = elgg_view('layout/elements/title', array( + 'title' => $type_str, + 'class' => 'search-heading-category', +)); + +$view = search_get_search_view($vars['params'], 'entity'); +if ($view) { + $body .= ''; } + echo $body; -echo $more_link; echo $nav; -- cgit v1.2.3