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

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 659 to 714

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 17th November 2024 15:35 Europe/London time based on the source file dated 28th October 2024 11:15 Europe/London time.