Advertisement
Guest User

m4a_X sprache aus db lesen

a guest
Oct 19th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. class Language {
  2.  
  3. protected $langID = null;
  4. protected $langArray = array();
  5. public function __construct( $langid = null ) {
  6. if( $langid != null ) {
  7. $this->langID = $langid;
  8. }
  9. $this->initLanguage();
  10. }
  11.  
  12. protected function initLanguage() {
  13. $sql = UCP_Framework::getDB()->sendQuery("SELECT * FROM `languages` WHERE ID = '". $this->langID ."'");
  14. if( UCP_Framework::getDB()->numRows($sql) == 0) {
  15. $this->langID = 1; //default
  16. }
  17.  
  18. $sql = UCP_Framework::getDB()->sendQuery("SELECT * FROM `languagevars` WHERE langID = '". $this->langID . "'");
  19. while( $row = UCP_Framework::getDB()->fetchArray($sql)) {
  20. $this->langArray[] = $row;
  21. }
  22. }
  23.  
  24. public function __get($id) {
  25. $rtn_found = false;
  26. foreach( $this->langArray as $lang ) {
  27. if( $lang["languageVar"] == $id ) {
  28. $rtn_found = true;
  29. $rtn_value = $lang["languageValue"];
  30. }
  31. }
  32. if( $rtn_found == true ) {
  33. return $rtn_value;
  34. } else {
  35. return $id;
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement