From b606b6d1ab4a484fae1922a574540c4bf6753be2 Mon Sep 17 00:00:00 2001 From: rvelices Date: Tue, 16 Oct 2007 01:46:09 +0000 Subject: - quick search optimizations (less queries) - added some meta_robots (noindex and nofollow) on popuphelp, search_rules and search seaction (googlebot gets crazy) git-svn-id: http://piwigo.org/svn/trunk@2138 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions_search.inc.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'include/functions_search.inc.php') diff --git a/include/functions_search.inc.php b/include/functions_search.inc.php index c34d31463..3d7d768a7 100644 --- a/include/functions_search.inc.php +++ b/include/functions_search.inc.php @@ -362,8 +362,8 @@ function get_qsearch_like_clause($q, $field) * 'items' => array(85,68,79...) * 'as_is' => 1 (indicates the caller that items are ordered and permissions checked * 'qs' => array( - * 'matching_tags' => array(85,86) - matching tags - * 'matching_cats' => array(1,2,3) - matching categories + * 'matching_tags' => array of matching tags + * 'matching_cats' => array of matching categories * 'matching_cats_no_images' =>array(99) - matching categories without images * )) * @@ -431,18 +431,18 @@ SELECT i.id, if (!empty($q_like_clause)) { // search name and url name (without accents) $query = ' -SELECT id +SELECT id, name, url_name FROM '.TAGS_TABLE.' WHERE ('.str_replace($q_like_field, 'CONVERT(name, CHAR)', $q_like_clause).' OR '.str_replace($q_like_field, 'url_name', $q_like_clause).')'; - $tag_ids = array_from_query( $query, 'id'); - if (!empty($tag_ids)) + $tags = hash_from_query($query, 'id'); + if ( !empty($tags) ) { // we got some tags; get the images - $search_results['qs']['matching_tags']=$tag_ids; + $search_results['qs']['matching_tags']=$tags; $query = ' SELECT image_id, COUNT(tag_id) AS weight FROM '.IMAGE_TAG_TABLE.' - WHERE tag_id IN ('.implode(',',$tag_ids).') + WHERE tag_id IN ('.implode(',',array_keys($tags)).') GROUP BY image_id'; $result = pwg_query($query); while ($row = mysql_fetch_assoc($result)) @@ -457,7 +457,7 @@ SELECT image_id, COUNT(tag_id) AS weight // Step 3 - search categories corresponding to the query $q ================== global $user; $query = ' -SELECT id, nb_images +SELECT id, name, permalink, nb_images FROM '.CATEGORIES_TABLE.' INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' ON id=cat_id WHERE user_id='.$user['id'].' @@ -470,11 +470,11 @@ SELECT id, nb_images { // weight is important when sorting images by relevance if ($row['nb_images']==0) { - $search_results['qs']['matching_cats_no_images'][] = $row['id']; + $search_results['qs']['matching_cats_no_images'][] = $row; } else { - $search_results['qs']['matching_cats'][] = $row['id']; + $search_results['qs']['matching_cats'][$row['id']] = $row; } } @@ -494,7 +494,7 @@ SELECT id, nb_images if ( !empty($search_results['qs']['matching_cats']) ) { $where_clauses[]='category_id IN ('. - implode(',',$search_results['qs']['matching_cats']).')'; + implode(',',array_keys($search_results['qs']['matching_cats'])).')'; } $where_clauses = array( '('.implode("\n OR ",$where_clauses).')' ); if (!empty($images_where)) -- cgit v1.2.3