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

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 1308 to 1346

Definition

 
function index_collection($ref,$index_string='')
    {
    
# Remove existing indexed keywords
    
ps_query("delete from collection_keyword where collection=?",array("i",$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 ps_query("select $indexfields from collection c left join user u on u.ref=c.user where c.ref = ?",array("i",$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);
        
ps_query("insert into collection_keyword values (?,?)",array("i",$ref,"i",$keyref));
        }
    
// return the number of keywords indexed
    
return $n;
    }

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