Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

get_suggested_keywords()

Parameters

ColumnTypeDefaultDescription
$search
$ref ""

Location

include/search_functions.php lines 2577 to 2613

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_node "";
    
$params=array("s",$search "%");

    if (
count($hidden_indexed_fields) > 0)
        {
        
$restriction_clause_node .= " AND n.resource_type_field NOT IN (" ps_param_insert(count($hidden_indexed_fields)) . ")";
        
$params=array_merge($params,ps_param_fill($hidden_indexed_fields,"i"));
        }

    if ((string)(int)
$ref == $ref)
        {
        
$restriction_clause_node .= " AND n.resource_type_field = ?";
        
$params[]="i";$params[]=$ref;
        }

    
$params[]="i";$params[]=$autocomplete_search_items;

    return 
ps_array("SELECT ak.keyword value
        FROM
            (
            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 ? " 
$restriction_clause_node "
            ) ak
        GROUP BY ak.keyword, ak.hit_count
        ORDER BY ak.hit_count DESC LIMIT ?"
,$params);
    }

This article was last updated 13th September 2024 13:05 Europe/London time based on the source file dated 17th July 2024 15:30 Europe/London time.