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_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 2768 to 2808

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 12th December 2024 16:35 Europe/London time based on the source file dated 11th December 2024 22:35 Europe/London time.