Collections functions
Encryption functions
General functions
Theme permission functions
Resource functions

resolve_keyword()

Parameters

ColumnTypeDefaultDescription
$keyword
$create false
$normalize true
$stem true

Location

include/search_functions.php lines 2004 to 2035

Definition

 
function resolve_keyword($keyword,$create=false,$normalize=true,$stem=true)
    {
    
debug_function_call("resolve_keyword"func_get_args());

    global 
$quoted_string$stemming;
    
$keyword=substr($keyword,0,100); # Trim keywords to 100 chars for indexing, as this is the length of the keywords column.
            
    
if(!$quoted_string && $normalize)
        {
        
$keyword=normalize_keyword($keyword);       
        
debug("resolving normalized keyword " $keyword  ".");
        }
    
    
# Stemming support. If enabled and a stemmer is available for the current language, index the stem of the keyword not the keyword itself.
    # This means plural/singular (and other) forms of a word are treated as equivalents.
    
    
if ($stem && $stemming && function_exists("GetStem"))
        {
        
$keyword=GetStem($keyword);
        }

    
# Returns the keyword reference for $keyword, or false if no such keyword exists.
    
$return=sql_value("select ref value from keyword where keyword='" trim(escape_check($keyword)) . "'",false);
    if (
$return===false && $create)
        {
        
# Create a new keyword.
        
debug("resolve_keyword: Creating new keyword for " $keyword);
        
sql_query("insert into keyword (keyword,soundex,hit_count) values ('" escape_check($keyword) . "',left('".soundex(escape_check($keyword))."',10),0)");
        
$return=sql_insert_id();
        }
    return 
$return;
    }

This article was last updated 10th July 2020 20:35 Europe/London time based on the source file dated 7th July 2020 15:22 Europe/London time.