Changeset 127 for trunk/comparison.php


Ignore:
Timestamp:
Feb 23, 2009, 1:18:38 PM (15 years ago)
Author:
george
Message:
  • Opraveno: Další validace kódů XHTML strict.
  • Upraveno: Vzhled tabulek upraven na třídu BaseTable. Zobrazování stylů v prohlížeči IE7.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/comparison.php

    r83 r127  
    22
    33include('includes/global.php');   
    4 
    54ShowPage();
    65
    7 echo ('Text je porovnáván vždy ku předešlému (vlevo). Změny jsou zvýrazněny <span id="edit">barvou.</span><br><br>');
     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 />');
    87
    9         function CompareString($String1, $String2) {
    10                 //TODO: barevné porovnání
    11                 //strcasecmp($String1, $String2) == 0 je totožné
    12         //      echo $String1.'<br><br>';
    13                 $ArrStr1 = explode(' ',$String1);
    14                 $ArrStr2 = explode(' ',$String2);
     8function CompareString($String1, $String2)
     9{
     10  //TODO: barevné porovnání
     11  //strcasecmp($String1, $String2) == 0 je totožné
     12  //    echo $String1.'<br /><br />';
     13  $ArrStr1 = explode(' ', $String1);
     14  $ArrStr2 = explode(' ', $String2);
    1515               
    16                 for($i = 0;$i<count($ArrStr1);$i++) {
    17                   if (isset($ArrStr2[$i])) {
    18                         if ($ArrStr1[$i] == $ArrStr2[$i]) {
    19                                 echo $ArrStr1[$i].' ';
    20                         } else {
    21                                 $find = false;
    22                                 for($j = 0;$j<count($ArrStr2);$j++) {
    23                                   if (($ArrStr1[$i] == $ArrStr2[$j]) and ($find == false)) {
    24                                         echo $ArrStr1[$i].' ';
    25                                         $find = true;
    26                                   }
    27                                 }
    28                                 if ($find == false)
    29                                         echo '<span id="edit">'.$ArrStr1[$i].' </span>';
    30                         }
    31                   } else echo '<span id="edit">'.$ArrStr1[$i].' </span>';
     16  for($i = 0; $i < count($ArrStr1); $i++)
     17  {
     18        if(isset($ArrStr2[$i]))
     19        {
     20          if($ArrStr1[$i] == $ArrStr2[$i])
     21          {
     22                echo($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                        echo($ArrStr1[$i].' ');
     31                        $find = true;
     32                  }
    3233                }
    33         //      echo $ArrStr1[0];
    34                
    35         }
     34                if($find == false)
     35                  echo('<span class="edit">'.$ArrStr1[$i].' </span>');
     36          }
     37        } else echo('<span class="edit">'.$ArrStr1[$i].' </span>');
     38  }
     39  //    echo $ArrStr1[0];
     40}
    3641
    3742if(array_key_exists('group', $_GET)) $GroupId = $_GET['group']; else $GroupId = 1;
     
    4247{
    4348  $Textentry = $_GET['entry']; 
    44 
    45 
    46         if ((array_key_exists('ID1', $_GET)) and ($_GET['ID1'] <> -1)) { //porovnání pouze 2 textů
    47                 $TextID1 = $_GET['ID1']; 
    48                 $TextID2 = $_GET['ID2']; 
    49                 $WhereID = " AND (ID = $TextID1 OR ID = $TextID2 OR Language = 0)";     
    50         } else $WhereID = '';
     49  if((array_key_exists('ID1', $_GET)) and ($_GET['ID1'] <> -1))  //porovnání pouze 2 textů
     50  {
     51        $TextID1 = $_GET['ID1']; 
     52        $TextID2 = $_GET['ID2']; 
     53        $WhereID = " AND (ID = $TextID1 OR ID = $TextID2 OR Language = 0)";     
     54  } else $WhereID = '';
    5155
    5256  $DataID = $Database->SQLCommand('SELECT * FROM '.$Table.' Where entry = '.$Textentry.$WhereID.' ORDER BY Language');
    5357  $i = 0;
    54   while($Line = mysql_fetch_assoc($DataID)) {
     58  while($Line = mysql_fetch_assoc($DataID))
     59  {
    5560        $BuffLine[$i] = $Line;
    56         $i = $i+1;     
     61        $i = $i + 1;   
    5762  }
    5863 // if(!$Line) die('Překlad nenalezen.');
    5964  $Line = $BuffLine;
    60   $i = $i-1;
    61   echo('Počet porovnávaných textů: <b>'.$i.'</b><br> ');
     65  $i = $i - 1;
     66  echo('Počet porovnávaných textů: <strong>'.$i.'</strong><br /> ');
    6267
    63   echo('
    64   <b>Číslo textu: <a href="http://www.wowhead.com/?quest='.$Textentry.'">'.$Textentry.'</a></b>
    65  
    66      <table border="1" cellpadding="1" cellspacing="0">
    67       <tr>');
    68     echo (' <th>ID textu</th>');
    69           foreach($Line as $Index => $LineItem) {
    70         echo ('<td><a href="form.php?group='.$GroupId.'&amp;ID='.$LineItem['ID'].'">'.$LineItem['ID'].'</a></td>');
    71       }
    72         echo('</tr>');
    73     echo (' <th>Převzato</th>');
    74           foreach($Line as $Index => $LineItem) {
    75         echo ('<td><a href="form.php?group='.$GroupId.'&amp;ID='.$LineItem['Take'].'">'.$LineItem['Take'].'</a></td>');
    76       }
    77         echo('</tr>');
    78     echo (' <th>Přeložil</th>');
    79           foreach($Line as $Index => $LineItem) {
    80             $LineUser = mysql_fetch_array($Database->SQLCommand('SELECT * FROM user WHERE id = '.$LineItem['User']));
    81         echo ('<th>'.$LineUser['user'].'</th>');
    82       }
    83         echo('</tr>');
    84     echo (' <th>Jazyk</th>');
    85           foreach($Line as $Index => $LineItem) {
    86         echo ('<td>'); WriteLanguagesWithoutSel($LineItem['Language']); echo('</td>');
    87       }
    88         echo('</tr>');
     68  echo('<strong>Číslo textu: <a href="http://www.wowhead.com/?quest='.$Textentry.'">'.$Textentry.'</a></strong>'.
     69    '<table class="BaseTable">');
     70  echo('<tr><th>Přeložil</th>');
     71  foreach($Line as $Index => $LineItem)
     72  {
     73        $LineUser = mysql_fetch_array($Database->SQLCommand('SELECT * FROM user WHERE id = '.$LineItem['User']));
     74    echo('<th>'.$LineUser['user'].'</th>');
     75  }
     76  echo('</tr>');
     77  echo('<tr>');
     78  echo('<th>ID textu</th>');
     79  foreach($Line as $Index => $LineItem)
     80  {
     81        echo('<td><a href="form.php?group='.$GroupId.'&amp;ID='.$LineItem['ID'].'">'.$LineItem['ID'].'</a></td>');
     82  }
     83  echo('</tr>');
     84  echo('<tr><th>Převzato</th>');
     85  foreach($Line as $Index => $LineItem)
     86  {
     87        echo('<td><a href="form.php?group='.$GroupId.'&amp;ID='.$LineItem['Take'].'">'.$LineItem['Take'].'</a></td>');
     88  }
     89  echo('</tr>');
     90  echo('<tr><th>Jazyk</th>');
     91  foreach($Line as $Index => $LineItem)
     92  {
     93        echo('<td>');
     94        WriteLanguagesWithoutSel($LineItem['Language']);
     95        echo('</td>');
     96  }
     97  echo('</tr>');
    8998  foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)
    9099  {         
    91         if ($Line[0][$TextItem['Column']] <> '')  {
    92         echo('<tr>
    93         <th>'.$TextItem['Name'].'</th>');
    94           for ($i = 0; $i < count($Line); $i++) {
    95         if ($i > 1) {
    96           echo ('<td>');
    97           CompareString($Line[$i][$TextItem['Column']],$Line[$i-1][$TextItem['Column']]);
    98                   echo ('</td>');
    99                 } else echo ('<td>'.$Line[$i][$TextItem['Column']].'</td>');
     100        if($Line[0][$TextItem['Column']] <> '')
     101        {
     102          echo('<tr><th>'.$TextItem['Name'].'</th>');
     103          for($i = 0; $i < count($Line); $i++)
     104          {
     105        if($i > 1)
     106                {
     107          echo('<td>');
     108          CompareString($Line[$i][$TextItem['Column']],$Line[$i - 1][$TextItem['Column']]);
     109                  echo('</td>');
     110                } else echo('<td>'.$Line[$i][$TextItem['Column']].'</td>');
    100111      }
    101112    echo ('</tr>');
    102113    }
    103114  }
    104   echo('</table></div>');
    105  
    106  
    107  
     115  echo('</table>'); 
    108116} else
    109117{
Note: See TracChangeset for help on using the changeset viewer.