Changeset 610 for trunk/includes/Locale.php
- Timestamp:
- Nov 26, 2013, 11:16:15 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/Locale.php
r609 r610 108 108 } 109 109 110 function LoadFromDatabase($Database, $Lang uageId)110 function LoadFromDatabase($Database, $LangCode) 111 111 { 112 $this->Texts->Data = array(); 113 $DbResult = $Database->select('Locale', '`Original`, `Translated`', '`Language`='.$LanguageId * 1); 114 while($DbRow = $DbResult->fetch_assoc()) 115 $this->Texts->Data[$DbRow['Original']] = $DbRow['Translated']; 112 $DbResult = $Database->select('Language', '*', 'Code='.$Database->quote($LangCode)); 113 if($DbResult->num_rows > 0) 114 { 115 $Language = $DbResult->fetch_assoc(); 116 $this->Texts->Data = array(); 117 $DbResult = $Database->select('Locale', '`Original`, `Translated`', '`Language`='.$Language['Id']); 118 while($DbRow = $DbResult->fetch_assoc()) 119 $this->Texts->Data[$DbRow['Original']] = $DbRow['Translated']; 120 } 116 121 } 117 122 118 function SaveToDatabase(Database $Database, $Lang uageId)123 function SaveToDatabase(Database $Database, $LangCode) 119 124 { 120 $Database->delete('Locale', '`Language`='.$LanguageId * 1); 121 foreach($this->Texts->Data as $Index => $Item) 122 $Database->query('INSERT INTO `Locale` (`Language`,`Original`,`Translated`) '. 123 'VALUES('.$LanguageId.','.$Database->quote($Index).','.$Database->quote($Item).')'); 125 $DbResult = $Database->select('Language', '*', 'Code='.$Database->quote($LangCode)); 126 if($DbResult->num_rows > 0) 127 { 128 $Language = $DbResult->fetch_assoc(); 129 $Database->delete('Locale', '`Language`='.$Language['Id']); 130 foreach($this->Texts->Data as $Index => $Item) 131 $Database->query('INSERT INTO `Locale` (`Language`,`Original`,`Translated`) '. 132 'VALUES('.$Language['Id'].','.$Database->quote($Index).','.$Database->quote($Item).')'); 133 } 124 134 } 125 135 126 function UpdateToDatabase(Database $Database, $Lang uageId)136 function UpdateToDatabase(Database $Database, $LangCode) 127 137 { 128 foreach($this->Texts->Data as $Index => $Item) 129 { 130 $DbResult = $Database->select('Locale', '*', '`Original` ='.$Database->quote($Index)); 131 if($DbResult->num_rows > 0) 132 $Database->update('Locale', '(`Language`='.($LanguageId * 1).') AND '. 133 '(`Original` ='.$Database->quote($Index).')', array('Translated' => $Item)); 134 else $Database->insert('Locale', array('Language' => $LanguageId * 1, 135 'Original' => $Index, 'Translated' => $Item)); 136 } 138 $DbResult = $Database->select('Language', '*', 'Code='.$Database->quote($LangCode)); 139 if($DbResult->num_rows > 0) 140 { 141 $Language = $DbResult->fetch_assoc(); 142 foreach($this->Texts->Data as $Index => $Item) 143 { 144 $DbResult = $Database->select('Locale', '*', '(`Original` ='.$Database->quote($Index).') AND (`Language`='.($Language['Id']).')'); 145 if($DbResult->num_rows > 0) 146 $Database->update('Locale', '(`Language`='.($Language['Id']).') AND '. 147 '(`Original` ='.$Database->quote($Index).')', array('Translated' => $Item)); 148 else $Database->insert('Locale', array('Language' => $Language['Id'], 149 'Original' => $Index, 'Translated' => $Item)); 150 } 151 } 137 152 } 138 153 }
Note:
See TracChangeset
for help on using the changeset viewer.