Collections functions
General functions
Node functions
Render functions
Theme permission functions
User 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

string

Location

include/language_functions.php lines 152 to 185

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 19th March 2024 05:05 Europe/London time based on the source file dated 8th March 2024 15:10 Europe/London time.