Changeset 160 for trunk/dictionary.php


Ignore:
Timestamp:
Mar 18, 2009, 7:52:32 PM (16 years ago)
Author:
maron
Message:

Slovník vyhledávající názvy herních objedktů, předmětů, osob podle překladu

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dictionary.php

    r85 r160  
    22
    33include('includes/global.php');
     4
     5
     6function GetTranslatNames($Text) {
     7  global $Database;
     8 
     9        echo('Přeložené názvy věci, postav, a herních objektů k tomuto překladu
     10        <div style="overflow: auto; width: 100%; height: 345px;"><table width="98%" class="BaseTable">');
     11        echo('<tr><th>Originál</th>'.'<th>Překlad</th>');
     12 $Tables = array('gameobject' => 'Name', 'creature' => 'name', 'item' => 'Name');
     13 foreach($Tables as $Table => $Column) {
     14 
     15  $sql = 'SELECT *,(SELECT Name FROM '.$Table.' as T WHERE O.entry = T.entry AND Language <> 0 LIMIT 1) as tran
     16   FROM '.$Table.' as O WHERE ';
     17  $groupby = ' GROUP BY '.$Column;
     18 
     19  $ArrStr = explode(' ', $Text);
     20  $where = 'Language = 0 AND
     21  EXISTS(SELECT 1 FROM '.$Table.' AS sub WHERE (sub.Language <> 0) AND (sub.entry = O.entry))
     22   AND (';
     23  for($i = 0; $i < count($ArrStr); $i++)
     24  {
     25        if (strpos($ArrStr[$i],'\'s') > 0) $ArrStr[$i] = substr($ArrStr[$i],0,strlen($ArrStr[$i])-4);
     26        if (strlen($ArrStr[$i]) > 4)
     27        $where .= 'O.'.$Column.' LIKE "%'.addslashes($ArrStr[$i]).'%" OR ';
     28  }
     29  $where = substr($where,0,strlen($where)-4);
     30  $where .= ')';
     31        echo ('</tr>');
     32
     33        $ID = $Database->SQLCommand($sql.$where.$groupby);
     34        while($Line = mysql_fetch_assoc($ID)) {
     35        echo('<tr>
     36      <td>'.$Line[$Column].'</td>
     37      <td>'.$Line['tran'].'</td>
     38      ');
     39                echo('</tr>');
     40        }
     41 }
     42        echo('</table></div>');
     43}
     44
    445
    546echo('<?xml version="1.0" encoding="'.$Config['Web']['Charset'].'"?>
     
    849<head>
    950<meta http-equiv="content-type" content="text/html; charset=utf-8" />
    10 <link rel="stylesheet" href="'.$Config['Web']['BaseURL'].'style.css" type="text/css" media="all" />
     51<link rel="stylesheet" href="'.$Config['Web']['BaseURL'].'style/style.css" type="text/css" media="all" />
    1152<script type="text/javascript" src="'.$Config['Web']['BaseURL'].'global.js"></script>
    1253<link rel="SHORTCUT ICON" href="'.$Config['Web']['BaseURL'].'images/favicon.ico" />
     
    1556<body style="margin: 0px; font-family: Verdana, Arial, Sans-Serif;">');
    1657 
     58 
     59 
     60if (array_key_exists('group',$_GET)) { 
     61 
     62        if(array_key_exists('group', $_GET)) $GroupId = $_GET['group']; else $GroupId = 1;
     63        $Table = $TranslationTree[$GroupId]['TablePrefix'];
     64        if(array_key_exists('action', $_GET)) $Action = $_GET['action']; else $Action = '';
     65
     66        if(array_key_exists('ID', $_GET)) {
     67                $TextID = $_GET['ID']; 
     68
     69                $Line = mysql_fetch_assoc($Database->SQLCommand('SELECT * FROM '.$Table.' Where ID = '.$TextID));
     70                if(!$Line) die('Překlad nenalezen.');
     71               
     72                $Text = '';
     73                foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)
     74                        $Text .= ' '.$Line[$TextItem['Column']];
     75                                GetTranslatNames($Text);
     76        }
     77       
     78} else { 
    1779if(array_key_exists('insert', $_GET))
    1880{
     
    67129  $sql = "SELECT * FROM `dictionary`";
    68130}
    69 echo('<table border="1" cellpadding="2" cellspacing="0" width="100%">
     131echo('<table width="98%" class="BaseTable">
    70132  <tr><th>Eng</th>
    71133  <th>Cze</th>
     
    76138  echo('<tr>
    77139  <td>'.$Line['AJWord'].'</td>
    78   <th>'.$Line['CZWord'].'</th>
     140  <td><strong>'.$Line['CZWord'].'</strong></td>
    79141  <td>'.$Line['description'].'</td></tr>');
    80142}
     
    83145echo('</div></td></tr>');
    84146
    85 echo('</table></form></body></html>');
     147echo('</table></form>');
     148
     149}
     150
     151echo ('</body></html>');
    86152
    87153?>
Note: See TracChangeset for help on using the changeset viewer.