aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-07 02:38:51 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-07 02:38:51 +0000
commitccca9564b23d6f860d46ccdb86a7578e74b7a534 (patch)
tree72fbe19572d8006a0babb8782cd514bb8d05a731
parentcb5ecaff25b858117a57ede78f353661a520c9d4 (diff)
downloadelgg-ccca9564b23d6f860d46ccdb86a7578e74b7a534.tar.gz
elgg-ccca9564b23d6f860d46ccdb86a7578e74b7a534.tar.bz2
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
-rw-r--r--mod/search/index.php24
-rw-r--r--mod/search/start.php20
-rw-r--r--mod/search/views/default/search/comments/entity.php12
-rw-r--r--mod/search/views/default/search/entity.php23
-rw-r--r--mod/search/views/default/search/entity_list.php64
-rw-r--r--mod/search/views/default/search/gallery.php53
-rw-r--r--mod/search/views/default/search/gallery_listing.php14
-rw-r--r--mod/search/views/default/search/layout.php9
-rw-r--r--mod/search/views/default/search/listing.php20
-rw-r--r--mod/search/views/default/search/search_box.php7
-rw-r--r--mod/search/views/default/search/startblurb.php3
-rw-r--r--mod/search/views/rss/search/comments/entity.php6
-rw-r--r--mod/search/views/rss/search/entity.php4
-rw-r--r--mod/search/views/rss/search/layout.php5
-rw-r--r--mod/search/views/rss/search/listing.php7
15 files changed, 79 insertions, 192 deletions
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 @@
<?php
/**
- * Elgg core search.
+ * Elgg search page
*
- * @package Elgg
- * @subpackage Core
+ * @todo much of this code should be pulled out into a library of functions
*/
// Search supports RSS
@@ -76,7 +75,7 @@ $data = htmlspecialchars(http_build_query(array(
'search_type' => '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 @@
<?php
/**
- * Elgg core search.
+ * Elgg search plugin
*
- * @package Elgg
- * @subpackage Core
*/
+elgg_register_event_handler('init','system','search_init');
+
/**
- * Initialise search helper functions.
- *
+ * Initialize search plugin
*/
function search_init() {
global $CONFIG;
@@ -20,8 +19,6 @@ function search_init() {
// register some default search hooks
elgg_register_plugin_hook_handler('search', 'object', 'search_objects_hook');
elgg_register_plugin_hook_handler('search', 'user', 'search_users_hook');
-
- // @todo pull this out into groups
elgg_register_plugin_hook_handler('search', 'group', 'search_groups_hook');
// tags and comments are a bit different.
@@ -223,7 +220,7 @@ function search_consolidate_substrings($offsets, $lengths) {
$end_pos = $offset + $length;
// find the next entry that doesn't overlap
- while(array_key_exists($i+1, $offsets) && $end_pos > $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 @@
<?php
/**
- * Elgg search entity
+ * Default view for a comment
*
- * @package Elgg
- * @subpackage Core
+ * @uses $vars['entity']
*/
+
$entity = $vars['entity'];
$owner = get_entity($entity->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 = "<a href=\"$url\">$title</a>";
}
@@ -54,4 +56,4 @@ echo <<<___END
</div>
___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 @@
<?php
/**
- * Elgg search entity
+ * 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)
@@ -10,8 +10,7 @@
* - search_url (defaults to entity->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);
}
?>
- <div class="search_listing clearfix">
- <div class="search_listing_icon"><?php echo $icon; ?></div>
- <div class="search_listing_info">
- <p class="entity-title"><?php echo $title; ?></p>
- <?php echo $description; ?>
+<div class="search_listing clearfix">
+ <div class="search_listing_icon">
+ <?php echo $icon; ?>
+ </div>
+ <div class="search_listing_info">
+ <p class="entity-title"><?php echo $title; ?></p>
+ <?php echo $description; ?>
<?php
if ($extra_info) {
?>
- <p class="entity-subtext"><?php echo $extra_info; ?></p>
+ <p class="entity-subtext"><?php echo $extra_info; ?></p>
<?php
}
?>
- <p class="entity-subtext"><?php echo $time; ?></p>
- </div>
+ <p class="entity-subtext"><?php echo $time; ?></p>
</div>
+</div>
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 @@
-<?php
-$context = $vars['context'];
-$offset = $vars['offset'];
-$entities = $vars['entities'];
-$limit = $vars['limit'];
-$count = $vars['count'];
-$baseurl = $vars['baseurl'];
-$context = $vars['context'];
-$listtype = $vars['listtype'];
-$pagination = $vars['pagination'];
-$fullview = $vars['fullview'];
-
-$html = "";
-$nav = "";
-if (isset($vars['listtypetoggle'])) {
- $listtypetoggle = $vars['listtypetoggle'];
-} else {
- $listtypetoggle = true;
-}
-
-if ($context == "search" && $count > 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 @@
-<?php
-
- /**
- * Elgg gallery view
- *
- * @package Elgg
- * @subpackage Core
-
-
- */
-
- $entities = $vars['entities'];
- if (is_array($entities) && sizeof($entities) > 0) {
-
-?>
-
- <table class="entity_gallery">
-
-<?php
-
- $col = 0;
- foreach($entities as $entity) {
- if ($col == 0) {
-
- echo "<tr>";
-
- }
- echo "<td class='entity_gallery_item'>";
-
- $ev = elgg_view_entity($entity, $fullview);
-
- echo elgg_view('search/listing', array('entity_view' => $ev,
- 'search_types' => $entity->getVolatileData('search')));
-
-
- echo "</td>";
- $col++;
- if ($col > 3) {
- echo "</tr>";
- $col = 0;
- }
- }
- if ($col > 0) echo "</tr>";
-
-?>
-
- </table>
-
-<?php
-
- }
-
-?> \ 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 @@
-<?php
-/**
- * Elgg search listing: gallery view
- *
- * DEPRECATED VIEW: use entities/gallery_listing instead
- *
- * @package Elgg
- * @subpackage Core
- */
-
-
- echo elgg_view('entities/gallery_listing', $vars);
-
-?> \ 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 @@
<?php
/**
- * Elgg core search listing.
- *
- * @package Elgg
- * @subpackage Core
- */
+ * 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/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 @@
<?php
/**
- * Elgg search listing
+ * List a section of search results corresponding in a particular type/subtype
+ * or search type (comments for example)
*
- * @package Elgg
- * @subpackage Core
+ * @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'
+ * - 'limit'
+ * - 'pagination' Display pagination?
*/
$entities = $vars['results']['entities'];
@@ -13,6 +22,7 @@ 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'],
@@ -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 = "<div class='search_listing_category_title'>".elgg_view_title($type_str)."</div>";
+$body = "<div class='search_listing_category_title'>" . elgg_view_title($type_str) . "</div>";
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 @@
<?php
+/**
+ * Search box
+ *
+ * @uses $vars['value'] Current search query
+ *
+ * @todo Move javascript into something that extends elgg.js
+ */
if (array_key_exists('value', $vars)) {
$value = $vars['value'];
diff --git a/mod/search/views/default/search/startblurb.php b/mod/search/views/default/search/startblurb.php
index 3ffa39e68..d6394da0d 100644
--- a/mod/search/views/default/search/startblurb.php
+++ b/mod/search/views/default/search/startblurb.php
@@ -1,7 +1,6 @@
<?php
/**
- * @package Elgg
- * @subpackage Core
+ * @todo This doesn't appear to be called by anything. Look into removing.
*/
echo elgg_echo("tag:search:startblurb", array($vars['query']));
diff --git a/mod/search/views/rss/search/comments/entity.php b/mod/search/views/rss/search/comments/entity.php
index 46ef87a14..869779f35 100644
--- a/mod/search/views/rss/search/comments/entity.php
+++ b/mod/search/views/rss/search/comments/entity.php
@@ -1,10 +1,10 @@
<?php
/**
- * Elgg search comment view
+ * Search comment view for RSS feeds.
*
- * @package Elgg
- * @subpackage Core
+ * @uses $vars['entity']
*/
+
$entity = $vars['entity'];
$author_name = '';
diff --git a/mod/search/views/rss/search/entity.php b/mod/search/views/rss/search/entity.php
index 54f241982..10d28e8e1 100644
--- a/mod/search/views/rss/search/entity.php
+++ b/mod/search/views/rss/search/entity.php
@@ -1,10 +1,8 @@
<?php
/**
- * Elgg core search.
* Search entity view for RSS feeds.
*
- * @package Elgg
- * @subpackage Core
+ * @uses $vars['entity']
*/
if (!array_key_exists('entity', $vars) || !($vars['entity'] instanceof ElggEntity)) {
diff --git a/mod/search/views/rss/search/layout.php b/mod/search/views/rss/search/layout.php
index d722ccaeb..2c255a9cc 100644
--- a/mod/search/views/rss/search/layout.php
+++ b/mod/search/views/rss/search/layout.php
@@ -1,5 +1,6 @@
<?php
+/**
+ * Search layout for RSS
+ */
echo $vars['body'];
-
-?> \ 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 @@
<?php
/**
- * Elgg core search.
- * Search listing view for RSS feeds.
+ * List a section of search results for RSS feeds.
*
- * @package Elgg
- * @subpackage Core
+ * @uses $vars['results']
+ * @uses $vars['params']
*/
$entities = $vars['results']['entities'];