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

reindex_resource()

Parameters

ColumnTypeDefaultDescription
$ref

Location

include/resource_functions.php lines 5549 to 5598

Definition

 
function reindex_resource($ref)
    {
    global 
$index_contributed_by$index_resource_type,$FIXED_LIST_FIELD_TYPES;
    
# Reindex a resource. Delete all resource_keyword rows and create new ones.
    
    # Delete existing keywords
    
sql_query("DELETE FROM resource_keyword WHERE resource = '{$ref}'");

    
# Index fields
    
$data=get_resource_field_data($ref,false,false); # Fetch all fields and do not use permissions.
    
for ($m=0;$m<count($data);$m++)
        {
        if (
$data[$m]["keywords_index"]==&& !in_array($data[$m]["type"],$FIXED_LIST_FIELD_TYPES))
            {
            
#echo $data[$m]["value"];
            
$value=$data[$m]["value"];
            if (
$data[$m]["type"]==|| $data[$m]["type"]==2)
                {
                
# Prepend a comma when indexing dropdowns
                
$value="," $value;
                }
            
            
# Date field? These need indexing differently.
            
$is_date=($data[$m]["type"]==|| $data[$m]["type"]==6);

            
$is_html=($data[$m]["type"]==8);                    
            
add_keyword_mappings($ref,i18n_get_indexable($value),$data[$m]["ref"],$data[$m]["partial_index"],$is_date,'','',$is_html);        
            }
        }
    
    
# Also index contributed by field, unless disabled
    
if ($index_contributed_by)
        {
        
$resource=get_resource_data($ref);
        
$userinfo=get_user($resource["created_by"]);
        
add_keyword_mappings($ref,$userinfo["username"] . " " $userinfo["fullname"],-1);
        }

        
# Also index the resource type name, unless disabled
    
if ($index_resource_type)
        {
        
$restypename=ps_value("select name value from resource_type where ref in (select resource_type from resource where ref=?)",array("i",$ref), "");
        
add_keyword_mappings($ref,$restypename,-2);
        }
                
    
# Always index the resource ID as a keyword
    
add_keyword_mappings($ref$ref, -1);
    
    
hook("afterreindexresource","all",array($ref));
    }

This article was last updated 28th June 2022 15:05 Europe/London time based on the source file dated 27th June 2022 12:50 Europe/London time.