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

add_sql_node_language()

Description

Append SQL to an existing node query to obtain the translated names of the node

Parameters

ColumnTypeDefaultDescription
&$sql_select
&$sql_params
$alias string "node"
$sql_select string SQL query
$sql_params array Array of SQL parameters

Return

void *

Location

include/node_functions.php lines 2724 to 2764

Definition

 
function add_sql_node_language(&$sql_select,&$sql_params,string $alias "node")
    {
    global 
$language,$defaultlanguage;

    
// Use language specified, if not use default
    
isset($language) ? $language_in_use $language $language_in_use $defaultlanguage;


    
// Get length of language string + 2 (for ~ and :) for usage in SQL below
    
$language_string_length = (strlen($language_in_use) + 2);

    
$sql_paramsarray_merge($sql_params,[
        
"s","~" $language_in_use,
        
"s","~" $language_in_use":",
        
"i",$language_string_length,
        
"s","~" $language_in_use":",
        
"i",$language_string_length,
        
"s","~" $language_in_use":",
        
"i",$language_string_length,
        ]);
    
$sql_select .= ", 
        CASE
        WHEN
            POSITION(? IN " 
$alias ".name) > 0
        THEN
            TRIM(SUBSTRING(name,
                    POSITION(? IN " 
$alias ".name) + ?,
                    CASE
                        WHEN
                            POSITION('~' IN SUBSTRING(" 
$alias ".name,
                                    POSITION(? IN " 
$alias ".name) + ?,
                                    LENGTH(" 
$alias ".name) - 1)) > 0
                        THEN
                            POSITION('~' IN SUBSTRING(" 
$alias ".name,
                                    POSITION(? IN " 
$alias ".name) + ?,
                                    LENGTH(" 
$alias ".name) - 1)) - 1
                        ELSE LENGTH(" 
$alias ".name)
                    END))
        ELSE TRIM(" 
$alias ".name)
        END AS translated_name"
;
    }

This article was last updated 26th April 2024 21:35 Europe/London time based on the source file dated 15th April 2024 11:30 Europe/London time.