From 4afa14cc8d3f26f841c92b083355004251d75087 Mon Sep 17 00:00:00 2001 From: rvelices Date: Fri, 12 Oct 2007 03:27:34 +0000 Subject: - fix plugin menu link broken with xamp (realpath behaves differently) - complete quick search rewriting - now we can quote phrases as in google "New York" is not the same as New York - user comments not searched anymore (faster) - the big full text query does not use joins anymore (faster) - related tags not shown on the index page, but now you can see the matching tags and matching categories git-svn-id: http://piwigo.org/svn/trunk@2135 68402e56-0260-453c-a942-63ccdbb3a9ee --- index.php | 87 ++++++++++++++++++++++++++++++++++++--------------------------- 1 file changed, 50 insertions(+), 37 deletions(-) (limited to 'index.php') diff --git a/index.php b/index.php index ab21a7e5a..49125e8ac 100644 --- a/index.php +++ b/index.php @@ -103,6 +103,7 @@ if ( count($page['items']) > 0) { $template_title.= ' ['.count($page['items']).']'; } +$template->assign_var('TITLE', $template_title); if (isset($page['flat']) or isset($page['chronology_field'])) { @@ -169,12 +170,6 @@ else // include menubar include(PHPWG_ROOT_PATH.'include/menubar.inc.php'); -$template->assign_vars( - array( - 'TITLE' => $template_title - ) - ); - if ('search' == $page['section']) { $template->assign_block_vars( @@ -199,42 +194,61 @@ if (isset($page['category']) and is_admin()) if (is_admin() and !empty($page['items']) ) { - $template->assign_block_vars( - 'caddie', - array( - 'URL' => - add_url_params(duplicate_index_url(), array('caddie'=>1) ) - ) - ); - } + $template->assign_block_vars( + 'caddie', + array( + 'URL' => + add_url_params(duplicate_index_url(), array('caddie'=>1) ) + ) + ); +} -if ( $page['section']=='search' and $page['start']==0 ) +if ( $page['section']=='search' and $page['start']==0 and + !isset($page['chronology_field']) and isset($page['qsearch_details']) ) { - $tags = get_common_tags($page['items'], - $conf['content_tag_cloud_items_number'], null); - if ( count($tags)>1 ) - { - $template->assign_block_vars('related_tags', array() ); + $template->assign_var('QUERY_SEARCH', + htmlspecialchars($page['qsearch_details']['q']) ); - $tags = add_level_to_tags($tags); - foreach ($tags as $tag) + $found_cat_ids = array_merge( + (array)@$page['qsearch_details']['matching_cats_no_images'], + (array)@$page['qsearch_details']['matching_cats'] ); + if (count($found_cat_ids)) + { + $hints = array(); + $query = ' +SELECT id, name, permalink FROM '.CATEGORIES_TABLE.' + WHERE id IN ('.implode(',', $found_cat_ids).') + ORDER BY name + LIMIT 10'; + $result = pwg_query($query); + while ( $row = mysql_fetch_assoc($result) ) { - $template->assign_block_vars( - 'related_tags.tag', array( - 'URL' => make_index_url( - array( - 'tags' => array($tag) - ) - ), - 'NAME' => $tag['name'], - 'TITLE' => l10n_dec( - '%d picture are also linked to current tags', - '%d pictures are also linked to current tags', - $tag['counter']), - 'CLASS' => 'tagLevel'.$tag['level'] - ) + $hints[] = get_cat_display_name( array($row) ); + } + $template->assign_block_vars( 'category_search_results', + array( + 'CONTENT' => implode(' — ', $hints) + ) ); + } + + $tags = find_tags( (array)@$page['qsearch_details']['matching_tags'] ); + if (count($tags)) + { + usort($tags, 'name_compare'); + $hints = array(); + foreach ( $tags as $tag ) + { + $hints[] = + '' + .$tag['name'] + .''; } + $template->assign_block_vars( 'tag_search_results', + array( + 'CONTENT' => implode(' — ', $hints) + ) + ); } } @@ -299,7 +313,6 @@ if (isset($page['comment']) and $page['comment'] != '') 'COMMENTS' => $page['comment'] ) ); - $header_infos['COMMENT'] = strip_tags($page['comment']); } //------------------------------------------------------------ log informations pwg_log(); -- cgit v1.2.3