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