Changeset 393 for trunk/dictionary.php
- Timestamp:
- Mar 17, 2010, 1:21:49 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dictionary.php
r379 r393 3 3 include('includes/global.php'); 4 4 5 function GetIDbyName($Table)5 function WriteTranslatNames($Text,$mode) 6 6 { 7 global $TranslationTree; 8 9 foreach($TranslationTree as $TableID => $Value) 10 { 11 //echo $Value['TablePrefix'].'='.$Table.'<br>'; 12 if ($Value['TablePrefix'] == $Table) return $TableID; 13 } 14 } 15 16 function GetTranslatNames($Text) 17 { 18 global $Database, $mode; 19 20 if ($mode == 0) echo ('..Přesné'); 7 8 if ($mode == 0) echo ('..Nalezené názvy jmen věcí, míst, postav'); 21 9 if ($mode == 1) echo ('..Všechny přeložené'); 22 10 if ($mode == 2) echo ('..Nepřeložené'); 23 echo('<div style="overflow: auto; width: 100%; height: 345px;"><table width="98%" class="BaseTable">'); 24 echo('<tr><th>Originál</th>'.'<th>Překlad</th>'); 11 echo('<table width="98%" class="BaseTable">'); 12 echo('<tr><th>Originál</th>'.'<th>Překlad</th></tr>'); 13 14 25 15 $TablesColumn = array 26 16 ( … … 31 21 'TextAreaTriggerTeleport' => 'Name', 32 22 'TextAreaTriggerTavern' => 'Name', 23 'Dictionary' => 'Text', 33 24 ); 34 /* $TablesID = array('gameobject' => 5, 35 'creature' => 6, 36 'item' => 4, 37 'transports' => 'Name', 38 'areatrigger_teleport' => 'Name', 39 'areatrigger_tavern' => 'Name',); */ 25 26 $buff = GetTranslatNames($Text,$mode,$TablesColumn); 40 27 41 foreach($TablesColumn as $Table => $Column) 42 { 43 $sql = 'SELECT `ID`,`'.$Column.'`, (SELECT `Name` FROM `'.$Table.'` AS `T` WHERE `O`.`Entry` = `T`.`Entry` AND `Language` <> 0 LIMIT 1) AS `Tran` FROM `'.$Table.'` AS `O` WHERE '; 44 $groupby = ' GROUP BY `'.$Column.'`'; 45 46 $ArrStr = explode(' ', $Text); 47 $where = '`Language` = 0 '; 48 if ($mode == 1) $where .= ' AND EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE (`Sub`.`Language` <> 0) AND (`Sub`.`Entry` = `O`.`Entry`))'; 49 if ($mode == 2) $where .= ' AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE (`Sub`.`Language` <> 0) AND (`Sub`.`Entry` = `O`.`Entry`))'; 50 $where .= ' AND ('; 51 52 for($i = 0; $i < count($ArrStr); $i++) 53 { 54 if (strpos($ArrStr[$i],'\'s') > 0) $ArrStr[$i] = substr($ArrStr[$i],0,strlen($ArrStr[$i])-4); 55 if (strpos($ArrStr[$i],',') > 0) $ArrStr[$i] = substr($ArrStr[$i],0,strlen($ArrStr[$i])-1); 56 if (strpos($ArrStr[$i],'.') > 0) $ArrStr[$i] = substr($ArrStr[$i],0,strlen($ArrStr[$i])-1); 57 if (strpos($ArrStr[$i],'!') > 0) $ArrStr[$i] = substr($ArrStr[$i],0,strlen($ArrStr[$i])-1); 58 if (strpos($ArrStr[$i],'?') > 0) $ArrStr[$i] = substr($ArrStr[$i],0,strlen($ArrStr[$i])-1); 59 60 if (strlen($ArrStr[$i]) > 4) 61 $where .= '(`O`.`'.$Column.'` LIKE "%'.addslashes($ArrStr[$i]).'%") OR '; 62 } 63 $where = substr($where,0,strlen($where)-4); 64 $where .= ')'; 65 echo('</tr>'); 66 67 $ID = $Database->SQLCommand($sql.$where.$groupby); 68 while($Line = mysql_fetch_assoc($ID)) 69 { 28 // $buff[] = array($Line['ID'],GetIDbyName($Table),$Line[$Column],$Line['Tran']); 29 foreach($buff as $Line) { 70 30 if ($mode == 0) 71 31 { 72 if (strpos(strtolower($Text), strtolower($Line[ $Column])) > 0)73 { 74 echo('<tr><td>'.$Line[ $Column].'</td>');75 if ($Line[ 'Tran'] <> '') echo('<td>'.$Line['Tran'].'</td></tr>');76 else echo('<td><a target="_NEW2" href="form.php?group='. GetIDbyName($Table).'&ID='.$Line['ID'].'">Překládat</a></td></tr>');32 if (strpos(strtolower($Text), strtolower($Line[2])) > 0) 33 { 34 echo('<tr><td>'.$Line[2].'</td>'); 35 if ($Line[3] <> '') echo('<td><a target="_NEW2" href="form.php?group='.$Line[1].'&ID='.$Line[0].'">'.$Line[3].'</a></td></tr>'); 36 else echo('<td><a target="_NEW2" href="form.php?group='.$Line[1].'&ID='.$Line[0].'">Překládat</a></td></tr>'); 77 37 } 78 38 } else 79 39 { 80 echo('<tr><td>'.$Line[ $Column].'</td>');81 if ($Line[ 'Tran'] <> '') echo('<td>'.$Line['Tran'].'</td></tr>');82 else echo('<td><a target="_NEW2" href="form.php?group='. GetIDbyName($Table).'&ID='.$Line['ID'].'">Překládat</a></td></tr>');40 echo('<tr><td>'.$Line[2].'</td>'); 41 if ($Line[3] <> '') echo('<td><a target="_NEW2" href="form.php?group='.$Line[1].'&ID='.$Line[0].'">'.$Line[3].'</a></td></tr>'); 42 else echo('<td><a target="_NEW2" href="form.php?group='.$Line[1].'&ID='.$Line[0].'">Překládat</a></td></tr>'); 83 43 } 84 85 } 86 echo('</table> </div>');44 } 45 46 echo('</table>'); 87 47 } 88 48 … … 119 79 foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) 120 80 $Text .= ' '.$Line[$TextItem['Column']]; 121 GetTranslatNames($Text);81 WriteTranslatNames($Text,$mode); 122 82 } 123 83 } else
Note:
See TracChangeset
for help on using the changeset viewer.