Collections functions
Encryption functions
General functions
Theme permission functions
Resource functions

get_suggested_keywords()

Parameters

ColumnTypeDefaultDescription
$search
$ref ""

Location

include/search_functions.php lines 2206 to 2249

Definition

 
function get_suggested_keywords($search,$ref="")
    {
    
# For the given partial word, suggest complete existing keywords.
    
global $autocomplete_search_items,$autocomplete_search_min_hitcount;
    
    
# Fetch a list of fields that are not available to the user - these must be omitted from the search.
    
$hidden_indexed_fields=get_hidden_indexed_fields();
    
    
$restriction_clause_free "";
    
$restriction_clause_node ""
    
    if (
count($hidden_indexed_fields) > 0)
        {
        
$restriction_clause_free .= " AND rk.resource_type_field NOT IN ('" join("','"$hidden_indexed_fields) . "')";
        
$restriction_clause_node .= " AND n.resource_type_field NOT IN ('" join("','"$hidden_indexed_fields) . "')";                                 
        }
    
    if ((string)(int)
$ref == $ref)
        {
        
$restriction_clause_free .= " AND rk.resource_type_field = '" $ref "'";
        
$restriction_clause_node .= " AND n.resource_type_field = '" $ref "'";                                        
        }    
    
    return 
sql_array("SELECT ak.keyword value
        FROM
            (
            SELECT k.keyword, k.hit_count
            FROM keyword k
            JOIN resource_keyword rk ON rk.keyword=k.ref
            WHERE k.keyword LIKE '" 
escape_check($search) . "%'" $restriction_clause_free "
            AND k.hit_count >= '
$autocomplete_search_min_hitcount'
         
            UNION
         
            SELECT k.keyword, k.hit_count
            FROM keyword k
            JOIN node_keyword nk ON nk.keyword=k.ref
            JOIN node n ON n.ref=nk.node
            WHERE k.keyword LIKE '" 
escape_check($search) . "%'" $restriction_clause_node "
            ) ak
        GROUP BY ak.keyword, ak.hit_count 
        ORDER BY ak.hit_count DESC LIMIT " 
$autocomplete_search_items
        
);
    }

This article was last updated 16th July 2020 02:05 Europe/London time based on the source file dated 7th July 2020 15:22 Europe/London time.