includes/lang.php
changeset 209 8a00247d1dee
parent 205 c4542792db2b
child 210 2b283402e4e4
equal deleted inserted replaced
208:c75ad574b56d 209:8a00247d1dee
    79     else
    79     else
    80     {
    80     {
    81       $db->_die('lang.php - attempting to pass invalid value to constructor');
    81       $db->_die('lang.php - attempting to pass invalid value to constructor');
    82     }
    82     }
    83     
    83     
    84     $lang_default = ( $x = getConfig('default_language') ) ? intval($x) : 1;
    84     $lang_default = ( $x = getConfig('default_language') ) ? intval($x) : 'def';
    85     $q = $db->sql_query("SELECT lang_id, lang_code, ( lang_id = $lang_default ) AS is_default FROM " . table_prefix . "language WHERE $sql_col OR lang_id = $lang_default ORDER BY is_default DESC LIMIT 1;");
    85     $q = $db->sql_query("SELECT lang_id, lang_code, ( lang_id = $lang_default ) AS is_default FROM " . table_prefix . "language WHERE $sql_col OR lang_id = $lang_default ORDER BY is_default DESC LIMIT 1;");
    86     
    86     
    87     if ( !$q )
    87     if ( !$q )
    88       $db->_die('lang.php - main select query');
    88       $db->_die('lang.php - main select query');
    89     
    89     
   370       // Alright, it's nowhere. Return the input, grumble grumble...
   370       // Alright, it's nowhere. Return the input, grumble grumble...
   371       return $string_id;
   371       return $string_id;
   372     }
   372     }
   373     // Found it!
   373     // Found it!
   374     // Perform substitutions.
   374     // Perform substitutions.
       
   375     // if ( is_array($substitutions) )
       
   376     //   die('<pre>' . print_r($substitutions, true) . '</pre>');
   375     if ( !is_array($substitutions) )
   377     if ( !is_array($substitutions) )
   376       $substitutions = array();
   378       $substitutions = array();
   377     return $this->substitute($string, $substitutions);
   379     return $this->substitute($string, $substitutions);
   378   }
   380   }
   379   
   381   
   393       {
   395       {
   394         $result = $this->get($string_id);
   396         $result = $this->get($string_id);
   395         $string = str_replace($matches[0][$i], $result, $string);
   397         $string = str_replace($matches[0][$i], $result, $string);
   396       }
   398       }
   397     }
   399     }
       
   400     preg_match_all('/%config\.([a-z0-9_]+)%/', $string, $matches);
       
   401     if ( count($matches[0]) > 0 )
       
   402     {
       
   403       foreach ( $matches[1] as $i => $string_id )
       
   404       {
       
   405         $result = getConfig($string_id);
       
   406         $string = str_replace($matches[0][$i], $result, $string);
       
   407       }
       
   408     }
   398     foreach ( $subs as $key => $value )
   409     foreach ( $subs as $key => $value )
   399     {
   410     {
   400       $string = str_replace("%$key%", $value, $string);
   411       $subs[$key] = strval($value);
   401     }
   412       $string = str_replace("%{$key}%", "{$subs[$key]}", $string);
   402     return $string;
   413     }
       
   414     return "[L] $string";
   403   }
   415   }
   404   
   416   
   405 } // class Language
   417 } // class Language
   406 
   418 
   407 ?>
   419 ?>