- Timestamp:
- Mar 23, 2014, 6:38:05 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions_search.inc.php
r27882 r27884 593 593 var $images_iids; 594 594 var $iids; 595 596 var $variants; 595 597 } 596 598 … … 599 601 //@TODO: inflections for english / french 600 602 $qsr->images_iids = array_fill(0, count($expr->tokens), array()); 603 604 $inflector = null; 605 $lang_code = substr(get_default_language(),0,2); 606 include_once(PHPWG_ROOT_PATH.'include/inflectors/'.$lang_code.'.php'); 607 $class_name = 'Inflector_'.$lang_code; 608 if (class_exists($class_name)) 609 { 610 $inflector = new $class_name; 611 } 612 601 613 $query_base = 'SELECT id from '.IMAGES_TABLE.' i WHERE '; 602 614 for ($i=0; $i<count($expr->stokens); $i++) … … 608 620 $like = str_replace( array('%','_'), array('\\%','\\_'), $like); // escape LIKE specials %_ 609 621 $clauses[] = 'CONVERT(file, CHAR) LIKE \'%'.$like.'%\''; 622 623 if ($inflector!=null && strlen($token)>2 624 && ($expr->stoken_modifiers[$i] & (QST_QUOTED|QST_WILDCARD))==0 625 && strcspn($token, '\'0123456789') == strlen($token) 626 ) 627 { 628 $variants = array_unique( array_diff( $inflector->get_variants($token), array($token) ) ); 629 $qsr->variants[$token] = $variants; 630 } 631 else 632 { 633 $variants = array(); 634 } 610 635 611 636 if (strlen($token)>3) // default minimum full text index … … 616 641 if ($expr->stoken_modifiers[$i] & QST_WILDCARD_END) 617 642 $ft .= '*'; 643 foreach ($variants as $variant) 644 { 645 $ft.=' '.$variant; 646 } 618 647 $clauses[] = 'MATCH(i.name, i.comment) AGAINST( \''.addslashes($ft).'\' IN BOOLEAN MODE)'; 619 648 } … … 622 651 foreach( array('i.name', 'i.comment') as $field) 623 652 { 624 $clauses[] = $field.' LIKE \''.$like.' %\'';653 /*$clauses[] = $field.' LIKE \''.$like.' %\''; 625 654 $clauses[] = $field.' LIKE \'% '.$like.'\''; 626 $clauses[] = $field.' LIKE \'% '.$like.' %\''; 655 $clauses[] = $field.' LIKE \'% '.$like.' %\'';*/ 656 $clauses[] = $field.' REGEXP \'[[:<:]]'.addslashes(preg_quote($token)).'[[:>:]]\''; 627 657 } 628 658 } … … 754 784 $tag_id = $token_tag_ids[$i][$j]; 755 785 $counter += $all_tags[$tag_id]['counter']; 756 if ($counter > 200 && $j>0 && $token_tag_scores[$i][0] > $token_tag_scores[$i][$j] ) 757 {// "many" images in previous tags and starting from this tag is less relevent 786 if ( $j>0 && ( 787 ($counter > 100 && $token_tag_scores[$i][0] > $token_tag_scores[$i][$j]) // "many" images in previous tags and starting from this tag is less relevant 788 || ($token_tag_scores[$i][0]==1 && $token_tag_scores[$i][$j]<0.8) 789 || ($token_tag_scores[$i][0]>0.8 && $token_tag_scores[$i][$j]<0.5) 790 )) 791 {// we remove this tag from the results, but we still leave it in all_tags list so that if we are wrong, the user chooses it 758 792 array_splice($token_tag_ids[$i], $j); 759 793 array_splice($token_tag_scores[$i], $j); … … 865 899 global $conf; 866 900 //@TODO: maybe cache for 10 minutes the result set to avoid many expensive sql calls when navigating the pictures 901 $q = trim(stripslashes($q)); 867 902 $search_results = 868 903 array( 869 904 'items' => array(), 870 'qs' => array('q'=> stripslashes($q)),905 'qs' => array('q'=>$q), 871 906 ); 872 $q = trim($q); 907 873 908 $expression = new QExpression($q); 874 909 //var_export($expression); … … 885 920 for ($i=0; $i<count($expression->stokens); $i++) 886 921 { 887 $debug[] = $expression->stokens[$i].': '.count($qsr->tag_ids[$i]).' tags, '.count($qsr->tag_iids[$i]).' tiids, '.count($qsr->images_iids[$i]).' iiids, '.count($qsr->iids[$i]).' iids'; 922 $debug[] = $expression->stokens[$i].': '.count($qsr->tag_ids[$i]).' tags, '.count($qsr->tag_iids[$i]).' tiids, '.count($qsr->images_iids[$i]).' iiids, '.count($qsr->iids[$i]).' iids' 923 .( !empty($qsr->variants[$expression->stokens[$i]]) ? ' variants: '.implode(', ',$qsr->variants[$expression->stokens[$i]]): ''); 888 924 } 889 925 $debug[] = 'before perms '.count($ids); -
trunk/index.php
r27882 r27884 86 86 $template->assign('thumb_navbar', $page['navigation_bar'] ); 87 87 88 if ( $page['section']=='search' and isset($page['qsearch_details']) ) 89 { 90 $template->assign('QUERY_SEARCH', htmlspecialchars($page['qsearch_details']['q']) ); 91 } 92 88 93 // caddie filling :-) 89 94 if (isset($_GET['caddie'])) … … 219 224 !isset($page['chronology_field']) and isset($page['qsearch_details']) ) 220 225 { 221 $template->assign('QUERY_SEARCH',222 htmlspecialchars($page['qsearch_details']['q']) );223 224 226 $cats = array_merge( 225 227 (array)@$page['qsearch_details']['matching_cats_no_images'], -
trunk/themes/default/template/menubar_menu.tpl
r21817 r27884 4 4 <form action="{$ROOT_URL}qsearch.php" method="get" id="quicksearch" onsubmit="return this.q.value!='' && this.q.value!=qsearch_prompt;"> 5 5 <p style="margin:0;padding:0"{*this <p> is for html validation only - does not affect positioning*}> 6 <input type="text" name="q" id="qsearchInput" onfocus="if (value==qsearch_prompt) value='';" onblur="if (value=='') value=qsearch_prompt;" style="width:90%" >6 <input type="text" name="q" id="qsearchInput" onfocus="if (value==qsearch_prompt) value='';" onblur="if (value=='') value=qsearch_prompt;" style="width:90%"{if !empty($QUERY_SEARCH)} value="{$QUERY_SEARCH}"{/if}> 7 7 </p> 8 8 </form> 9 <script type="text/javascript">var qsearch_prompt="{'Quick search'|@translate|@escape:'javascript'}"; document.getElementById('qsearchInput').value=qsearch_prompt;</script>9 <script type="text/javascript">var qsearch_prompt="{'Quick search'|@translate|@escape:'javascript'}";{if empty($QUERY_SEARCH)}document.getElementById('qsearchInput').value=qsearch_prompt;{/if}</script> 10 10 {/if} 11 11 <ul>{strip}
Note: See TracChangeset
for help on using the changeset viewer.