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

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
    
$GLOBALS['customsitetext'] = array();

    
// Set the default language first, user language second so we can override the default with any language specific entries
    
foreach([$defaultlanguage$language] as $check_lang)
        {
        foreach(
$results as $result)
            {
             if(
$result['language'] != $check_lang)
                 {
                 continue;
                 }

             if(
$result['page'] == '')
                 {
                 
$lang[$result['name']] = $result['text'];
                 
$GLOBALS['customsitetext'][$result['name']] = $result['text'];
                 } 
             else 
                 {
                 
$lang["{$result['page']}__{$result['name']}"] = $result['text'];
                 }
             }
         }
    }

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.