Changeset 2138


Ignore:
Timestamp:
Oct 16, 2007, 3:46:09 AM (17 years ago)
Author:
rvelices
Message:
  • quick search optimizations (less queries)
  • added some meta_robots (noindex and nofollow) on popuphelp, search_rules and search seaction (googlebot gets crazy)
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_search.inc.php

    r2135 r2138  
    363363 * 'as_is' => 1 (indicates the caller that items are ordered and permissions checked
    364364 * 'qs'    => array(
    365  *    'matching_tags' => array(85,86) - matching tags
    366  *    'matching_cats' => array(1,2,3) - matching categories
     365 *    'matching_tags' => array of matching tags
     366 *    'matching_cats' => array of matching categories
    367367 *    'matching_cats_no_images' =>array(99) - matching categories without images
    368368 *      ))
     
    432432  { // search name and url name (without accents)
    433433    $query = '
    434 SELECT id
     434SELECT id, name, url_name
    435435  FROM '.TAGS_TABLE.'
    436436  WHERE ('.str_replace($q_like_field, 'CONVERT(name, CHAR)', $q_like_clause).'
    437437    OR '.str_replace($q_like_field, 'url_name', $q_like_clause).')';
    438     $tag_ids = array_from_query( $query, 'id');
    439     if (!empty($tag_ids))
     438    $tags = hash_from_query($query, 'id');
     439    if ( !empty($tags) )
    440440    { // we got some tags; get the images
    441       $search_results['qs']['matching_tags']=$tag_ids;
     441      $search_results['qs']['matching_tags']=$tags;
    442442      $query = '
    443443SELECT image_id, COUNT(tag_id) AS weight
    444444  FROM '.IMAGE_TAG_TABLE.'
    445   WHERE tag_id IN ('.implode(',',$tag_ids).')
     445  WHERE tag_id IN ('.implode(',',array_keys($tags)).')
    446446  GROUP BY image_id';
    447447      $result = pwg_query($query);
     
    458458  global $user;
    459459  $query = '
    460 SELECT id, nb_images
     460SELECT id, name, permalink, nb_images
    461461  FROM '.CATEGORIES_TABLE.'
    462462    INNER JOIN '.USER_CACHE_CATEGORIES_TABLE.' ON id=cat_id
     
    471471    if ($row['nb_images']==0)
    472472    {
    473       $search_results['qs']['matching_cats_no_images'][] = $row['id'];
     473      $search_results['qs']['matching_cats_no_images'][] = $row;
    474474    }
    475475    else
    476476    {
    477       $search_results['qs']['matching_cats'][] = $row['id'];
     477      $search_results['qs']['matching_cats'][$row['id']] = $row;
    478478    }
    479479  }
     
    495495  {
    496496    $where_clauses[]='category_id IN ('.
    497       implode(',',$search_results['qs']['matching_cats']).')';
     497      implode(',',array_keys($search_results['qs']['matching_cats'])).')';
    498498  }
    499499  $where_clauses = array( '('.implode("\n    OR ",$where_clauses).')' );
  • trunk/include/section_init.inc.php

    r2135 r2138  
    539539elseif ('recent_cats'==$page['section'])
    540540{
     541  $page['meta_robots']['noindex']=1;
     542}
     543elseif ('search'==$page['section'])
     544{
    541545  $page['meta_robots']['nofollow']=1;
    542546}
  • trunk/index.php

    r2135 r2138  
    210210    htmlspecialchars($page['qsearch_details']['q']) );
    211211
    212   $found_cat_ids = array_merge(
     212  $cats = array_merge(
    213213      (array)@$page['qsearch_details']['matching_cats_no_images'],
    214214      (array)@$page['qsearch_details']['matching_cats'] );
    215   if (count($found_cat_ids))
    216   {
     215  if (count($cats))
     216  {
     217    usort($cats, 'name_compare');
    217218    $hints = array();
    218     $query = '
    219 SELECT id, name, permalink FROM '.CATEGORIES_TABLE.'
    220   WHERE id IN ('.implode(',', $found_cat_ids).')
    221   ORDER BY name
    222   LIMIT 10';
    223     $result = pwg_query($query);
    224     while ( $row = mysql_fetch_assoc($result) )
     219    foreach ( $cats as $cat )
    225220    {
    226       $hints[] = get_cat_display_name( array($row) );
     221      $hints[] = get_cat_display_name( array($cat) );
    227222    }
    228223    $template->assign_block_vars( 'category_search_results',
     
    233228  }
    234229
    235   $tags = find_tags( (array)@$page['qsearch_details']['matching_tags'] );
     230  $tags = (array)@$page['qsearch_details']['matching_tags'];
    236231  if (count($tags))
    237232  {
  • trunk/popuphelp.php

    r2126 r2138  
    33// | PhpWebGallery - a PHP based picture gallery                           |
    44// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
    5 // | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
     5// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
    66// +-----------------------------------------------------------------------+
    7 // | branch        : BSF (Best So Far)
    8 // | file          : $RCSfile$
     7// | file          : $Id$
    98// | last update   : $Date$
    109// | last modifier : $Author$
     
    4140$title = l10n('PhpWebGallery Help');
    4241$page['page_banner'] = '<h1>'.$title.'</h1>';
     42$page['meta_robots']=array('noindex'=>1, 'nofollow'=>1);
    4343include(PHPWG_ROOT_PATH.'include/page_header.php');
    4444
  • trunk/search_rules.php

    r1900 r2138  
    33// | PhpWebGallery - a PHP based picture gallery                           |
    44// | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net |
    5 // | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net |
    6 // +-----------------------------------------------------------------------+
    7 // | branch        : BSF (Best So Far)
     5// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
     6// +-----------------------------------------------------------------------+
    87// | file          : $Id$
    98// | last update   : $Date$
     
    5049$title = l10n('PhpWebGallery Help');
    5150$page['page_banner'] = '<h1>'.$title.'</h1>';
     51$page['meta_robots']=array('noindex'=>1, 'nofollow'=>1);
    5252include(PHPWG_ROOT_PATH.'include/page_header.php');
    5353
Note: See TracChangeset for help on using the changeset viewer.