From ccca9564b23d6f860d46ccdb86a7578e74b7a534 Mon Sep 17 00:00:00 2001 From: cash Date: Mon, 7 Feb 2011 02:38:51 +0000 Subject: Fixes #2335 #2336 clean up and minor standardization of search plugin - needs html/css clean up git-svn-id: http://code.elgg.org/elgg/trunk@8057 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/search/index.php | 24 +++++--- mod/search/start.php | 20 +++---- .../views/default/search/comments/entity.php | 12 ++-- mod/search/views/default/search/entity.php | 23 ++++---- mod/search/views/default/search/entity_list.php | 64 ---------------------- mod/search/views/default/search/gallery.php | 53 ------------------ .../views/default/search/gallery_listing.php | 14 ----- mod/search/views/default/search/layout.php | 9 ++- mod/search/views/default/search/listing.php | 20 +++++-- mod/search/views/default/search/search_box.php | 7 +++ mod/search/views/default/search/startblurb.php | 3 +- mod/search/views/rss/search/comments/entity.php | 6 +- mod/search/views/rss/search/entity.php | 4 +- mod/search/views/rss/search/layout.php | 5 +- mod/search/views/rss/search/listing.php | 7 +-- 15 files changed, 79 insertions(+), 192 deletions(-) delete mode 100644 mod/search/views/default/search/entity_list.php delete mode 100644 mod/search/views/default/search/gallery.php delete mode 100644 mod/search/views/default/search/gallery_listing.php diff --git a/mod/search/index.php b/mod/search/index.php index 8662283e4..db2aa5cc2 100644 --- a/mod/search/index.php +++ b/mod/search/index.php @@ -1,9 +1,8 @@ 'all', //'friends' => $friends ))); -$url = elgg_get_site_url()."pg/search/?$data"; +$url = elgg_get_site_url() . "pg/search/?$data"; $menu_item = new ElggMenuItem('all', elgg_echo('all'), $url); elgg_register_menu_item('page', $menu_item); @@ -110,7 +109,7 @@ foreach ($types as $type => $subtypes) { 'friends' => $friends ))); - $url = elgg_get_site_url()."pg/search/?$data"; + $url = elgg_get_site_url() . "pg/search/?$data"; $menu_item = new ElggMenuItem($label, elgg_echo($label), $url); elgg_register_menu_item('page', $menu_item); @@ -189,7 +188,10 @@ if ($search_type == 'all' || $search_type == 'entities') { if (is_array($results['entities']) && $results['count']) { if ($view = search_get_search_view($current_params, 'listing')) { - $results_html .= elgg_view($view, array('results' => $results, 'params' => $current_params)); + $results_html .= elgg_view($view, array( + 'results' => $results, + 'params' => $current_params, + )); } } } @@ -207,7 +209,10 @@ if ($search_type == 'all' || $search_type == 'entities') { if (is_array($results['entities']) && $results['count']) { if ($view = search_get_search_view($current_params, 'listing')) { - $results_html .= elgg_view($view, array('results' => $results, 'params' => $current_params)); + $results_html .= elgg_view($view, array( + 'results' => $results, + 'params' => $current_params, + )); } } } @@ -235,7 +240,10 @@ if ($search_type != 'entities' || $search_type == 'all') { if (is_array($results['entities']) && $results['count']) { if ($view = search_get_search_view($current_params, 'listing')) { - $results_html .= elgg_view($view, array('results' => $results, 'params' => $current_params)); + $results_html .= elgg_view($view, array( + 'results' => $results, + 'params' => $current_params, + )); } } } diff --git a/mod/search/start.php b/mod/search/start.php index ac61963d4..71473632c 100644 --- a/mod/search/start.php +++ b/mod/search/start.php @@ -1,14 +1,13 @@ $offsets[$i+1]) { + while (array_key_exists($i+1, $offsets) && $end_pos > $offsets[$i+1]) { $i++; if (!array_key_exists($i, $offsets)) { break; @@ -329,7 +326,7 @@ function search_remove_ignored_words($query, $format = 'array') { * * @param array $results * @param array $params - * @param string $view_type = listing, entity or listing + * @param string $view_type = listing, entity or layout * @return string */ function search_get_search_view($params, $view_type) { @@ -456,7 +453,7 @@ function search_get_order_by_sql($entities_table, $type_table, $sort, $order) { default: case 'relevance': // default is relevance descending. - // acending relevancy is silly and complicated. + // ascending relevancy is silly and complicated. $on = ''; break; case 'created': @@ -488,6 +485,3 @@ function search_get_order_by_sql($entities_table, $type_table, $sort, $order) { return $order_by; } -/** Register init system event **/ - -elgg_register_event_handler('init','system','search_init'); diff --git a/mod/search/views/default/search/comments/entity.php b/mod/search/views/default/search/comments/entity.php index 6e267fe7a..eddb36547 100644 --- a/mod/search/views/default/search/comments/entity.php +++ b/mod/search/views/default/search/comments/entity.php @@ -1,16 +1,16 @@ getVolatileData('search_matched_comment_owner_guid')); if ($owner instanceof ElggUser) { - $icon = elgg_view('profile/icon', array('entity' => $owner, 'size' => 'tiny')); + $icon = elgg_view_entity_icon($owner, 'tiny'); } else { $icon = ''; } @@ -36,6 +36,8 @@ if ($entity->getVolatileData('search_unavailable_entity')) { } $title = elgg_echo('search:comment_on', array($title)); + + // @todo this should use something like $comment->getURL() $url = $entity->getURL() . '#comment_' . $entity->getVolatileData('search_match_annotation_id'); $title = "$title"; } @@ -54,4 +56,4 @@ echo <<<___END ___END; -?> +?> \ 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 a967853a3..ae3d43e01 100644 --- a/mod/search/views/default/search/entity.php +++ b/mod/search/views/default/search/entity.php @@ -1,6 +1,6 @@ getURL()) * - search_time (defaults to entity->time_updated or entity->time_created) * - * @package Elgg - * @subpackage Core + * @uses $vars['entity'] Entity returned in a search */ $entity = $vars['entity']; @@ -49,18 +48,20 @@ if (!$time) { $time = elgg_view_friendly_time(($tu > $tc) ? $tu : $tc); } ?> -
-
-
-

