Changeset 816 for trunk/Modules/Translation/Comparison.php
- Timestamp:
- Feb 22, 2015, 11:20:50 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/Translation/Comparison.php
r752 r816 3 3 class PageTranslationComparison extends Page 4 4 { 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 5 function CompareString($String1, $String2) 6 { 7 $Result = ''; 8 //TODO: Implement colored comparison 9 //strcasecmp($String1, $String2) == 0 je totožné 10 // echo $String1.'<br /><br />'; 11 $ArrStr1 = explode(' ', $String1); 12 $ArrStr2 = explode(' ', $String2); 13 14 for($i = 0; $i < count($ArrStr1); $i++) 15 { 16 if(isset($ArrStr2[$i])) 17 { 18 if($ArrStr1[$i] == $ArrStr2[$i]) 19 { 20 $Result .= $ArrStr1[$i].' '; 21 } else 22 { 23 $find = false; 24 for($j = 0; $j < count($ArrStr2); $j++) 25 { 26 if(($ArrStr1[$i] == $ArrStr2[$j]) and ($find == false)) 27 { 28 $Result .= $ArrStr1[$i].' '; 29 $find = true; 30 } 31 } 32 if($find == false) 33 $Result .= '<span class="edit">'.$ArrStr1[$i].' </span>'; 34 } 35 } else $Result .= '<span class="edit">'.$ArrStr1[$i].' </span>'; 36 } 37 return($Result); 38 } 39 40 function Show() 41 { 42 global $TranslationTree; 43 44 44 $Output = ''; 45 45 46 47 46 if($this->System->User->Licence(LICENCE_USER)) 47 { 48 48 $Output = 'Text je porovnáván vždy ku předešlému (vlevo). Změny jsou zvýrazněny <span class="edit">barvou.</span><br /><br />'; 49 50 $GroupId = LoadGroupIdParameter();51 $Table = $TranslationTree[$GroupId]['TablePrefix'];52 53 if(array_key_exists('entry', $_GET))54 {55 $Textentry = $_GET['entry'];56 if((array_key_exists('ID1', $_GET)) and ($_GET['ID1'] <> -1)) //porovnání pouze 2 textů57 {58 $TextID1 = $_GET['ID1'];59 $TextID2 = $_GET['ID2'];60 $WhereID = ' AND ((`'.$Table.'`.`ID` = '.$TextID1.') OR (`'.$Table.'`.`ID` = '.$TextID2.'))';61 } else $WhereID = '';62 63 $DataID = $this->Database->query('SELECT `'.$Table.'`.*, `User`.`Name` AS `UserName`, '.64 '`Language`.`Name` AS `LanguageName` '.65 'FROM '.$Table.' LEFT JOIN `User` ON `User`.`Id` = `'.$Table.'`.`User` '.66 ' LEFT JOIN `Language` ON `Language`.`Id` = `'.$Table.'`.`Language` '.67 'WHERE `Entry` = '.$Textentry.' '.$WhereID.' ORDER BY `Language`');68 while($Line[] = $DataID->fetch_assoc());69 array_pop($Line);70 71 $Output .= 'Počet porovnávaných textů: <strong>'.count($Line).'</strong><br /> ';72 73 $Output .= '<strong>Číslo textu: <a href="http://www.wowhead.com/?quest='.$Textentry.'">'.$Textentry.'</a></strong>'.74 '<table class="BaseTable">'.75 '<tr><th>Přeložil</th>';76 foreach($Line as $Index => $LineItem)77 $Output .= '<th>'.$LineItem['UserName'].'</th>';78 $Output .= '</tr>'.79 '<tr>'.80 '<th>ID textu</th>';81 foreach($Line as $Index => $LineItem)82 $Output .= '<td><a href="form.php?group='.$GroupId.'&ID='.$LineItem['ID'].'">'.$LineItem['ID'].'</a></td>';83 $Output .= '</tr>'.84 '<tr><th>Převzato</th>';85 foreach($Line as $Index => $LineItem)86 $Output .= '<td><a href="form.php?group='.$GroupId.'&ID='.$LineItem['Take'].'">'.$LineItem['Take'].'</a></td>';87 $Output .= '</tr>'.88 '<tr><th>Jazyk</th>';89 foreach($Line as $Index => $LineItem)90 $Output .= '<td>'.$LineItem['LanguageName'].'</td>';91 $Output .= '</tr>'.92 '<tr><th>Verze</th>';93 foreach($Line as $Index => $LineItem)94 $Output .= '<td>'.GetVersionWOW($LineItem['VersionStart']).' - '.GetVersionWOW($LineItem['VersionEnd']).'</td>';95 $Output .= '</tr>';96 foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)97 {98 $writethis = false;99 for($i = 0; $i < count($Line); $i++)100 {101 if($Line[$i][$TextItem['Column']] <> '') $writethis = true;102 }103 if($writethis)104 {105 $Output .= '<tr><th>'.$TextItem['Name'].'</th>';106 for($i = 0; $i < count($Line); $i++)107 {108 if($i > 0)109 {110 $Output .= '<td>';111 $Output .= str_replace("\n", '<br/>', $this->CompareString(htmlspecialchars($Line[$i][$TextItem['Column']]),htmlspecialchars($Line[$i - 1][$TextItem['Column']])));112 $Output .= '</td>';113 } else $Output .= '<td>'.htmlspecialchars($Line[$i][$TextItem['Column']]).'</td>';114 }115 $Output .= '</tr>';116 }117 }118 $Output .= '</table>';119 } else $Output .= ShowMessage('Nebylo zadáno ID.', MESSAGE_CRITICAL);120 } else $Output .= ShowMessage('Porovnávat můžou pouze překladatelé!', MESSAGE_CRITICAL);121 49 122 return($Output); 123 } 50 $GroupId = LoadGroupIdParameter(); 51 $Table = $TranslationTree[$GroupId]['TablePrefix']; 52 53 if(array_key_exists('entry', $_GET)) 54 { 55 $Textentry = $_GET['entry']; 56 if((array_key_exists('ID1', $_GET)) and ($_GET['ID1'] <> -1)) //porovnání pouze 2 textů 57 { 58 $TextID1 = $_GET['ID1']; 59 $TextID2 = $_GET['ID2']; 60 $WhereID = ' AND ((`'.$Table.'`.`ID` = '.$TextID1.') OR (`'.$Table.'`.`ID` = '.$TextID2.'))'; 61 } else $WhereID = ''; 62 63 $DataID = $this->Database->query('SELECT `'.$Table.'`.*, `User`.`Name` AS `UserName`, '. 64 '`Language`.`Name` AS `LanguageName` '. 65 'FROM '.$Table.' LEFT JOIN `User` ON `User`.`Id` = `'.$Table.'`.`User` '. 66 ' LEFT JOIN `Language` ON `Language`.`Id` = `'.$Table.'`.`Language` '. 67 'WHERE `Entry` = '.$Textentry.' '.$WhereID.' ORDER BY `Language`'); 68 while($Line[] = $DataID->fetch_assoc()); 69 array_pop($Line); 70 71 $Output .= 'Počet porovnávaných textů: <strong>'.count($Line).'</strong><br /> '; 72 73 $Output .= '<strong>Číslo textu: <a href="http://www.wowhead.com/?quest='.$Textentry.'">'.$Textentry.'</a></strong>'. 74 '<table class="BaseTable">'. 75 '<tr><th>Přeložil</th>'; 76 foreach($Line as $Index => $LineItem) 77 $Output .= '<th>'.$LineItem['UserName'].'</th>'; 78 $Output .= '</tr>'. 79 '<tr>'. 80 '<th>ID textu</th>'; 81 foreach($Line as $Index => $LineItem) 82 $Output .= '<td><a href="form.php?group='.$GroupId.'&ID='.$LineItem['ID'].'">'.$LineItem['ID'].'</a></td>'; 83 $Output .= '</tr>'. 84 '<tr><th>Převzato</th>'; 85 foreach($Line as $Index => $LineItem) 86 $Output .= '<td><a href="form.php?group='.$GroupId.'&ID='.$LineItem['Take'].'">'.$LineItem['Take'].'</a></td>'; 87 $Output .= '</tr>'. 88 '<tr><th>Jazyk</th>'; 89 foreach($Line as $Index => $LineItem) 90 $Output .= '<td>'.$LineItem['LanguageName'].'</td>'; 91 $Output .= '</tr>'. 92 '<tr><th>Verze</th>'; 93 foreach($Line as $Index => $LineItem) 94 $Output .= '<td>'.GetVersionWOW($LineItem['VersionStart']).' - '.GetVersionWOW($LineItem['VersionEnd']).'</td>'; 95 $Output .= '</tr>'; 96 foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem) 97 { 98 $writethis = false; 99 for($i = 0; $i < count($Line); $i++) 100 { 101 if($Line[$i][$TextItem['Column']] <> '') $writethis = true; 102 } 103 if($writethis) 104 { 105 $Output .= '<tr><th>'.$TextItem['Name'].'</th>'; 106 for($i = 0; $i < count($Line); $i++) 107 { 108 if($i > 0) 109 { 110 $Output .= '<td>'; 111 $Output .= str_replace("\n", '<br/>', $this->CompareString(htmlspecialchars($Line[$i][$TextItem['Column']]),htmlspecialchars($Line[$i - 1][$TextItem['Column']]))); 112 $Output .= '</td>'; 113 } else $Output .= '<td>'.htmlspecialchars($Line[$i][$TextItem['Column']]).'</td>'; 114 } 115 $Output .= '</tr>'; 116 } 117 } 118 $Output .= '</table>'; 119 } else $Output .= ShowMessage('Nebylo zadáno ID.', MESSAGE_CRITICAL); 120 } else $Output .= ShowMessage('Porovnávat můžou pouze překladatelé!', MESSAGE_CRITICAL); 121 122 return($Output); 123 } 124 124 }
Note:
See TracChangeset
for help on using the changeset viewer.