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_verbatim_keywords()

Parameters

ColumnTypeDefaultDescription
&$keywords
$string
$resource_type_field
$called_from_search false

Location

include/resource_functions.php lines 8435 to 8491

Definition

 
function add_verbatim_keywords(&$keywords$string$resource_type_field$called_from_search=false)
    {
    global 
$resource_field_verbatim_keyword_regex,$resource_field_checkbox_match_full;

    
// add ",<string>" if specified resource_type_field is found within $resource_field_checkbox_match_full array.
    
if( !$called_from_search &&
        isset(
$resource_field_checkbox_match_full) &&
        
is_array($resource_field_checkbox_match_full) &&
        
in_array($resource_type_field,$resource_field_checkbox_match_full))
        {
        
preg_match_all('/,[^,]+/'$string$matches);
        if (isset(
$matches[0][0]))
            {
            foreach (
$matches[0] as $match)
                {
                
$match=strtolower($match);
                
array_push($keywords,$match);
                }
            }
        }

    
// normal verbatim expansion of keywords as defined in config.php
    
if (!empty($resource_field_verbatim_keyword_regex[$resource_type_field]))
        {
        
preg_match_all($resource_field_verbatim_keyword_regex[$resource_type_field], $string$matches);
        foreach (
$matches as $match)
            {
            foreach (
$match as $sub_match)
                {
                
array_push($keywords$sub_match);        // note that the keywords array is passed in by reference.
                
}
            }
        }

    
// when searching change "field:<string>" to "field:,<string>" if specified resource_type_field is found within $resource_field_checkbox_match_full array.
    
if ($called_from_search &&
        isset(
$resource_field_checkbox_match_full) &&
        
is_array($resource_field_checkbox_match_full) &&
        
in_array($resource_type_field,$resource_field_checkbox_match_full))
        {
        
$found_name ps_value("SELECT `name` AS 'value' FROM `resource_type_field` WHERE `ref`=?", array("i",$resource_type_field), "");
        
preg_match_all('/' $found_name ':([^,]+)/'$string$matches);
        if (isset(
$matches[1][0]))
            {
            foreach (
$matches[1] as $match)
                {
                
$match=strtolower($match);
                
$remove "{$found_name}:{$match}";
                if (
in_array($remove,$keywords))
                    {
                    unset(
$keywords[array_search($remove,$keywords)]);
                    }
                
array_push($keywords"{$found_name}:,{$match}");
                }
            }
        }
    }

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