- +
+
+ +
+
+

+ -

+

-

-
+

+
diff --git a/mod/search/views/default/search/entity_list.php b/mod/search/views/default/search/entity_list.php deleted file mode 100644 index f9105c711..000000000 --- a/mod/search/views/default/search/entity_list.php +++ /dev/null @@ -1,64 +0,0 @@ - 0 && $listtypetoggle) { - $nav .= elgg_view("navigation/listtype",array( - - 'baseurl' => $baseurl, - 'offset' => $offset, - 'count' => $count, - 'listtype' => $listtype, - - )); -} - -if ($pagination) - $nav .= elgg_view('navigation/pagination',array( - - 'baseurl' => $baseurl, - 'offset' => $offset, - 'count' => $count, - 'limit' => $limit, - - )); - -if ($listtype == "list") { - if (is_array($entities) && sizeof($entities) > 0) { - foreach($entities as $entity) { - // print out the entity - $ev = elgg_view_entity($entity, $fullview); - // then add the search decorations around it - $html .= elgg_view('search/listing', array('entity_view' => $ev, - 'search_types' => $entity->getVolatileData('search'))); - - } - } -} else if ($listtype == "gallery") { - if (is_array($entities) && sizeof($entities) > 0) { - $html .= elgg_view("search/gallery",array('entities' => $entities)); - } -} - -if ($count) { - $html .= $nav; -} -echo $html; - -?> diff --git a/mod/search/views/default/search/gallery.php b/mod/search/views/default/search/gallery.php deleted file mode 100644 index e2c6875e0..000000000 --- a/mod/search/views/default/search/gallery.php +++ /dev/null @@ -1,53 +0,0 @@ - 0) { - -?> - - - -"; - - } - echo ""; - $col++; - if ($col > 3) { - echo ""; - $col = 0; - } - } - if ($col > 0) echo ""; - -?> - - - - \ No newline at end of file diff --git a/mod/search/views/default/search/gallery_listing.php b/mod/search/views/default/search/gallery_listing.php deleted file mode 100644 index e4b723242..000000000 --- a/mod/search/views/default/search/gallery_listing.php +++ /dev/null @@ -1,14 +0,0 @@ - \ No newline at end of file diff --git a/mod/search/views/default/search/layout.php b/mod/search/views/default/search/layout.php index 6882f252d..eb597836e 100644 --- a/mod/search/views/default/search/layout.php +++ b/mod/search/views/default/search/layout.php @@ -1,9 +1,8 @@ $vars['body'])); \ No newline at end of file diff --git a/mod/search/views/default/search/listing.php b/mod/search/views/default/search/listing.php index d84d567d4..27916a363 100644 --- a/mod/search/views/default/search/listing.php +++ b/mod/search/views/default/search/listing.php @@ -1,9 +1,18 @@ $vars['params']['query'], @@ -25,7 +35,7 @@ $query = http_build_query( ) ); -$url = elgg_get_site_url()."pg/search?$query"; +$url = elgg_get_site_url() . "pg/search?$query"; // get pagination if (array_key_exists('pagination', $vars) && $vars['pagination']) { @@ -90,7 +100,7 @@ if ($more) { $more_link = ''; } -$body = "
".elgg_view_title($type_str)."
"; +$body = "
" . elgg_view_title($type_str) . "
"; foreach ($entities as $entity) { if ($view = search_get_search_view($vars['params'], 'entity')) { diff --git a/mod/search/views/default/search/search_box.php b/mod/search/views/default/search/search_box.php index 1a02a9861..9de861179 100644 --- a/mod/search/views/default/search/search_box.php +++ b/mod/search/views/default/search/search_box.php @@ -1,4 +1,11 @@ \ No newline at end of file diff --git a/mod/search/views/rss/search/listing.php b/mod/search/views/rss/search/listing.php index 92f6553b9..32082fd31 100644 --- a/mod/search/views/rss/search/listing.php +++ b/mod/search/views/rss/search/listing.php @@ -1,10 +1,9 @@