- 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
This commit is contained in:
parent
608c174245
commit
b606b6d1ab
5 changed files with 26 additions and 27 deletions
|
@ -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))
|
||||
|
|
|
@ -537,6 +537,10 @@ elseif ('tags' == $page['section'])
|
|||
}
|
||||
}
|
||||
elseif ('recent_cats'==$page['section'])
|
||||
{
|
||||
$page['meta_robots']['noindex']=1;
|
||||
}
|
||||
elseif ('search'==$page['section'])
|
||||
{
|
||||
$page['meta_robots']['nofollow']=1;
|
||||
}
|
||||
|
|
17
index.php
17
index.php
|
@ -209,21 +209,16 @@ if ( $page['section']=='search' and $page['start']==0 and
|
|||
$template->assign_var('QUERY_SEARCH',
|
||||
htmlspecialchars($page['qsearch_details']['q']) );
|
||||
|
||||
$found_cat_ids = array_merge(
|
||||
$cats = array_merge(
|
||||
(array)@$page['qsearch_details']['matching_cats_no_images'],
|
||||
(array)@$page['qsearch_details']['matching_cats'] );
|
||||
if (count($found_cat_ids))
|
||||
if (count($cats))
|
||||
{
|
||||
usort($cats, 'name_compare');
|
||||
$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) )
|
||||
foreach ( $cats as $cat )
|
||||
{
|
||||
$hints[] = get_cat_display_name( array($row) );
|
||||
$hints[] = get_cat_display_name( array($cat) );
|
||||
}
|
||||
$template->assign_block_vars( 'category_search_results',
|
||||
array(
|
||||
|
@ -232,7 +227,7 @@ SELECT id, name, permalink FROM '.CATEGORIES_TABLE.'
|
|||
);
|
||||
}
|
||||
|
||||
$tags = find_tags( (array)@$page['qsearch_details']['matching_tags'] );
|
||||
$tags = (array)@$page['qsearch_details']['matching_tags'];
|
||||
if (count($tags))
|
||||
{
|
||||
usort($tags, 'name_compare');
|
||||
|
|
|
@ -2,10 +2,9 @@
|
|||
// +-----------------------------------------------------------------------+
|
||||
// | PhpWebGallery - a PHP based picture gallery |
|
||||
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | branch : BSF (Best So Far)
|
||||
// | file : $RCSfile$
|
||||
// | file : $Id$
|
||||
// | last update : $Date$
|
||||
// | last modifier : $Author$
|
||||
// | revision : $Revision$
|
||||
|
@ -40,6 +39,7 @@ check_status(ACCESS_GUEST);
|
|||
$page['body_id'] = 'thePopuphelpPage';
|
||||
$title = l10n('PhpWebGallery Help');
|
||||
$page['page_banner'] = '<h1>'.$title.'</h1>';
|
||||
$page['meta_robots']=array('noindex'=>1, 'nofollow'=>1);
|
||||
include(PHPWG_ROOT_PATH.'include/page_header.php');
|
||||
|
||||
if
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
// +-----------------------------------------------------------------------+
|
||||
// | PhpWebGallery - a PHP based picture gallery |
|
||||
// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
|
||||
// +-----------------------------------------------------------------------+
|
||||
// | branch : BSF (Best So Far)
|
||||
// | file : $Id$
|
||||
// | last update : $Date$
|
||||
// | last modifier : $Author$
|
||||
|
@ -49,6 +48,7 @@ include_once( PHPWG_ROOT_PATH.'include/functions_search.inc.php' );
|
|||
$page['body_id'] = 'thePopuphelpPage';
|
||||
$title = l10n('PhpWebGallery Help');
|
||||
$page['page_banner'] = '<h1>'.$title.'</h1>';
|
||||
$page['meta_robots']=array('noindex'=>1, 'nofollow'=>1);
|
||||
include(PHPWG_ROOT_PATH.'include/page_header.php');
|
||||
|
||||
$template->set_filenames(array('search_rules' => 'search_rules.tpl'));
|
||||
|
|
Loading…
Reference in a new issue