Changeset 455 for trunk/dictionary.php


Ignore:
Timestamp:
Apr 13, 2010, 10:03:12 AM (15 years ago)
Author:
george
Message:
  • Upraveno: Přístup k databázi převeden na objektový pomocí rozšířené PHP třídy mysqli. Při práci s databází použít globální objekt $System a jeho prvek $Database ($System->Database->query("SELECT ...");.
  • Upraveno: Při vkládání nové zprávy do Kecátka neprovádět přesměrování, ale rovnou zobrazit výpis. U některých překladatelů toto způsobovalo opakované vložení zprávy.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dictionary.php

    r393 r455  
    55function WriteTranslatNames($Text,$mode)
    66{
    7        
     7 
    88  if ($mode == 0) echo ('..Nalezené názvy jmen věcí, míst, postav');
    99  if ($mode == 1) echo ('..Všechny přeložené');
     
    2626  $buff = GetTranslatNames($Text,$mode,$TablesColumn);
    2727 
    28         // $buff[] = array($Line['ID'],GetIDbyName($Table),$Line[$Column],$Line['Tran']);
     28  // $buff[] = array($Line['ID'],GetIDbyName($Table),$Line[$Column],$Line['Tran']);
    2929  foreach($buff as $Line) {
    3030      if ($mode == 0)
     
    7373  '<a href="?mode=0&amp;group='.$GroupId.'&amp;ID='.$TextID.'" title="Zobrazit pouze přesné výsledky">Přesné</a> '.
    7474  '<a href="?mode=2&amp;group='.$GroupId.'&amp;ID='.$TextID.'" title="Zobrazit všechny nepřeložené">Nepřeložené</a> ');
    75     $Line = mysql_fetch_assoc($Database->SQLCommand('SELECT * FROM '.$Table.' Where ID = '.$TextID));
     75    $DbResult = $System->Database->query('SELECT * FROM '.$Table.' Where ID = '.$TextID);
     76    $Line = $DbResult->fetch_assoc();
    7677    if(!$Line) die('Překlad nenalezen.');
    7778   
     
    102103      if(array_key_exists('Original', $_POST) and array_key_exists('Translated', $_POST) and array_key_exists('Description', $_POST))
    103104      {       
    104         $DbResult = $Database->SQLCommand('SELECT * FROM `Dictionary` WHERE `Text` = "'.$_POST['Original'].'" AND `Language`=0');
    105         if(mysql_num_rows($DbResult) > 0)
    106         {
    107           $DbRow = mysql_fetch_assoc($DbResult);
     105        $DbResult = $System->Database->query('SELECT * FROM `Dictionary` WHERE `Text` = "'.$_POST['Original'].'" AND `Language`=0');
     106        if($DbResult->num_rows > 0)
     107        {
     108          $DbRow = $DbResult->fetch_assoc();
    108109          $Entry = $DbRow['Entry'];
    109110        } else
    110111        {
    111           $DbResult = $Database->SQLCommand('SELECT MAX(`Entry`) FROM `Dictionary`');
    112           $DbRow = mysql_fetch_row($DbResult);
     112          $DbResult = $System->Database->query('SELECT MAX(`Entry`) FROM `Dictionary`');
     113          $DbRow = $DbResult->fetch_row();
    113114          $Entry = $DbRow[0] + 1;
    114           $Database->SQLCommand('INSERT INTO `Dictionary` ( `Text` , `Entry` , `Description` , `User`, `Language` ) VALUES ("'.$_POST['Original'].'", "'.$Entry.'", "", 0, 0);');
     115          $System->Database->query('INSERT INTO `Dictionary` ( `Text` , `Entry` , `Description` , `User`, `Language` ) VALUES ("'.$_POST['Original'].'", "'.$Entry.'", "", 0, 0);');
    115116        }
    116117     
    117         $DbResult = $Database->SQLCommand('SELECT `Id` FROM `Dictionary` WHERE `Entry` = '.$Entry.' AND `Language`='.$_SESSION['language'].' AND `User`='.$User->Id);
     118        $DbResult = $System->Database->query('SELECT `Id` FROM `Dictionary` WHERE `Entry` = '.$Entry.' AND `Language`='.$_SESSION['language'].' AND `User`='.$User->Id);
    118119        if(mysql_num_rows($DbResult) > 0)
    119120        {
    120121          $DbRow = mysql_fetch_assoc($DbResult);
    121           $Database->SQLCommand('UPDATE `Dictionary` SET `Text`="'.$_POST['Translated'].'", `Description` = "'.$_POST['Description'].'" WHERE Id='.$DbRow['Id']);
     122          $System->Database->query('UPDATE `Dictionary` SET `Text`="'.$_POST['Translated'].'", `Description` = "'.$_POST['Description'].'" WHERE Id='.$DbRow['Id']);
    122123        } else     
    123           $Database->SQLCommand('INSERT INTO `Dictionary` ( `Text` , `Entry` , `Description` , `User`, `Language` ) VALUES ("'.$_POST['Translated'].'", "'.$Entry.'", "'.$_POST['Description'].'", '.$User->Id.', '.$_SESSION['language'].')');
     124          $System->Database->query('INSERT INTO `Dictionary` ( `Text` , `Entry` , `Description` , `User`, `Language` ) VALUES ("'.$_POST['Translated'].'", "'.$Entry.'", "'.$_POST['Description'].'", '.$User->Id.', '.$_SESSION['language'].')');
    124125        echo('Záznam byl uložen!');
    125126      } else echo('Nebyly zaslány všechny položky formuláře.');
     
    127128    if(($_GET['action'] == 'remove') and $User->Licence(LICENCE_USER))
    128129    {
    129       $Database->SQLCommand('DELETE FROM `Dictionary` WHERE `User`='.$User->Id.' AND `Language`='.$_SESSION['language'].' AND `Entry`='.$_GET['entry']);
     130      $System->Database->query('DELETE FROM `Dictionary` WHERE `User`='.$User->Id.' AND `Language`='.$_SESSION['language'].' AND `Entry`='.$_GET['entry']);
    130131    } else
    131132    if(($_GET['action'] == 'modify')  and $User->Licence(LICENCE_USER))
    132133    {
    133       $DbResult = $Database->SQLCommand('SELECT * FROM `Dictionary` WHERE `User`='.$User->Id.' AND `Entry`='.$_GET['entry'].' AND `Language`='.$_SESSION['language']);
    134       $DbRow = mysql_fetch_assoc($DbResult);
    135       $DbResult = $Database->SQLCommand('SELECT * FROM `Dictionary` WHERE `User`=0 AND `Entry`='.$_GET['entry'].' AND `Language`=0');
    136       $DbRow2 = mysql_fetch_assoc($DbResult);
     134      $DbResult = $System->Database->query('SELECT * FROM `Dictionary` WHERE `User`='.$User->Id.' AND `Entry`='.$_GET['entry'].' AND `Language`='.$_SESSION['language']);
     135      $DbRow = $DbResult->fetch_assoc();
     136      $DbResult = $System->Database->query('SELECT * FROM `Dictionary` WHERE `User`=0 AND `Entry`='.$_GET['entry'].' AND `Language`=0');
     137      $DbRow2 = $DbResult->fetch_assoc();
    137138      echo('<form action="dictionary.php?action=save" method="post">'.
    138139      '<fieldset><legend>Upravení slova</legend>'.
     
    177178  } else $sql = 'SELECT `User`.`Name` AS `UserName`, `ID` AS `UserID`, `T3`.`Entry`, `T3`.`Original`, `T3`.`Translated`, `T3`.`Description` FROM (SELECT `T2`.`User`, `T1`.Language, `T1`.`Text` AS `Original`, `T2`.`Text` AS `Translated`, `T2`.`Description`, `T1`.`Entry` AS `Entry` FROM `Dictionary` AS `T1` JOIN `Dictionary` AS `T2` ON `T2`.`Entry` = `T1`.`Entry` AND `T2`.`Language` = '.$_SESSION['language'].') AS `T3` JOIN `User` ON `User`.`ID` = `T3`.`User` WHERE `T3`.`Language` = 0';
    178179
    179   $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM ('.$sql.') AS `T1`');
    180   $DbRow = mysql_fetch_row($DbResult);
     180  $DbResult = $System->Database->query('SELECT COUNT(*) FROM ('.$sql.') AS `T1`');
     181  $DbRow = $DbResult->fetch_row();
    181182  $PageList = GetPageList($DbRow[0]); 
    182183
     
    195196
    196197  $sql_page = $sql.$Order['SQL'].$PageList['SQLLimit'];
    197   $ID = $Database->SQLCommand($sql_page);
    198   while($Line = mysql_fetch_assoc($ID))
     198  $DbResult = $System->Database->query($sql_page);
     199  while($Line = $DbResult->fetch_assoc())
    199200  {
    200201    echo('<tr>
Note: See TracChangeset for help on using the changeset viewer.