source: trunk/comparison.php@ 376

Last change on this file since 376 was 365, checked in by george, 15 years ago
  • Upraveno: Jména tabulek v databází upraveny na stejná s prvními velkými písmeny.
  • Upraveno: Doplněny SQL uvozovky do mnoha SQL dotazů.
File size: 3.9 KB
Line 
1<?php
2
3include('includes/global.php');
4ShowPage();
5
6echo('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 />');
7
8function CompareString($String1, $String2)
9{
10 $Result = '';
11 //TODO: barevné porovnání
12 //strcasecmp($String1, $String2) == 0 je totožné
13 // echo $String1.'<br /><br />';
14 $ArrStr1 = explode(' ', $String1);
15 $ArrStr2 = explode(' ', $String2);
16
17 for($i = 0; $i < count($ArrStr1); $i++)
18 {
19 if(isset($ArrStr2[$i]))
20 {
21 if($ArrStr1[$i] == $ArrStr2[$i])
22 {
23 $Result .= $ArrStr1[$i].' ';
24 } else
25 {
26 $find = false;
27 for($j = 0; $j < count($ArrStr2); $j++)
28 {
29 if(($ArrStr1[$i] == $ArrStr2[$j]) and ($find == false))
30 {
31 $Result .= $ArrStr1[$i].' ';
32 $find = true;
33 }
34 }
35 if($find == false)
36 $Result .= '<span class="edit">'.$ArrStr1[$i].' </span>';
37 }
38 } else $Result .= '<span class="edit">'.$ArrStr1[$i].' </span>';
39 }
40 // echo $ArrStr1[0];
41 return($Result);
42}
43
44$GroupId = LoadGroupIdParameter();
45$Table = $TranslationTree[$GroupId]['TablePrefix'];
46
47if(array_key_exists('entry', $_GET))
48{
49 $Textentry = $_GET['entry'];
50 if((array_key_exists('ID1', $_GET)) and ($_GET['ID1'] <> -1)) //porovnání pouze 2 textů
51 {
52 $TextID1 = $_GET['ID1'];
53 $TextID2 = $_GET['ID2'];
54 $WhereID = ' AND (ID = '.$TextID1.' OR ID = '.$TextID2.' OR Language = 0)';
55 } else $WhereID = '';
56
57 $DataID = $Database->SQLCommand('SELECT * FROM '.$Table.' Where entry = '.$Textentry.' '.$WhereID.' ORDER BY Language');
58 $i = 0;
59 while($Line = mysql_fetch_assoc($DataID))
60 {
61 $BuffLine[$i] = $Line;
62 $i = $i + 1;
63 }
64 // if(!$Line) die('Překlad nenalezen.');
65 $Line = $BuffLine;
66 $i = $i - 1;
67 echo('Počet porovnávaných textů: <strong>'.$i.'</strong><br /> ');
68
69 echo('<strong>Číslo textu: <a href="http://www.wowhead.com/?quest='.$Textentry.'">'.$Textentry.'</a></strong>'.
70 '<table class="BaseTable">');
71 echo('<tr><th>Přeložil</th>');
72 foreach($Line as $Index => $LineItem)
73 {
74 $LineUser = mysql_fetch_array($Database->SQLCommand('SELECT * FROM `User` WHERE `ID` = '.$LineItem['User']));
75 echo('<th>'.$LineUser['Name'].'</th>');
76 }
77 echo('</tr>');
78 echo('<tr>');
79 echo('<th>ID textu</th>');
80 foreach($Line as $Index => $LineItem)
81 {
82 echo('<td><a href="form.php?group='.$GroupId.'&amp;ID='.$LineItem['ID'].'">'.$LineItem['ID'].'</a></td>');
83 }
84 echo('</tr>');
85 echo('<tr><th>Převzato</th>');
86 foreach($Line as $Index => $LineItem)
87 {
88 echo('<td><a href="form.php?group='.$GroupId.'&amp;ID='.$LineItem['Take'].'">'.$LineItem['Take'].'</a></td>');
89 }
90 echo('</tr>');
91 echo('<tr><th>Jazyk</th>');
92 foreach($Line as $Index => $LineItem)
93 {
94 echo('<td>');
95 WriteLanguagesWithoutSel($LineItem['Language']);
96 echo('</td>');
97 }
98 echo('</tr>');
99 echo('<tr><th>Verze</th>');
100 foreach($Line as $Index => $LineItem)
101 {
102 echo('<td>');
103 echo (GetVersionWOW($LineItem['VersionStart']).' - '.GetVersionWOW($LineItem['VersionEnd']));
104 echo('</td>');
105 }
106 echo('</tr>');
107 foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)
108 {
109 if($Line[0][$TextItem['Column']] <> '')
110 {
111 echo('<tr><th>'.$TextItem['Name'].'</th>');
112 for($i = 0; $i < count($Line); $i++)
113 {
114 if($i > 0)
115 {
116 echo('<td>');
117 echo(str_replace("\n", '<br/>', CompareString($Line[$i][$TextItem['Column']],$Line[$i - 1][$TextItem['Column']])));
118 echo('</td>');
119 } else echo('<td>'.$Line[$i][$TextItem['Column']].'</td>');
120 }
121 echo ('</tr>');
122 }
123 }
124 echo('</table>');
125} else
126{
127 // include 'ListQuests.php';
128 echo('Nebylo zadáno ID <a href="index.php">zpět</a>');
129}
130
131ShowFooter();
132
133?>
134
Note: See TracBrowser for help on using the repository browser.