Changeset 79 for trunk/comparison.php


Ignore:
Timestamp:
Feb 9, 2009, 11:02:09 PM (15 years ago)
Author:
maron
Message:

Zvýrazňování porovnání textů

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/comparison.php

    r78 r79  
    55ShowPage();
    66
     7echo ('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>');
     8
    79        function CompareString($String1, $String2) {
    810                //TODO: barevné porovnání
    9                 //echo $String2;
     11                //strcasecmp($String1, $String2) == 0 je totožné
     12        //      echo $String1.'<br><br>';
     13                $ArrStr1 = explode(' ',$String1);
     14                $ArrStr2 = explode(' ',$String2);
     15               
     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]) {
     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>';
     32                }
     33        //      echo $ArrStr1[0];
     34               
    1035        }
    1136
     
    3459     <table border="1" cellpadding="1" cellspacing="0">
    3560      <tr>');
     61    echo (' <th>ID textu</th>');
     62          foreach($Line as $Index => $LineItem) {
     63        echo ('<td><a href="form.php?group='.$GroupId.'&amp;ID='.$LineItem['ID'].'">'.$LineItem['ID'].'</a></td>');
     64      }
     65        echo('</tr>');
     66    echo (' <th>Převzato</th>');
     67          foreach($Line as $Index => $LineItem) {
     68        echo ('<td><a href="form.php?group='.$GroupId.'&amp;ID='.$LineItem['Take'].'">'.$LineItem['Take'].'</a></td>');
     69      }
     70        echo('</tr>');
    3671    echo (' <th>Přeložil</th>');
    3772          foreach($Line as $Index => $LineItem) {
     
    5085        echo('<tr>
    5186        <th>'.$TextItem['Name'].'</th>');
    52           foreach($Line as $Index => $LineItem) {
    53         echo ('<td>'.htmlspecialchars($LineItem[$TextItem['Column']]).'</td>');
    54         if ($Index > 1)
    55          CompareString(htmlspecialchars($Line[$Index][$TextItem['Column']]),htmlspecialchars($Line[$Index-1][$TextItem['Column']]));
     87          for ($i = 0; $i < count($Line); $i++) {
     88        if ($i >= 1) {
     89          echo ('<td>');
     90          CompareString($Line[$i][$TextItem['Column']],$Line[$i-1][$TextItem['Column']]);
     91                  echo ('</td>');
     92                } else echo ('<td>'.$Line[$i][$TextItem['Column']].'</td>');
    5693      }
    5794    echo ('</tr>');
Note: See TracChangeset for help on using the changeset viewer.