Changeset 40 for branches


Ignore:
Timestamp:
Jan 24, 2009, 5:55:02 PM (16 years ago)
Author:
george
Message:
  • Upraveno: Změna kódování znaků souborů na UTF-8.
Location:
branches/2
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/2/database.php

    r8 r40  
    1212  {
    1313    $this->LastQuery = $Query;
     14    //if(($this->error != ''))
     15    {
     16      //echo('<strong>Database error:</strong> ');
     17      echo($this->error.'<div style="border-bottom-width: 1px; border-bottom-style: solid; padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;"><strong>Query:</strong> '.$Query.'</div>');
     18      //echo('<pre style="font-size: 9px">'); print_r(debug_backtrace()); echo('</pre>');
     19    }
    1420    return(parent::query($Query)); 
    1521  }
  • branches/2/frontend.php

    r9 r40  
    4646  }
    4747
    48   function ShowText($TranslationGroupId, $Edit)
    49   {
    50     if($Edit)
    51     {
    52       // Edit new text
    53       $Output = '<strong>Překlad textů:</strong><table class="TranslationTable">';
    54       foreach($this->System->Modules['Translation']->GetTextList($TranslationGroupId) as $GroupItem)
    55       {
    56         $Output .= '<tr><th>'.$GroupItem['Name'].'</th><td>'.$GroupItem['Text'].'</td><td><div><textarea name="GroupItem'.$GroupItem['Id'].'">'.$GroupItem['Text'].'</textarea></div></td></tr>';
    57       }
    58       $Output .= '</table>';
    59     }
     48  function NewText($TranslationGroupId)
     49  {
     50    $Output = '<form action="?Action=AddText&amp;GroupId='.$TranslationGroupId.'&amp;Index='.$Index.'" method="post"><strong>Překlad textů:</strong><table class="TranslationTable">';
     51    foreach($this->System->Modules['Translation']->GetTextList($TranslationGroupId) as $GroupItem)
     52    {
     53      $Output .= '<tr><th>'.$GroupItem['Name'].'</th><td>'.$GroupItem['Text'].'</td><td><div><textarea name="GroupItem'.$GroupItem['Id'].'">'.$GroupItem['Text'].'</textarea></div></td></tr>';
     54    }
     55    $Output .= '</table><input type="submit" value="Přidat"></from>';
     56    return($Output);
     57  }
     58
     59  function EditText($TranslationGroupId)
     60  {
     61    $Output = '<form action="?Action=SaveText&amp;GroupId='.$TranslationGroupId.'" method="post"><strong>Překlad textů:</strong><table class="TranslationTable">';
     62    foreach($this->System->Modules['Translation']->GetTextList($TranslationGroupId) as $GroupItem)
     63    {
     64      $Output .= '<tr><th>'.$GroupItem['Name'].'</th><td>'.$GroupItem['Text'].'</td><td><div><textarea name="GroupItem'.$GroupItem['Id'].'">'.$GroupItem['Text'].'</textarea></div></td></tr>';
     65    }
     66    $Output .= '</table><input type="submit" value="Uložit"></from>';
     67    return($Output);
     68  }
     69
     70  function ShowText($TranslationGroupId)
     71  {
     72    $Output = '<strong>Zobrazení textu:</strong><table class="TranslationTable">';
     73    foreach($this->System->Modules['Translation']->GetTextList($TranslationGroupId) as $GroupItem)
     74    {
     75      $Output .= '<tr><th>'.$GroupItem['Name'].'</th><td>'.$GroupItem['Text'].'</td><td>'.$GroupItem['Text'].'</td></tr>';
     76    }
     77    $Output .= '</table>';
     78    $Output .= '<a href="?Action=NewText">Překládat</a>';
     79    return($Output);
     80  }
     81
     82  function AddText($TranslationGroupId, $Index)
     83  {
     84     $Values = array();
     85     foreach($this->System->Modules['Translation']->GetTextList($TranslationGroupId) as $GroupItem)
     86     {
     87       $Values[] = array($GroupItem['Id'] => $_POST['GroupItem'.$GroupItem['Id']]);
     88     }
     89     $this->System->Modules['Translation']->AddTranslation($TranslationGroupId, $Index, $Values);
     90  }
     91 
     92  function ShowMultipleText($TranslationGroupId, $Index)
     93  {
     94    $TextList = $this->System->Modules['Translation']->GetMultipleText($TranslationGroupId, $Index);
     95    $EnglishText = array_shift($TextList);
     96    if(count($TextList) == 0) $Output = 'Tento text zatím nebyl přeložen! <a href="?Action=NewText&amp;GroupId='.$TranslationGroupId.'&amp;Index='.$_GET['Index'].'">Překládat</a>';
     97    else if(count($TextList) == 1) $Output = $this->ShowText($EnglishText['Id']);
    6098    else
    6199    {
    62       // Show only one
    63       $Output = '<strong>Zobrazení textu:</strong><table class="TranslationTable">';
    64       foreach($this->System->Modules['Translation']->GetTextList($TranslationGroupId) as $GroupItem)
    65       {
    66         $Output .= '<tr><th>'.$GroupItem['Name'].'</th><td>'.$GroupItem['Text'].'</td><td>'.$GroupItem['Text'].'</td></tr>';
    67       }
    68       $Output .= '</table>';
    69     }
    70     return($Output);
    71   }
    72  
    73   function ShowMultipleText($TranslationGroupId)
    74   {
    75     $TextList = $this->System->Modules['Translation']->GetMultipleText($TranslationGroupId, $_GET['Index']);
    76     $EnglishText = array_shift($TextList);
    77     if(count($TextList) == 0) $Output = $this->ShowText($EnglishText['Id'], 1);
    78     else if(count($TextList) == 1) $Output = $this->ShowText($EnglishText['Id'], 0);
    79     else {
    80100      // Show multiple possibilites
    81101      $Output = '<strong>Více překladů jednoho textu:</strong><table>'.
     
    176196  }
    177197
    178   function UserTextList($GroupId)
     198  function UserTextList()
    179199  {
    180200    $ItemPerPage = 30;
    181201    if(array_key_exists('Page', $_GET)) $Page = $_GET['Page']; else $Page = 0;
    182202    $Output = '<strong>Seznam vašich textů:</strong><br/>';
    183     foreach($this->System->Modules['Translation']->GetTextGroupList($GroupId, $this->System->Modules['User']->User['Id'], 1, $Page, $ItemPerPage) as $Translation)
    184     {
     203    foreach($this->System->Modules['Translation']->GetTextGroupList(0, $this->System->Modules['User']->User['Id'], 1, $Page, $ItemPerPage) as $Translation)
     204    {
     205      echo('.');
    185206      if(strlen($Translation['Text']) > 30) $Translation['Text'] = substr($Translation['Text'], 0, 30).'...';
    186207      $Output .= $Translation['Index'].'. <a href="?Action=TranslationGroupEdit&amp;GroupId='.$Translation['Id'].'">'.$Translation['Text'].'</a><br />';
    187208    }
    188     $Output .= $this->System->PagesList('?Action=TextGroupList&amp;GroupId='.$GroupId.'&amp;Page=', $Page, $this->System->Modules['Translation']->GetTextGroupListCount($GroupId, 1, 1), $ItemPerPage);
     209    $Output .= $this->System->PagesList('?Action=TextGroupList&amp;GroupId='.$GroupId.'&amp;Page=', $Page, $this->System->Modules['Translation']->GetTextGroupListCount(0, $this->System->Modules['User']->User['Id'], 1), $ItemPerPage);
    189210    return($Output);
    190211  }
     
    215236        break;
    216237      case 'ShowMultipleText':
    217         $Output = $this->ShowMultipleText($_GET['GroupId']);
     238        $Output = $this->ShowMultipleText($_GET['GroupId'], $_GET['Index']);
     239        break;
     240      case 'NewText':
     241        $Output = $this->NewText($_GET['GroupId'], $_GET['Index']);
     242        break;
     243      case 'AddText':
     244        $Output = $this->AddText($_GET['GroupId'], $_GET['Index']);
     245        break;
     246      case 'SaveText':
     247        $Output = $this->SaveText($_GET['GroupId'], $_GET['Edit']);
    218248        break;
    219249      case 'TextGroupList':
  • branches/2/mangos_import.php

    r9 r40  
    2929      while($DbRow = $DbResult->fetch_array())
    3030      {
    31         $this->Database->replace('TextGroup', array('Language' => 1, 'User' => 1, 'Revision' => 1, 'Time' => 'NOW()', 'Group' => $Group['Id'], 'Index' => $DbRow[$Group['MangosTableIndex']]));
     31        $this->Database->query('REPLACE INTO `TextGroup` (`Language`, `User`, `Revision`, `Time`, `Group`, `Index`) VALUES (1, 2, 1, "NOW()", '.$Group['Id'].', '.$DbRow[$Group['MangosTableIndex']].')');
    3232        $TranslationGroupId = $this->Database->insert_id;
    3333        foreach($GroupItemList as $GroupItem)
     
    5151    // Import users
    5252    $this->Database->query('TRUNCATE TABLE `User`');
     53    $this->Database->insert('User', array('Name' => 'Anonym', 'Password' => '', 'Email' => '', 'TranslationLanguage' => 1, 'LastLoginTime' => '', 'LastIpAddress' => '', 'Role' => 1));
     54    $AnonymousId = $this->Database->insert_id;
     55    $this->Database->insert('User', array('Name' => 'MaNGOS', 'Password' => '', 'Email' => '', 'TranslationLanguage' => 1, 'LastLoginTime' => '', 'LastIpAddress' => '', 'Role' => 1));
     56    $MangosId = $this->Database->insert_id;
     57    $this->Database->insert('User', array('Name' => 'WoWEmu', 'Password' => '', 'Email' => '', 'TranslationLanguage' => 1, 'LastLoginTime' => '',     'LastIpAddress' => '', 'Role' => 1));
     58    $WowemuId = $this->Database->insert_id;
     59    $this->Database->insert('User', array('Name' => 'Neznámý', 'Password' => '', 'Email' => '', 'TranslationLanguage' => 1, 'LastLoginTime' => '',     'LastIpAddress' => '', 'Role' => 1));
     60    $UnknownUserId = $this->Database->insert_id;
     61    $UserIdIncrement = 4;
     62
     63    // Load old users
    5364    $DbResult = $this->Database->query('SELECT * FROM `quests`.`user`');
    5465    while($User = $DbResult->fetch_array())
     
    5970      if($User['gm'] == 1) $Role = 3;
    6071      if($User['gm'] == 2) $Role = 4;
    61       $this->Database->insert('User', array('Name' => $User['user'], 'Password' => $User['pass'], 'Email' => $User['Email'], 'TranslationLanguage' => $Language, 'LastLoginTime' => $User['LastLogin'], 'LastIpAddress' => $User['LastIP'], 'Role' => $Role, 'Id' => $User['ID']));
     72      $this->Database->insert('User', array('Name' => $User['user'], 'Password' => $User['pass'], 'Email' => $User['Email'], 'TranslationLanguage' => $Language, 'LastLoginTime' => $User['LastLogin'], 'LastIpAddress' => $User['LastIP'], 'Role' => $Role, 'Id' => ($User['ID'] + $UserIdIncrement)));
    6273    }
    63     $this->Database->insert('User', array('Name' => 'Anonym', 'Password' => '', 'Email' => '', 'TranslationLanguage' => 1, 'LastLoginTime' => '', 'LastIpAddress' => '', 'Role' => 1));
    64     $this->Database->insert('User', array('Name' => 'MaNGOS', 'Password' => '', 'Email' => '', 'TranslationLanguage' => 1, 'LastLoginTime' => '', 'LastIpAddress' => '', 'Role' => 1));
    65     $this->Database->insert('User', array('Name' => 'WoWEmu', 'Password' => '', 'Email' => '', 'TranslationLanguage' => 1, 'LastLoginTime' => '', 'LastIpAddress' => '', 'Role' => 1));
    66     $UnknownUserId = $this->Database->insert_id;
    6774    $Output .= 'Uživatelé převedeni<br>';
    6875
    6976    // Import texts
    70     $this->Database->query('CREATE TABLE Transition (OldIndex INT, NewIndex INT, INDEX OldIndex ) ENGINE=MEMORY');
     77    $this->Database->query('CREATE TABLE Transition (OldIndex INT, NewIndex INT, INDEX (OldIndex) ) ENGINE=MEMORY');
    7178    //$this->Database->query('TRUNCATE TABLE `User`');
    7279    $DbResult = $this->Database->query('SELECT * FROM `quests`.`quests`');
     
    7582      if($Quest['Language'] > 0)
    7683      {
    77         if($Quest['User'] == 0) $Quest['User'] = $UnknownUserId;
     84        if($Quest['User'] == 0) $Quest['User'] = $UnknownUserId; else $Quest['User'] = $Quest['User'] + $UserIdIncrement;
    7885        if($Quest['Take'] > 0)
    7986        {
  • branches/2/sql/full.sql

    r37 r40  
    11-- phpMyAdmin SQL Dump
    2 -- version 2.9.1.1
     2-- version 2.10.2
    33-- http://www.phpmyadmin.net
    44--
    5 -- Host: localhost
    6 -- Generation Time: Oct 13, 2008 at 07:51 PM
    7 -- Server version: 5.0.67
    8 -- PHP Version: 5.2.0
     5-- Počítač: localhost
     6-- Vygenerováno: Čtvrtek 08. května 2008, 19:59
     7-- Verze MySQL: 5.0.45
     8-- Verze PHP: 5.2.4
     9
     10SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
     11
    912--
    10 -- Database: `wowpreklad`
     13-- Databáze: `wowpreklad`
    1114--
    1215
     
    1417
    1518--
    16 -- Table structure for table `language`
     19-- Struktura tabulky `Language`
    1720--
    1821
    19 CREATE TABLE `language` (
     22CREATE TABLE `Language` (
    2023  `Id` int(11) NOT NULL auto_increment,
    2124  `Name` varchar(64) collate utf8_czech_ci NOT NULL,
     
    2629
    2730--
    28 -- Table structure for table `permission`
     31-- Struktura tabulky `Permission`
    2932--
    3033
    31 CREATE TABLE `permission` (
     34CREATE TABLE `Permission` (
    3235  `Id` int(11) NOT NULL auto_increment,
    3336  `Title` varchar(64) collate utf8_czech_ci NOT NULL,
     
    3841
    3942--
    40 -- Table structure for table `text`
     43-- Struktura tabulky `Text`
    4144--
    4245
    43 CREATE TABLE `text` (
     46CREATE TABLE `Text` (
    4447  `Id` int(11) NOT NULL auto_increment,
    4548  `TranslationGroup` int(11) NOT NULL,
     
    5356
    5457--
    55 -- Table structure for table `textgroup`
     58-- Struktura tabulky `TextGroup`
    5659--
    5760
    58 CREATE TABLE `textgroup` (
     61CREATE TABLE `TextGroup` (
    5962  `Id` int(11) NOT NULL auto_increment,
    6063  `Group` int(11) NOT NULL,
     
    7174
    7275--
    73 -- Table structure for table `translation`
     76-- Struktura tabulky `Translation`
    7477--
    7578
    76 CREATE TABLE `translation` (
     79CREATE TABLE `Translation` (
    7780  `Id` int(11) NOT NULL auto_increment,
    7881  `Group` int(11) NOT NULL,
     
    8588
    8689--
    87 -- Table structure for table `translationgroup`
     90-- Struktura tabulky `TranslationGroup`
    8891--
    8992
    90 CREATE TABLE `translationgroup` (
     93CREATE TABLE `TranslationGroup` (
    9194  `Id` int(11) NOT NULL auto_increment,
    9295  `Name` varchar(64) collate utf8_czech_ci NOT NULL,
     
    99102
    100103--
    101 -- Table structure for table `user`
     104-- Struktura tabulky `User`
    102105--
    103106
    104 CREATE TABLE `user` (
     107CREATE TABLE `User` (
    105108  `Id` int(11) NOT NULL auto_increment,
    106109  `Name` varchar(64) collate utf8_czech_ci NOT NULL,
     
    108111  `Email` varchar(128) collate utf8_czech_ci NOT NULL,
    109112  `Permission` int(11) NOT NULL,
    110   `LastIpAddress` varchar(255) collate utf8_czech_ci NOT NULL,
     113  `LastIpAddress` varchar(16) collate utf8_czech_ci NOT NULL,
    111114  `LastLoginTime` datetime NOT NULL,
    112115  `TranslationLanguage` int(11) NOT NULL,
    113116  `FullName` varchar(128) collate utf8_czech_ci NOT NULL,
    114117  PRIMARY KEY  (`Id`)
    115 ) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=4 ;
     118) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci AUTO_INCREMENT=2 ;
    116119
    117120-- --------------------------------------------------------
    118121
    119122--
    120 -- Table structure for table `useronline`
     123-- Struktura tabulky `UserOnline`
    121124--
    122125
    123 CREATE TABLE `useronline` (
     126CREATE TABLE `UserOnline` (
    124127  `User` int(11) NOT NULL,
    125128  `Time` datetime NOT NULL,
    126129  `SessionId` varchar(255) collate utf8_czech_ci NOT NULL,
    127   `IpAddress` varchar(255) collate utf8_czech_ci NOT NULL,
    128   UNIQUE KEY `SessionId` (`SessionId`)
     130  `IpAddress` varchar(16) collate utf8_czech_ci NOT NULL,
     131  PRIMARY KEY  (`User`)
    129132) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_czech_ci;
    130133
     
    132135
    133136--
    134 -- Table structure for table `vote`
     137-- Struktura tabulky `Vote`
    135138--
    136139
    137 CREATE TABLE `vote` (
     140CREATE TABLE `Vote` (
    138141  `TranslationGroup` int(11) NOT NULL,
    139142  `User` int(11) NOT NULL,
  • branches/2/sql/init_data.sql

    r37 r40  
    11-- phpMyAdmin SQL Dump
    2 -- version 2.10.2 
     2-- version 2.10.2
    33-- http://www.phpmyadmin.net
    44--
  • branches/2/translation.php

    r9 r40  
    4444  {
    4545    $Result = array();
    46     $DbResult = $this->Database->query('SELECT `TextGroup`.*, (SELECT `Text` FROM `Text` WHERE `Text`.`TranslationGroup` = `TextGroup`.`Id` LIMIT 1) as `Text`, (SELECT COUNT(`TextGroup2`.`User`) FROM `TextGroup` AS `TextGroup2` WHERE `TextGroup2`.`Index` = `TextGroup`.`Index` AND `TextGroup2`.`Group` = `TextGroup`.`Group`) as `TextCount` FROM `TextGroup` WHERE `TextGroup`.`Group`='.$GroupId.' AND `TextGroup`.`User`='.$UserId.' AND `TextGroup`.`Language`='.$Language.' LIMIT '.($Page * $ItemPerPage).','.$ItemPerPage);
     46    if($GroupId != 0) $GroupCondition = '`TextGroup`.`Group`='.$GroupId.' AND '; else $GroupCondition = '';
     47    $DbResult = $this->Database->query('SELECT `TextGroup`.*, (SELECT `Text` FROM `Text` WHERE `Text`.`TranslationGroup` = `TextGroup`.`Id` LIMIT 1) as `Text`, (SELECT COUNT(`TextGroup2`.`User`) FROM `TextGroup` AS `TextGroup2` WHERE `TextGroup2`.`Index` = `TextGroup`.`Index` AND `TextGroup2`.`Group` = `TextGroup`.`Group`) as `TextCount` FROM `TextGroup` WHERE '.$GroupCondition.'`TextGroup`.`User`='.$UserId.' AND `TextGroup`.`Language`='.$Language.' LIMIT '.($Page * $ItemPerPage).','.$ItemPerPage);
    4748    //echo($this->Database->LastQuery);
    4849    if($DbResult->num_rows > 0)
     
    5051    {
    5152      $Result[] = $DbRow;
     53      echo('.');
    5254    }
    5355    return($Result);
     
    5759  {
    5860    $Result = array();
    59     $DbResult = $this->Database->select('TextGroup', 'COUNT(*)', '`Group`='.$GroupId.' AND `User`='.$UserId.' AND `Language`='.$Language);
     61    if($GroupId != 0) $GroupCondition = '`Group`='.$GroupId.' AND '; else $GroupCondition = '';
     62    $DbResult = $this->Database->select('TextGroup', 'COUNT(*)', $GroupCondition.'`User`='.$UserId.' AND `Language`='.$Language);
    6063    //echo($this->Database->LastQuery);
    6164    $DbRow = $DbResult->fetch_array();
     
    7578    return($Result);
    7679  }
     80 
     81  function AddTranslation($Group, $Index, $TextList)
     82  {
     83    $this->Database->insert('TextGroup', array('Group' => $Group, 'Index' => $Index, 'Language' => $this->System->Modules['User']->User['Language'], 'User' => $this->System->Modules['User']->User['Id'], 'Time' => 'NOW()', 'Revision' => 1, 'OriginalText' => 0));
     84    $GroupId = $this->Database->insert_id;
     85    foreach($TextList as $Index => $Text)
     86    {
     87      $this->Database->insert('Text', array('TranslationGroup' => $GroupId, 'Text' => $Text, 'GroupItem' => $Index));
     88    }   
     89  }
    7790}
    7891
  • branches/2/user.php

    r9 r40  
    2020  var $DefaultRole = 2;
    2121  var $AnonymousUserId = 1;
    22  
     22
    2323  function Check()
    2424  {
     
    3131      // Refresh time of last access
    3232      $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('Time' => 'NOW()'));
    33     } else $this->Database->insert('UserOnline', array('SessionId' => $SID, 'User' => $AnonymousUserId, 'Time' => 'NOW()', 'IpAddress' => (gethostbyaddr(GetRemoteAddress()).' '.GetRemoteAddress()))); 
     33    } else $this->Database->insert('UserOnline', array('SessionId' => $SID, 'User' => $this->AnonymousUserId, 'Time' => 'NOW()', 'HostAddress' => (gethostbyaddr(GetRemoteAddress()).' '.GetRemoteAddress()))); 
    3434
    3535    // Odeber neaktivní uživatele
     
    3737
    3838    // Zkontroluj přihlášení
    39     $Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"');
    40     $Row = $Query->fetch_array();
     39    $DbResult = $this->Database->select('UserOnline', 'User', 'SessionId="'.$SID.'"');
     40    $Row = $DbResult->fetch_assoc();
    4141    if($Row['User'] != $this->AnonymousUserId)
    4242    {
Note: See TracChangeset for help on using the changeset viewer.