Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

i18n_get_indexable()

Description

For field names / values using the i18n syntax, return all language versions, as necessary for indexing.

Parameters

ColumnTypeDefaultDescription
$text string The text to process

Return

void

Location

include/language_functions.php lines 153 to 186

Definition

 
function i18n_get_indexable($text)
    {
    
// Make sure keywords don't get squashed together, then trim
    
$text=str_replace(array("<br />","<br>","\\r","\\n","&nbsp;")," ",$text);
    
$text=trim($text);
    
    
$text=preg_replace('/~(.*?):/',',',$text);// remove i18n strings, which shouldn't be in the keywords
        
    # For multiple keywords, parse each keyword.
    
if (substr($text,0,1)!="," && (strpos($text,",")!==false) && (strpos($text,"~")!==false)) {
        
$s=explode(",",$text);
        
$out="";
        for (
$n=0;$n<count($s);$n++) {
        if (
$n>0) {$out.=",";} 
        
$out.=i18n_get_indexable(trim($s[$n]));
        }
        return 
$out;
    }

    
# Split
    
$s=explode("~",$text);

    
# Not a translatable field?
    
if (count($s)<2) {return $text;}

    
$out="";
    for (
$n=1;$n<count($s);$n++)
        {
        if (
substr($s[$n],2,1)!=":") {return $text;}
        if (
$out!="") {$out.=",";}
        
$out.=substr($s[$n],3);
        }    
    return 
$out;
    }

This article was last updated 24th November 2020 18:35 Europe/London time based on the source file dated 7th July 2020 14:31 Europe/London time.