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

add_node_keyword_mappings()

Description

Function used to index node keywords

have access to the fields' data

Parameters

ColumnTypeDefaultDescription
$node array Individual node for a field ( as returned by get_nodes() )
$partial_index boolean|null false Partially index flag for node keywords. Use NULL if code doesn't
$is_date bool false
$is_html bool false

Return

boolean

Location

include/node_functions.php lines 1167 to 1233

Definition

 
function add_node_keyword_mappings(array $node$partial_index false,bool $is_date=false,bool $is_html=false)
    {
    global 
$node_keyword_index_chars;
    if(
'' == trim($node['ref']) && '' == trim($node['name']) && '' == trim($node['resource_type_field']))
        {
        return 
false;
        }

    
// Client code does not know whether field is partially indexed or not
    
if(is_null($partial_index))
        {
        
$field_data get_field($node['resource_type_field']);

        if(isset(
$field_data['partial_index']) && '' != trim($field_data['partial_index']))
            {
            
$partial_index $field_data['partial_index'];
            }
        }

    
// Check for translations and split as necessary
    
if(substr($node['name'],0,1) == "~")
        {
        
$translations array_filter(i18n_get_translations($node['name']));
        }
    else
        {
        
$translations[] = $node['name'];
        }
    
$in_transaction $GLOBALS['sql_transaction_in_progress'] ?? false;
    if(!
$in_transaction)
        {
        
db_begin_transaction("add_node_keyword_mappings");
        }
    foreach(
$translations as $translation)
        {
        
// Only index the first 500 characters
        
$translation mb_substr($translation,0,$node_keyword_index_chars);

        
$keywords split_keywords($translationtrue$partial_index,$is_date$is_html);

        
add_verbatim_keywords($keywords$translation$node['resource_type_field']);

        for(
$n 0$n count($keywords); $n++)
            {
            unset(
$keyword_position);

            if(
is_array($keywords[$n]))
                {
                
$keyword_position $keywords[$n]['position'];
                
$keywords[$n]     = $keywords[$n]['keyword'];
                }

            if(!isset(
$keyword_position))
                {
                
$keyword_position $n;
                }

            
add_node_keyword($node['ref'], $keywords[$n], $keyword_position);
            }
        }
    if(!
$in_transaction)
        {
        
db_end_transaction("add_node_keyword_mappings");
        }

    return 
true;
    }

This article was last updated 17th November 2024 15:35 Europe/London time based on the source file dated 28th October 2024 11:15 Europe/London time.