includes/lang.php
changeset 616 e311f5e6f904
parent 613 c08670a77871
child 623 a7a14bc57855
equal deleted inserted replaced
615:8eed90734867 616:e311f5e6f904
    74   
    74   
    75   function __construct($lang)
    75   function __construct($lang)
    76   {
    76   {
    77     global $db, $session, $paths, $template, $plugins; // Common objects
    77     global $db, $session, $paths, $template, $plugins; // Common objects
    78     
    78     
    79     if ( defined('IN_ENANO_INSTALL') )
    79     if ( defined('IN_ENANO_INSTALL') && !defined('ENANO_CONFIG_FETCHED') )
    80     {
    80     {
    81       // special case for the Enano installer: it will load its own strings from a JSON file and just use this API for fetching and templatizing them.
    81       // special case for the Enano installer: it will load its own strings from a JSON file and just use this API for fetching
       
    82       // and templatizing them.
       
    83       // 1.1.4 fix: this was still being called after main API startup from installer payload
    82       $this->lang_id   = 1;
    84       $this->lang_id   = 1;
    83       $this->lang_code = $lang;
    85       $this->lang_code = $lang;
    84       return true;
    86       return true;
    85     }
    87     }
    86     if ( is_string($lang) )
    88     if ( is_string($lang) )
    94     else
    96     else
    95     {
    97     {
    96       $db->_die('lang.php - attempting to pass invalid value to constructor');
    98       $db->_die('lang.php - attempting to pass invalid value to constructor');
    97     }
    99     }
    98     
   100     
    99     $lang_default = ( $x = getConfig('default_language') ) ? intval($x) : '\'def\'';
   101     $lang_default = ( $x = getConfig('default_language') ) ? intval($x) : '0';
   100     
   102     
   101     $q = $db->sql_query("SELECT lang_id, lang_code, last_changed, ( lang_id = $lang_default ) AS is_default FROM " . table_prefix . "language WHERE $sql_col OR lang_id = $lang_default ORDER BY is_default ASC LIMIT 1;");
   103     $q = $db->sql_query("SELECT lang_id, lang_code, last_changed, ( lang_id = $lang_default ) AS is_default FROM " . table_prefix . "language WHERE $sql_col OR lang_id = $lang_default ORDER BY is_default ASC LIMIT 1;");
   102     
   104     
   103     if ( !$q )
   105     if ( !$q )
   104       $db->_die('lang.php - main select query');
   106       $db->_die('lang.php - main select query');
   604    * @return string
   606    * @return string
   605    */
   607    */
   606   
   608   
   607   function get_uncensored($string_id, $substitutions = false)
   609   function get_uncensored($string_id, $substitutions = false)
   608   {
   610   {
       
   611     global $db, $session, $paths, $template, $plugins; // Common objects
       
   612     
   609     // Extract the category and string ID
   613     // Extract the category and string ID
   610     $category = substr($string_id, 0, ( strpos($string_id, '_') ));
   614     $category = substr($string_id, 0, ( strpos($string_id, '_') ));
   611     $string_name = substr($string_id, ( strpos($string_id, '_') + 1 ));
   615     $string_name = substr($string_id, ( strpos($string_id, '_') + 1 ));
   612     $found = false;
   616     $found = false;
   613     if ( isset($this->strings[$category]) && isset($this->strings[$category][$string_name]) )
   617     if ( isset($this->strings[$category]) && isset($this->strings[$category][$string_name]) )
   617     }
   621     }
   618     if ( !$found )
   622     if ( !$found )
   619     {
   623     {
   620       // Ehh, the string wasn't found. Rerun fetch() and try again.
   624       // Ehh, the string wasn't found. Rerun fetch() and try again.
   621       // Or if it's the installer, no use in refetching, so just fail.
   625       // Or if it's the installer, no use in refetching, so just fail.
   622       if ( defined('IN_ENANO_INSTALL') )
   626       if ( defined('IN_ENANO_INSTALL') || ( defined('ENANO_INSTALLED') && !@$db->_conn ) )
   623       {
   627       {
   624         return $string_id;
   628         return $string_id;
   625       }
   629       }
   626       $this->fetch();
   630       $this->fetch();
   627       profiler_log('Language(' . $this->lang_code . '): refetched due to missing string: ' . $string_id);
   631       profiler_log('Language(' . $this->lang_code . '): refetched due to missing string: ' . $string_id);