Changeset 2135 for trunk/index.php


Ignore:
Timestamp:
Oct 12, 2007, 5:27:34 AM (17 years ago)
Author:
rvelices
Message:
  • 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
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/index.php

    r2117 r2135  
    104104  $template_title.= ' ['.count($page['items']).']';
    105105}
     106$template->assign_var('TITLE', $template_title);
    106107
    107108if (isset($page['flat']) or isset($page['chronology_field']))
     
    170171include(PHPWG_ROOT_PATH.'include/menubar.inc.php');
    171172
    172 $template->assign_vars(
    173   array(
    174     'TITLE' => $template_title
    175     )
    176   );
    177 
    178173if ('search' == $page['section'])
    179174{
     
    200195if (is_admin() and !empty($page['items']) )
    201196{
    202     $template->assign_block_vars(
    203       'caddie',
    204       array(
    205         'URL' =>
    206           add_url_params(duplicate_index_url(), array('caddie'=>1) )
    207         )
     197  $template->assign_block_vars(
     198    'caddie',
     199    array(
     200      'URL' =>
     201         add_url_params(duplicate_index_url(), array('caddie'=>1) )
     202      )
     203    );
     204}
     205
     206if ( $page['section']=='search' and $page['start']==0 and
     207    !isset($page['chronology_field']) and isset($page['qsearch_details']) )
     208{
     209  $template->assign_var('QUERY_SEARCH',
     210    htmlspecialchars($page['qsearch_details']['q']) );
     211
     212  $found_cat_ids = array_merge(
     213      (array)@$page['qsearch_details']['matching_cats_no_images'],
     214      (array)@$page['qsearch_details']['matching_cats'] );
     215  if (count($found_cat_ids))
     216  {
     217    $hints = array();
     218    $query = '
     219SELECT 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) )
     225    {
     226      $hints[] = get_cat_display_name( array($row) );
     227    }
     228    $template->assign_block_vars( 'category_search_results',
     229        array(
     230            'CONTENT' => implode(' — ', $hints)
     231          )
    208232      );
    209233  }
    210234
    211 if ( $page['section']=='search' and $page['start']==0 )
    212 {
    213   $tags = get_common_tags($page['items'],
    214       $conf['content_tag_cloud_items_number'], null);
    215   if ( count($tags)>1 )
    216   {
    217     $template->assign_block_vars('related_tags', array() );
    218 
    219     $tags = add_level_to_tags($tags);
    220     foreach ($tags as $tag)
     235  $tags = find_tags( (array)@$page['qsearch_details']['matching_tags'] );
     236  if (count($tags))
     237  {
     238    usort($tags, 'name_compare');
     239    $hints = array();
     240    foreach ( $tags as $tag )
    221241    {
    222       $template->assign_block_vars(
    223       'related_tags.tag', array(
    224         'URL' => make_index_url(
    225           array(
    226             'tags' => array($tag)
    227             )
    228           ),
    229         'NAME' => $tag['name'],
    230         'TITLE' => l10n_dec(
    231             '%d picture are also linked to current tags',
    232             '%d pictures are also linked to current tags',
    233             $tag['counter']),
    234         'CLASS' => 'tagLevel'.$tag['level']
    235         )
     242      $hints[] =
     243        '<a href="' . make_index_url(array('tags'=>array($tag))) . '">'
     244        .$tag['name']
     245        .'</a>';
     246    }
     247    $template->assign_block_vars( 'tag_search_results',
     248        array(
     249            'CONTENT' => implode(' &mdash; ', $hints)
     250          )
    236251      );
    237     }
    238252  }
    239253}
     
    300314      )
    301315    );
    302   $header_infos['COMMENT'] = strip_tags($page['comment']);
    303316}
    304317//------------------------------------------------------------ log informations
Note: See TracChangeset for help on using the changeset viewer.