Collections functions
Encryption functions
General functions
Theme permission functions
Resource functions

index_collection()

Description

Update the keywords index for this collection

Parameters

ColumnTypeDefaultDescription
$ref integer
$index_string string ''

Return

integer How many keywords were indexed?

Location

include/collections_functions.php lines 839 to 877

Definition

 
function index_collection($ref,$index_string='')
    {
    

    
sql_query("delete from collection_keyword where collection='" escape_check($ref) . "'"); # Remove existing keywords
    # Define an indexable string from the name, themes and keywords.

    
global $index_collection_titles;

    if (
$index_collection_titles)
        {
            
$indexfields 'c.ref,c.name,c.keywords,c.description';
        } else {
            
$indexfields 'c.ref,c.keywords';
        }
    global 
$index_collection_creator;
    if (
$index_collection_creator)
        {
            
$indexfields .= ',u.fullname';
        } 
        
    
    
// if an index string wasn't supplied, generate one
    
if (!strlen($index_string) > 0){
        
$indexarray sql_query("select $indexfields from collection c left join user u on u.ref=c.user where c.ref = '" escape_check($ref) . "'");
        for (
$i=0$i<count($indexarray); $i++){
            
$index_string "," implode(',',$indexarray[$i]);
        } 
    }

    
$keywords=split_keywords($index_string,true);
    for (
$n=0;$n<count($keywords);$n++)
        {
        if(
trim($keywords[$n])==""){continue;}
        
$keyref=resolve_keyword($keywords[$n],true);
        
sql_query("insert into collection_keyword values ('" escape_check($ref) . "','$keyref')");
        }
    
// return the number of keywords indexed
    
return $n;
    }

This article was last updated 11th July 2020 22:35 Europe/London time based on the source file dated 9th July 2020 17:22 Europe/London time.