Changeset 524 for trunk/dictionary.php


Ignore:
Timestamp:
Feb 20, 2013, 9:40:53 PM (12 years ago)
Author:
chronos
Message:
  • Přidáno: Nastavení předvolené verze klienta pro překládání v profilu překladatelů.
  • Přidáno: Vlastní text v profilu uživatele.
  • Upraveno: Nyní lze veřejně zobrazovat profily překladatelů.
  • Opraveno: Na některých místech opraveno použití id originálního jazyka textů.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dictionary.php

    r507 r524  
    5353  {
    5454    $_SESSION['language'] = $User->Language;
    55   } else $_SESSION['language'] = 2;
     55  } else   {
     56    $LanguageId = reset($LanguageList);
     57    $_SESSION['language'] = $LanguageId['Id'];
     58  }     
    5659}
    5760if(array_key_exists('language', $_GET)) $_SESSION['language'] = LoadLanguageIdParameter();
     
    9598      'Původní anglické slovo:</td><td><input type="text" name="Original" /></td></tr>'.
    9699      '<tr><td>Přeložené:</td><td><input type="text" name="Translated" /></td></tr>'.
    97       '<tr><td>Popis:</td><td><input type="text" name="Description" /></td></tr>'.
     100      '<tr><td>Volitelný popis:</td><td><input type="text" name="Description" /></td></tr>'.
    98101      '<tr><td colspan="2"><input type="submit" value="Uložit" /></td></tr>'.
    99102      '</td></tr></table>'.
     
    105108      if(array_key_exists('Original', $_POST) and array_key_exists('Translated', $_POST) and array_key_exists('Description', $_POST))
    106109      {       
    107         $DbResult = $System->Database->query('SELECT * FROM `Dictionary` WHERE `Text` = "'.$_POST['Original'].'" AND `Language`=0');
     110        $DbResult = $System->Database->query('SELECT * FROM `Dictionary` WHERE `Text` = "'.$_POST['Original'].'" AND `Language`= '.$Config['OriginalLanguage']);
    108111        if($DbResult->num_rows > 0)
    109112        {
     
    115118          $DbRow = $DbResult->fetch_row();
    116119          $Entry = $DbRow[0] + 1;
    117           $System->Database->query('INSERT INTO `Dictionary` ( `Text` , `Entry` , `Description` , `User`, `Language` ) VALUES ("'.$_POST['Original'].'", "'.$Entry.'", "", NULL, 0);');
     120          $System->Database->query('INSERT INTO `Dictionary` ( `Text` , `Entry` , `Description` , `User`, `Language` ) VALUES ("'.$_POST['Original'].'", "'.$Entry.'", "", NULL, '.$Config['OriginalLanguage'].');');
    118121        }
    119122     
     
    137140      $DbResult = $System->Database->query('SELECT * FROM `Dictionary` WHERE `User`='.$User->Id.' AND `Entry`='.$_GET['entry'].' AND `Language`='.$_SESSION['language']);
    138141      $DbRow = $DbResult->fetch_assoc();
    139       $DbResult = $System->Database->query('SELECT * FROM `Dictionary` WHERE (`User` IS NULL) AND (`Entry`='.$_GET['entry'].') AND (`Language`=0)');
     142      $DbResult = $System->Database->query('SELECT * FROM `Dictionary` WHERE (`User` IS NULL) AND (`Entry`='.$_GET['entry'].') AND (`Language`= '.$Config['OriginalLanguage'].')');
    140143      $DbRow2 = $DbResult->fetch_assoc();
    141144      $Output .= '<form action="dictionary.php?action=save" method="post">'.
     
    169172    if($Language['Enabled'] == 1)
    170173    {
    171       if($Language['Id'] == $_SESSION['language']) $Output .= '<strong>';
    172       $Output .= ' <a href="?language='.$Language['Id'].'">'.$Language['Name'].'</a>';
    173       if($Language['Id'] == $_SESSION['language']) $Output .= '</strong>';
     174        $Lang = ' <a href="?language='.$Language['Id'].'">'.$Language['Name'].'</a>';
     175      if($Language['Id'] == $_SESSION['language']) $Output .= '<strong>'.$Lang.'</strong> ';
     176        else $Output .= $Lang;
    174177    }
    175178  $Output .= '</td></tr>'.
     
    179182  if($Search <> '')
    180183  {
    181     $sql = 'SELECT `User`.`Name` AS `UserName`, `User`. `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'].' WHERE LOWER(`T1`.`Text`) LIKE LOWER("%'.$Search.'%") OR LOWER(`T1`.`Description`) LIKE LOWER("%'.$Search.'%") ) AS `T3` JOIN `User` ON `User`.`ID` = `T3`.`User` WHERE `T3`.`Language` = 0';
    182   } 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';
     184    $sql = 'SELECT `User`.`Name` AS `UserName`, `User`. `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'].' WHERE LOWER(`T1`.`Text`) LIKE LOWER("%'.$Search.'%") OR LOWER(`T1`.`Description`) LIKE LOWER("%'.$Search.'%") ) AS `T3` JOIN `User` ON `User`.`ID` = `T3`.`User` WHERE `T3`.`Language` = '.$Config['OriginalLanguage'];
     185  } 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` = '.$Config['OriginalLanguage'];
    183186
    184187  $DbResult = $System->Database->query('SELECT COUNT(*) FROM ('.$sql.') AS `T1`');
Note: See TracChangeset for help on using the changeset viewer.