Ignore:
Timestamp:
Apr 12, 2014, 8:13:46 PM (10 years ago)
Author:
rvelices
Message:

autocomplete fixes for custom suggestions and variants

Location:
extensions/rv_autocomplete
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/rv_autocomplete/admin/functions.inc.php

    r28153 r28161  
    2222                        $q = substr($q, 0, $pos);
    2323                }
     24                $invalid = '&()".:;,';
     25                $q = strtr($q, $invalid, str_repeat(' ', strlen($invalid)));
     26                for($i=0; $i<3; $i++)
     27                        $q = str_replace('  ', ' ', $q);
    2428        }
    2529        elseif (strncmp($url,'q=',2)==0)
     
    3539        if (isset($q))
    3640        {
    37                 if ( ($pos=strpos($q,' ')) !== false )
    38                 {
    39                         $q = '"'.$q.'"';
    40                 }
    4141                $url = get_root_url().'qsearch.php?q='.rawurlencode($q);
    4242        }
     
    198198                        $results = $rule['out'];
    199199                        $processed = array();
     200                        if ('a' == $rule['type'])
     201                                $processed[$in_word_t] = 1;
     202
    200203                        for ($i=0; $i<count($results); $i++)
    201204                        {
     
    247250                file_put_contents($file, $save);
    248251        }
    249         @file_put_contents($file.'.txt', var_export($res,true) );
     252        $file=PHPWG_ROOT_PATH.$conf['data_location'].'tmp/autocomplete_variants.txt';
     253        if ($fh = @fopen($file, 'w'))
     254        {
     255                fputcsv($fh, array("Type", "In", "Out"), "\t");
     256                foreach($rmap as $in => $words)
     257                        fputcsv($fh, array("r", $in, implode(',', $words)), "\t");
     258                foreach($amap as $in => $words)
     259                        fputcsv($fh, array("r", $in, implode(',', $words)), "\t");
     260                fclose($fh);
     261        }
    250262}
    251263
     
    282294        sort($in_trans);
    283295        $key = implode(',', $in_trans);
    284         if (strlen($key)>16)
     296        if (strlen($key)>24)
    285297                $key = md5($key);
    286298
     
    308320        );
    309321        if (!empty($params['comment']))
    310                 $rule['comment'] = $params['comment'];
     322                $rule['comment'] = stripslashes($params['comment']);
    311323        $rules[$key] = $rule;
    312324
  • extensions/rv_autocomplete/functions.inc.php

    r28153 r28161  
    3737function rvac_normalize($name)
    3838{
    39         $invalid = '&().,-';
     39        $invalid = '&()".,:;-';
    4040        $name = strtr($name, $invalid, str_repeat(' ', strlen($invalid)));
    4141        $name = transliterate($name);
     
    238238                }
    239239
    240                 $in_list = $processed = array();
     240                $processed = array();
    241241                for ($i=0; $i<count($all); $i++)
    242242                {
     
    244244                        $in_t = transliterate($in);
    245245
    246                         if (isset($in_list[$in_t]))
     246                        if (isset($processed[$in_t]))
    247247                        {
    248248                                array_splice($all, $i, 1);
     
    250250                                continue;
    251251                        }
    252 
    253                         if (isset($processed[$in_t]))
    254                                 continue;
    255252                        $processed[$in_t] = 1;
    256253
    257254                        if (isset($amap[$in_t]))
    258255                        {
    259                                 array_splice($all, $i, 0, $amap[$in_t]);
     256                                $all = array_merge($all, $amap[$in_t]);
    260257                        }
    261258                }
Note: See TracChangeset for help on using the changeset viewer.