Changeset 165


Ignore:
Timestamp:
Mar 19, 2009, 7:34:47 PM (16 years ago)
Author:
maron
Message:

Vylepšení slovníku názvů

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dictionary.php

    r161 r165  
    33include('includes/global.php');
    44
     5function GetIDbyName($Table) {
     6        global $TranslationTree;
     7        foreach($TranslationTree as $TableID => $Value) {
     8                //echo $Value['TablePrefix'].'='.$Table.'<br>';
     9        if ($Value['TablePrefix'] == $Table) return $TableID;
     10        }
     11}
     12
    513
    614function GetTranslatNames($Text) {
    7   global $Database;
     15  global $Database,$mode;
    816 
    9         echo('Přeložené názvy věci, postav, a herních objektů a další k tomuto překladu
    10         <div style="overflow: auto; width: 100%; height: 345px;"><table width="98%" class="BaseTable">');
     17        echo('<div style="overflow: auto; width: 100%; height: 345px;"><table width="98%" class="BaseTable">');
    1118        echo('<tr><th>Originál</th>'.'<th>Překlad</th>');
    12  $Tables = array('gameobject' => 'Name',
     19 $TablesColumn = array('gameobject' => 'Name',
    1320  'creature' => 'name',
    1421  'item' => 'Name',
     
    1623  'areatrigger_teleport' => 'Name',
    1724  'areatrigger_tavern' => 'Name',);
    18  foreach($Tables as $Table => $Column) {
     25 /* $TablesID = array('gameobject' => 5,
     26  'creature' => 6,
     27  'item' => 4,
     28  'transports' => 'Name',
     29  'areatrigger_teleport' => 'Name',
     30  'areatrigger_tavern' => 'Name',); */
    1931 
    20   $sql = 'SELECT '.$Column.',(SELECT Name FROM '.$Table.' as T WHERE O.entry = T.entry AND Language <> 0 LIMIT 1) as tran
     32 
     33 
     34 foreach($TablesColumn as $Table => $Column) {
     35 
     36  $sql = 'SELECT ID,'.$Column.',(SELECT Name FROM '.$Table.' as T WHERE O.entry = T.entry AND Language <> 0 LIMIT 1) as tran
    2137   FROM '.$Table.' as O WHERE ';
    2238  $groupby = ' GROUP BY '.$Column;
    2339 
    2440  $ArrStr = explode(' ', $Text);
    25   $where = 'Language = 0 AND
    26   EXISTS(SELECT 1 FROM '.$Table.' AS sub WHERE (sub.Language <> 0) AND (sub.entry = O.entry))
    27    AND (';
     41  $where = 'Language = 0 ';
     42  if ($mode == 1) $where .= ' AND EXISTS(SELECT 1 FROM '.$Table.' AS sub WHERE (sub.Language <> 0) AND (sub.entry = O.entry))';
     43  $where .= ' AND (';
     44
    2845  for($i = 0; $i < count($ArrStr); $i++)
    2946  {
     
    3855        $ID = $Database->SQLCommand($sql.$where.$groupby);
    3956        while($Line = mysql_fetch_assoc($ID)) {
    40         echo('<tr>
    41       <td>'.$Line[$Column].'</td>
    42       <td>'.$Line['tran'].'</td>
    43       ');
    44                 echo('</tr>');
     57        if ($mode == 0) {
     58                if (in_array($Line[$Column],$ArrStr)) {
     59                         echo('<tr><td>'.$Line[$Column].'</td>');
     60                         if ($Line['tran'] <> '') echo('<td>'.$Line['tran'].'</td></tr>');
     61                         else echo('<td><a target="_NEW2"
     62                          href="form.php?group='.GetIDbyName($Table).'&amp;ID='.$Line['ID'].'">Překládat</a></td></tr>');
     63                }
     64        } else {
     65                echo('<tr><td>'.$Line[$Column].'</td><td>'.$Line['tran'].'</td></tr>');
     66        }
    4567        }
    4668 }
     
    6688 
    6789        if(array_key_exists('group', $_GET)) $GroupId = $_GET['group']; else $GroupId = 1;
     90        if(array_key_exists('mode', $_GET)) $mode = $_GET['mode']; else $mode = 0; //0 = přesné názvy, 1=všechny názvy
    6891        $Table = $TranslationTree[$GroupId]['TablePrefix'];
    69         if(array_key_exists('action', $_GET)) $Action = $_GET['action']; else $Action = '';
    7092
    7193        if(array_key_exists('ID', $_GET)) {
    7294                $TextID = $_GET['ID']; 
    73 
     95                echo ('Přeložené názvy vztahující se k překladu: <a target="_NEW" href="form.php?group='.$GroupId.'&amp;ID='.$TextID.'">'.$TextID.'</a><br />'.
     96        '<a href="?mode=1&amp;group='.$GroupId.'&amp;ID='.$TextID.'" title="Zobrazit všechny podobné výsledky">Všechny výsledky</a> '.
     97        '<a href="?mode=0&amp;group='.$GroupId.'&amp;ID='.$TextID.'" title="Zobrazit pouze přesné výsledky">Přesné výsledky</a> ');
    7498                $Line = mysql_fetch_assoc($Database->SQLCommand('SELECT * FROM '.$Table.' Where ID = '.$TextID));
    7599                if(!$Line) die('Překlad nenalezen.');
Note: See TracChangeset for help on using the changeset viewer.