includes/lang.php
changeset 210 2b283402e4e4
parent 209 8a00247d1dee
child 215 94db56b8124f
equal deleted inserted replaced
209:8a00247d1dee 210:2b283402e4e4
    34    * The ISO-639-3 code for the loaded language. This should be grabbed directly from the database.
    34    * The ISO-639-3 code for the loaded language. This should be grabbed directly from the database.
    35    * @var string
    35    * @var string
    36    */
    36    */
    37   
    37   
    38   var $lang_code;
    38   var $lang_code;
       
    39 
       
    40   /**
       
    41    * Used to track when a language was last changed, to allow browsers to cache language data
       
    42    * @var int
       
    43    */
       
    44   
       
    45   var $lang_timestamp;
    39   
    46   
    40   /**
    47   /**
    41    * Will be an object that holds an instance of the class configured with the site's default language. Only instanciated when needed.
    48    * Will be an object that holds an instance of the class configured with the site's default language. Only instanciated when needed.
    42    * @var object
    49    * @var object
    43    */
    50    */
    80     {
    87     {
    81       $db->_die('lang.php - attempting to pass invalid value to constructor');
    88       $db->_die('lang.php - attempting to pass invalid value to constructor');
    82     }
    89     }
    83     
    90     
    84     $lang_default = ( $x = getConfig('default_language') ) ? intval($x) : 'def';
    91     $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;");
    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;");
    86     
    93     
    87     if ( !$q )
    94     if ( !$q )
    88       $db->_die('lang.php - main select query');
    95       $db->_die('lang.php - main select query');
    89     
    96     
    90     if ( $db->numrows() < 1 )
    97     if ( $db->numrows() < 1 )
    92     
    99     
    93     $row = $db->fetchrow();
   100     $row = $db->fetchrow();
    94     
   101     
    95     $this->lang_id   = intval( $row['lang_id'] );
   102     $this->lang_id   = intval( $row['lang_id'] );
    96     $this->lang_code = $row['lang_code'];
   103     $this->lang_code = $row['lang_code'];
       
   104     $this->lang_timestamp = $row['last_changed'];
    97   }
   105   }
    98   
   106   
    99   /**
   107   /**
   100    * PHP 4 constructor.
   108    * PHP 4 constructor.
   101    * @param int|string Language ID or code to load.
   109    * @param int|string Language ID or code to load.
   300       // Ehh, that's not good
   308       // Ehh, that's not good
   301       $db->_die('lang.php - var_export_string() failed');
   309       $db->_die('lang.php - var_export_string() failed');
   302     
   310     
   303     fwrite($handle, $exported . '; ?>');
   311     fwrite($handle, $exported . '; ?>');
   304     
   312     
       
   313     // Update timestamp in database
       
   314     $q = $db->sql_query('UPDATE ' . table_prefix . 'language SET last_changed = ' . time() . ' WHERE lang_id = ' . $this->lang_id . ';');
       
   315     if ( !$q )
       
   316       $db->_die('lang.php - updating timestamp on language');
       
   317     
   305     // Done =)
   318     // Done =)
   306     fclose($handle);
   319     fclose($handle);
   307   }
   320   }
   308   
   321   
   309   /**
   322   /**