Changeset 550


Ignore:
Timestamp:
Jun 18, 2013, 8:56:09 PM (11 years ago)
Author:
chronos
Message:
  • Upraveno: Část týkající se překládání přepracována na aplikační modul.
Location:
trunk
Files:
2 added
3 edited
4 moved

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Dictionary/Dictionary.php

    r549 r550  
    203203      foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)
    204204        $Text .= ' '.$Line[$TextItem['Column']];
    205       $Output .= WriteTranslatNames($Text, $mode);
     205      $Output .= $this->WriteTranslatNames($Text, $mode);
    206206    }
    207207  } 
  • trunk/Modules/Translation/Comparison.php

    r546 r550  
    11<?php
    22
    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)
     3class PageTranslationComparison extends Page
    84{
    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 />';
    1545   
    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.'&amp;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.'&amp;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        }
    40113}
    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.'&amp;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.'&amp;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 
  • trunk/Modules/Translation/Form.php

    r546 r550  
    11<?php
    22
    3 include('includes/global.php');   
    4 
    5 function ColorNames($Text, $names)
    6 {
    7    // $buff[] = array($Line['ID'],GetIDbyName($Table),$Line[$Column],$Line['Tran']);
    8   foreach($names as $Line) {
    9    if ($Line[3] <> '') {
    10      $Text = str_replace($Line[2],'<span Title="Byl nalezen překlad: '.$Line[3].'" class="edit">'.$Line[2].'</span>',$Text);
    11      $Text = str_replace(strtolower($Line[2]),'<span Title="Byl nalezen překlad: '.$Line[3].'" class="edit">'.$Line[2].'</span>',$Text);
    12    } else {
    13        $Text = str_replace($Line[2],'<span title="Jméno bylo nalezeno v názvech a můžete ho přeložit. Začnete kliknutím na: Vyhledat v názvech" class="edit">'.$Line[2].'</span>',$Text);
    14        $Text = str_replace(strtolower($Line[2]),'<span title="Jméno bylo nalezeno v názvech a můžete ho přeložit. Začnete kliknutím na: Vyhledat v názvech" class="edit">'.$Line[2].'</span>',$Text);
    15      }
    16   }
    17   return $Text;
    18 }
    19 
    20 $Output = '';
     3class PageTranslationForm extends Page
     4{
     5        function ColorNames($Text, $names)
     6        {
     7                // $buff[] = array($Line['ID'],GetIDbyName($Table),$Line[$Column],$Line['Tran']);
     8                foreach($names as $Line) {
     9                        if ($Line[3] <> '') {
     10                                $Text = str_replace($Line[2],'<span Title="Byl nalezen překlad: '.$Line[3].'" class="edit">'.$Line[2].'</span>',$Text);
     11                                $Text = str_replace(strtolower($Line[2]),'<span Title="Byl nalezen překlad: '.$Line[3].'" class="edit">'.$Line[2].'</span>',$Text);
     12                        } else {
     13                                $Text = str_replace($Line[2],'<span title="Jméno bylo nalezeno v názvech a můžete ho přeložit. Začnete kliknutím na: Vyhledat v názvech" class="edit">'.$Line[2].'</span>',$Text);
     14                                $Text = str_replace(strtolower($Line[2]),'<span title="Jméno bylo nalezeno v názvech a můžete ho přeložit. Začnete kliknutím na: Vyhledat v názvech" class="edit">'.$Line[2].'</span>',$Text);
     15                        }
     16                }
     17                return $Text;
     18        }       
     19       
     20        function Show()
     21  {
     22        global $System, $Config, $User, $TranslationTree;
     23        $Output = '';
    2124
    2225$GroupId = LoadGroupIdParameter();
     
    170173        $Output .= '<tr><th>'.$LineAJ['ShortCut'].'</th>';
    171174        else $Output .= '<tr><th>'.$TextItem['Name'].'</th>';
    172       $Output .= '<td>'.str_replace("\n", '<br/>', ColorNames(htmlspecialchars($LineAJ[$TextItem['Column']]),$names)).'</td>
     175      $Output .= '<td>'.str_replace("\n", '<br/>', $this->ColorNames(htmlspecialchars($LineAJ[$TextItem['Column']]),$names)).'</td>
    173176      <td><textarea rows="8" cols="40" onkeydown="ResizeTextArea(this)" class="textedit" id="'.$TextItem['Column'].'" name="'.$TextItem['Column'].'">'.htmlspecialchars($Line[$TextItem['Column']]).'</textarea></td></tr>';
    174177    }
     
    181184  }
    182185} else $Output = ShowMessage('Nebylo zadáno ID.', MESSAGE_CRITICAL);
    183 
    184 ShowPage($Output);
    185 
    186 ?>   
    187 
     186return($Output);
     187  }
     188}
  • trunk/Modules/Translation/Save.php

    r549 r550  
    11<?php
    22
    3 include_once('includes/global.php');
    4 
    5 
     3class PageTranslationSave extends Page
     4{
     5  function Show()
     6  {
     7        global $System, $User, $Config, $TranslationTree;
    68$Output = '';
    79$CompleteText = array('nedokončený', 'dokončený');
     
    215217  } else $Output = ShowMessage('Nezadány požadované údaje.', MESSAGE_CRITICAL);
    216218}
    217          
    218 ShowPage($Output);
    219 
    220 ?>
     219    return($Output);         
     220  }
     221}
  • trunk/Modules/Translation/TranslationList.php

    r549 r550  
    11<?php
    22
    3 include('includes/global.php');
    4 
     3class PageTranslationList extends Page
     4{
    55function ShowFilter($GroupId = 0)
    66{
     
    134134  if($Filter['Text'] != '')
    135135  {
    136     $Items = array('(`ID` LIKE "%'.$Filter['Text'].'%")', '(`Entry` LIKE "%'.$Filter['Text'].'%")');
     136    $Items = array('(`T`.`ID` LIKE "%'.$Filter['Text'].'%")', '(`T`.`Entry` LIKE "%'.$Filter['Text'].'%")');
    137137    if($Filter['Group'] != 0)
    138138    foreach($TranslationTree[$Filter['Group']]['Items'] as $GroupItem)
    139139    if($GroupItem['Visible'] == 1)
    140       $Items[] = '(`'.$GroupItem['Column'].'` LIKE "%'.$Filter['Text'].'%")';
     140      $Items[] = '(`T`.`'.$GroupItem['Column'].'` LIKE "%'.$Filter['Text'].'%")';
    141141    $Filter['SQL'] .= ' AND ('.implode(' OR ', $Items).')';
    142142  }
     
    252252    if($Group['TablePrefix'] != '')
    253253    {
    254       $Filter = ShowFilter($Group['Id']);
     254      $Filter = $this->ShowFilter($Group['Id']);
    255255      $ID = $System->Database->query('SELECT COUNT(*) FROM `'.$Group['TablePrefix'].'` AS `T` WHERE 1 '.$Filter['SQL']);
    256256      $Line = $ID->fetch_row();
     
    376376}
    377377
    378 $Action = GetParameter('action', '');
    379 if($Action == 'filter') $Output = ShowMenu();
    380 else if($Action == 'grouplist') $Output = ShowGroupTypeList();
    381 else if($Action == 'groupadd') $Output = ShowGroupAdd();
    382 else if($Action == 'groupaddfinish') $Output = ShowGroupAddFinish();
    383 else
    384 {
    385   $Filter = ShowFilter();
    386   if($Filter['Group'] > 0) $Output = ShowTranslationList($Filter);
    387     else $Output = ShowGroupList($Filter);
     378function Show()
     379{
     380  $Action = GetParameter('action', '');
     381  if($Action == 'filter') $Output = $this->ShowMenu();
     382  else if($Action == 'grouplist') $Output = $this->ShowGroupTypeList();
     383  else if($Action == 'groupadd') $Output = $this->ShowGroupAdd();
     384  else if($Action == 'groupaddfinish') $Output = $this->ShowGroupAddFinish();
     385  else
     386  {
     387    $Filter = $this->ShowFilter();
     388    if($Filter['Group'] > 0) $Output = $this->ShowTranslationList($Filter);
     389      else $Output = $this->ShowGroupList($Filter);
     390  }
     391  return($Output);
    388392}   
    389 
    390 ShowPage($Output);
    391 
    392 ?>
     393}
  • trunk/includes/Version.php

    r549 r550  
    11<?php
    22
    3 $Revision = 549; // Subversion revision
     3$Revision = 550; // Subversion revision
    44$DatabaseRevision = 543; // Database structure revision
    55$ReleaseTime = '2013-06-18';
  • trunk/includes/global.php

    r549 r550  
    1414// Include application modules
    1515// TODO: Make modules configurable
     16include_once(dirname(__FILE__).'/../Modules/Translation/Translation.php');
    1617include_once(dirname(__FILE__).'/../Modules/AoWoW/AoWoW.php');
    1718include_once(dirname(__FILE__).'/../Modules/Referrer/Referrer.php');
     
    6970  $System->ModuleManager->RegisterModule(new ModuleTeam($System));
    7071  $System->ModuleManager->RegisterModule(new ModuleDictionary($System));
     72  $System->ModuleManager->RegisterModule(new ModuleTranslation($System));
    7173  $System->ModuleManager->StartAll();
    7274}
Note: See TracChangeset for help on using the changeset viewer.