Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

add_verbatim_keywords()

Parameters

ColumnTypeDefaultDescription
&$keywords
$string
$resource_type_field
$called_from_search false

Location

include/resource_functions.php lines 8249 to 8305

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 19th March 2024 09:35 Europe/London time based on the source file dated 11th March 2024 14:25 Europe/London time.