Collections functions
General functions
Render functions
Theme permission functions
Resource functions

lang_load_site_text()

Description

Load all site text for the given page and language into the global $lang array

Parameters

ColumnTypeDefaultDescription
&$lang
$pagename string Pagename
$language string "" Language
$lang array Passed by reference

Return

void

Location

include/language_functions.php lines 625 to 691

Definition

 
function lang_load_site_text(&$lang,$pagename,$language "")
    {
    global 
$defaultlanguage$site_text;

    
$site_text=array();
    
$results=ps_query("SELECT language,name,text FROM site_text WHERE (page=? OR page='all' OR page='') AND (specific_to_group IS NULL OR specific_to_group=0)",array("s",$pagename),"sitetext");

    for (
$n=0;$n<count($results);$n++)
        {
        
$site_text[$results[$n]["language"] . "-" $results[$n]["name"]]=$results[$n]["text"];
        }

    
$query " SELECT `name`,
                `text`,
                `page`,
                `language`, specific_to_group 
            FROM site_text
            WHERE (`language` = ? OR `language` = ?)
            AND (specific_to_group IS NULL OR specific_to_group = 0)
        "
;
    
$parameters=array("s",$language,"s",$defaultlanguage);

    if (
$pagename!="admin_content")
        {
        
// Load all content on the admin_content page to allow management.
        
$query.="AND (page = ? OR page = 'all' OR page = '' " .  (($pagename=="dash_tile")?" OR page = 'home'":"") . ")";
        
$parameters[]="s";$parameters[]=$pagename;
        }

    
$results=ps_query($query,$parameters,"sitetext");

    
// Create a new array to hold customised text at any stage, may be overwritten in authenticate.php. Needed so plugin lang file can be overidden if plugin only enabled for specific groups
    
$customsitetext=array();
    
// Go through the results twice, setting the default language first, then repeat for the user language so we can override the default with any language specific entries
    
for ($n=0;$n<count($results);$n++) 
        {
        if(
$results[$n]["language"]!=$defaultlanguage)
            {
            continue;
            }
        if (
$results[$n]["page"]==""
            {
            
$lang[$results[$n]["name"]]=$results[$n]["text"];
            
$customsitetext[$results[$n]['name']] = $results[$n]['text'];
            } 
        else 
            {
            
$lang[$results[$n]["page"] . "__" $results[$n]["name"]]=$results[$n]["text"];
            }
        }
    for (
$n=0;$n<count($results);$n++) 
        {
        if(
$results[$n]["language"]!=$language)
            {
            continue;
            }
        if (
$results[$n]["page"]==""
            {
            
$lang[$results[$n]["name"]]=$results[$n]["text"];
            
$customsitetext[$results[$n]['name']] = $results[$n]['text'];
            } 
        else 
            {
            
$lang[$results[$n]["page"] . "__" $results[$n]["name"]]=$results[$n]["text"];
            }
        }
    }

This article was last updated 26th June 2022 06:35 Europe/London time based on the source file dated 1st June 2022 12:35 Europe/London time.