includes/lang.php
changeset 372 5bd429428101
parent 371 dc6026376919
child 376 66732bd4532c
equal deleted inserted replaced
371:dc6026376919 372:5bd429428101
    87     {
    87     {
    88       $db->_die('lang.php - attempting to pass invalid value to constructor');
    88       $db->_die('lang.php - attempting to pass invalid value to constructor');
    89     }
    89     }
    90     
    90     
    91     $lang_default = ( $x = getConfig('default_language') ) ? intval($x) : '\'def\'';
    91     $lang_default = ( $x = getConfig('default_language') ) ? intval($x) : '\'def\'';
    92     $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 DESC LIMIT 1;");
    92     
       
    93     $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;");
    93     
    94     
    94     if ( !$q )
    95     if ( !$q )
    95       $db->_die('lang.php - main select query');
    96       $db->_die('lang.php - main select query');
    96     
    97     
    97     if ( $db->numrows() < 1 )
    98     if ( $db->numrows() < 1 )
   318     // Trim off all text before and after the starting and ending braces
   319     // Trim off all text before and after the starting and ending braces
   319     $contents = preg_replace('/^([^{]+)\{/', '{', $contents);
   320     $contents = preg_replace('/^([^{]+)\{/', '{', $contents);
   320     $contents = preg_replace('/\}([^}]+)$/', '}', $contents);
   321     $contents = preg_replace('/\}([^}]+)$/', '}', $contents);
   321     
   322     
   322     // Correct syntax to be nice to the json parser
   323     // Correct syntax to be nice to the json parser
   323     
   324     $contents = enano_clean_json($contents);
   324     // eliminate comments
       
   325     $contents = preg_replace(array(
       
   326             // eliminate single line comments in '// ...' form
       
   327             '#^\s*//(.+)$#m',
       
   328             // eliminate multi-line comments in '/* ... */' form, at start of string
       
   329             '#^\s*/\*(.+)\*/#Us',
       
   330             // eliminate multi-line comments in '/* ... */' form, at end of string
       
   331             '#/\*(.+)\*/\s*$#Us'
       
   332           ), '', $contents);
       
   333     
       
   334     $contents = preg_replace('/([,\{\[])([\s]*?)([a-z0-9_]+)([\s]*?):/', '\\1\\2"\\3" :', $contents);
       
   335     
   325     
   336     try
   326     try
   337     {
   327     {
   338       $langdata = enano_json_decode($contents);
   328       $langdata = enano_json_decode($contents);
   339     }
   329     }