Changeset 9


Ignore:
Timestamp:
May 9, 2008, 2:04:07 PM (17 years ago)
Author:
george
Message:

Přidáno: Import uživatelů a questů ze starého systému.
Přidáno: Zobrazení vícenásobných překladů.

Location:
branches/2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2/frontend.php

    r8 r9  
    4646  }
    4747
    48   function ShowText($TranslationGroupId)
    49   {
    50    
    51     $TextList = $this->System->Modules['Translation']->GetMultipleText($TranslationGroupId, $_GET['Index']);
    52     if(count($TextList) == 0)
     48  function ShowText($TranslationGroupId, $Edit)
     49  {
     50    if($Edit)
    5351    {
    5452      // Edit new text
     
    6058      $Output .= '</table>';
    6159    }
    62     else if(count($TextList) == 1)
     60    else
    6361    {
    6462      // Show only one
     
    6967      }
    7068      $Output .= '</table>';
    71     } else
    72     {
     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 {
    7380      // Show multiple possibilites
    74       $Output = '<strong>Více překladů jednoho textu:</strong><table class="TranslationTable">'.
     81      $Output = '<strong>Více překladů jednoho textu:</strong><table>'.
    7582       '<tr><th>ID</th><th>Titulek</th></tr>';
    7683      foreach($TextList as $Text)
    7784      {
    78         $Output .= '<tr><td>'.$Text['Index'].'</td><td><a href="?Action=ShowText&amp;GroupId='.$Text['Id'].'">'.$Text['Text'].'</a></td></tr>';
     85        $Output .= '<tr><td>'.$Text['Index'].'</td><td><a href="?Action=ShowText&amp;GroupId='.$Text['Id'].'&amp;Edit=0">'.$Text['Text'].'</a></td></tr>';
    7986      }
    8087      $Output .= '</table>';
     
    9299    {
    93100      if(strlen($Translation['Text']) > 30) $Translation['Text'] = substr($Translation['Text'], 0, 30).'...';
    94       $Output .= '<tr><td>'.$Translation['Index'].'</td><td><a href="?Action=ShowText&amp;GroupId='.$Translation['Id'].'&amp;Index='.$Translation['Index'].'">'.$Translation['Text'].'</a></td><td>'.($Translation['TextCount'] - 1).'</td></tr>';
     101      $Output .= '<tr><td>'.$Translation['Index'].'</td><td><a href="?Action=ShowMultipleText&amp;GroupId='.$Translation['Group'].'&amp;Index='.$Translation['Index'].'">'.$Translation['Text'].'</a></td><td>'.($Translation['TextCount'] - 1).'</td></tr>';
    95102    }
    96103    $Output .= '</table>'.$this->System->PagesList('?Action=TextGroupList&amp;GroupId='.$GroupId.'&amp;Page=', $Page, $this->System->Modules['Translation']->GetTextGroupListCount($GroupId, 1, 1), $ItemPerPage);
     
    205212        break;
    206213      case 'ShowText':
    207         $Output = $this->ShowText($_GET['GroupId']);
     214        $Output = $this->ShowText($_GET['GroupId'], $_GET['Edit']);
     215        break;
     216      case 'ShowMultipleText':
     217        $Output = $this->ShowMultipleText($_GET['GroupId']);
    208218        break;
    209219      case 'TextGroupList':
     
    229239        break;
    230240      case 'ImportOldSystem':
    231         $Output = $this->System->Modules['MangosImport']->ImportOldMangos();
     241        $Output = $this->System->Modules['MangosImport']->ImportOldSystem();
    232242        break;
    233243    }
  • branches/2/mangos_import.php

    r8 r9  
    66  {
    77    $Output = '';
    8     $this->Database->delete('Text', '`Text`.`TranslationGroup`=(SELECT `TextGroup`.`Id` FROM `TextGroup` WHERE `TextGroup`.`Language`=1)');
     8    $this->Database->query('DELETE FROM `Text` JOIN `TextGroup` ON `TextGroup`.`Language`=1 AND `TextGroup`.`Id` = `Text`.`TranslationGroup`');
    99    echo($this->Database->error);
    10     $this->Database->delete('TranslationGroup', '`Language`=1');
     10    $this->Database->delete('TextGroup', '`Language`=1');
    1111    echo($this->Database->error);
    1212
     
    4747  function ImportOldSystem()
    4848  {
     49    $Output = '';
     50
     51    // Import users
     52    $this->Database->query('TRUNCATE TABLE `User`');
     53    $DbResult = $this->Database->query('SELECT * FROM `quests`.`user`');
     54    while($User = $DbResult->fetch_array())
     55    {
     56      $Language = $User['Language'] + 1;
     57      if($Language == 1) $Language = 2;
     58      $Role = 2;
     59      if($User['gm'] == 1) $Role = 3;
     60      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']));
     62    }
     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;
     67    $Output .= 'Uživatelé převedeni<br>';
     68
     69    // Import texts
     70    $this->Database->query('CREATE TABLE Transition (OldIndex INT, NewIndex INT, INDEX OldIndex ) ENGINE=MEMORY');
     71    //$this->Database->query('TRUNCATE TABLE `User`');
     72    $DbResult = $this->Database->query('SELECT * FROM `quests`.`quests`');
     73    while($Quest = $DbResult->fetch_array())
     74    {
     75      if($Quest['Language'] > 0)
     76      {
     77        if($Quest['User'] == 0) $Quest['User'] = $UnknownUserId;
     78        if($Quest['Take'] > 0)
     79        {
     80          $DbResult2 = $this->Database->select('Transition', 'NewIndex', 'OldIndex='.$Quest['Take']);
     81          $DbRow2 = $DbResult2->fetch_array();
     82          $Take = $DbRow2['NewIndex'];
     83        } else $Take = 0;
     84
     85        $this->Database->insert('TextGroup', array('Index' => $Quest['entry'], 'Group' => 1, 'Time' => 'NOW()', 'Language' => $Quest['Language'] + 1, 'OldSystem' => 1, 'Complete' => $Quest['complete'], 'OriginalText' => $Take));
     86        //echo($this->Database->LastQuery);
     87        $TextGroupId = $this->Database->insert_id;
     88        $this->Database->insert('Transition', array('OldIndex' => $Quest['ID'], 'NewIndex' => $TextGroupId));
     89        if($Quest['Title'] != '') $this->Database->insert('Text', array('TranslationGroup' => $TextGroupId, 'GroupItem' => 1, 'Text' => $Quest['Title']));
     90        if($Quest['Details'] != '') $this->Database->insert('Text', array('TranslationGroup' => $TextGroupId, 'GroupItem' => 2, 'Text' => $Quest['Details']));
     91        if($Quest['Objectives'] != '') $this->Database->insert('Text', array('TranslationGroup' => $TextGroupId, 'GroupItem' => 3, 'Text' => $Quest['Objectives']));
     92        if($Quest['OfferRewardText'] != '') $this->Database->insert('Text', array('TranslationGroup' => $TextGroupId, 'GroupItem' => 4, 'Text' => $Quest['OfferRewardText']));
     93        if($Quest['RequestItemsText'] != '') $this->Database->insert('Text', array('TranslationGroup' => $TextGroupId, 'GroupItem' => 5, 'Text' => $Quest['RequestItemsText']));
     94        if($Quest['EndText'] != '') $this->Database->insert('Text', array('TranslationGroup' => $TextGroupId, 'GroupItem' => 6, 'Text' => $Quest['EndText']));
     95        if($Quest['ObjectiveText1'] != '') $this->Database->insert('Text', array('TranslationGroup' => $TextGroupId, 'GroupItem' => 7, 'Text' => $Quest['ObjectiveText1']));
     96        if($Quest['ObjectiveText2'] != '') $this->Database->insert('Text', array('TranslationGroup' => $TextGroupId, 'GroupItem' => 8, 'Text' => $Quest['ObjectiveText2']));
     97        if($Quest['ObjectiveText3'] != '') $this->Database->insert('Text', array('TranslationGroup' => $TextGroupId, 'GroupItem' => 9, 'Text' => $Quest['ObjectiveText3']));
     98        if($Quest['ObjectiveText4'] != '') $this->Database->insert('Text', array('TranslationGroup' => $TextGroupId, 'GroupItem' => 10, 'Text' => $Quest['ObjectiveText4']));
     99      }
     100    }
     101    $this->Database->query('DROP TABLE Transition');
     102    $Output .= 'Questy převedeny<br>';
     103    return($Output);
    49104  }
    50105}
  • branches/2/translation.php

    r8 r9  
    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`.`Id` = `TextGroup`.`Id`) as `TextCount` FROM `TextGroup` WHERE `TextGroup`.`Group`='.$GroupId.' AND `TextGroup`.`User`='.$UserId.' AND `TextGroup`.`Language`='.$Language.' LIMIT '.($Page * $ItemPerPage).','.$ItemPerPage);
     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);
    4747    //echo($this->Database->LastQuery);
    4848    if($DbResult->num_rows > 0)
     
    6666  {
    6767    $Result = array();
    68     $DbResult = $this->Database->query('SELECT `TextGroup`.*, (SELECT `Text` FROM `Text` WHERE `Text`.`TranslationGroup` = `TextGroup`.`Id` LIMIT 1) as `Text` FROM `TextGroup` WHERE `TextGroup`.`Group`='.$GroupId.' AND `TextGroup`.`Index` = '.$Index.' AND `TextGroup`.`Language` != 1');
     68    $DbResult = $this->Database->query('SELECT `TextGroup`.*, (SELECT `Text` FROM `Text` WHERE `Text`.`TranslationGroup` = `TextGroup`.`Id` LIMIT 1) as `Text` FROM `TextGroup` WHERE `TextGroup`.`Group`='.$GroupId.' AND `TextGroup`.`Index` = '.$Index.'');
    6969    //echo($this->Database->LastQuery);
    7070    if($DbResult->num_rows > 0)
  • branches/2/user.php

    r8 r9  
    1919  var $User = array();
    2020  var $DefaultRole = 2;
     21  var $AnonymousUserId = 1;
    2122 
    2223  function Check()
     
    3031      // Refresh time of last access
    3132      $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('Time' => 'NOW()'));
    32     } else $this->Database->insert('UserOnline', array('SessionId' => $SID, 'User' => 1, 'Time' => 'NOW()', 'IpAddress' => (gethostbyaddr(GetRemoteAddress()).' '.GetRemoteAddress()))); 
     33    } else $this->Database->insert('UserOnline', array('SessionId' => $SID, 'User' => $AnonymousUserId, 'Time' => 'NOW()', 'IpAddress' => (gethostbyaddr(GetRemoteAddress()).' '.GetRemoteAddress()))); 
    3334
    3435    // Odeber neaktivní uživatele
     
    3839    $Query = $this->Database->select('UserOnline', '*', 'SessionId="'.$SID.'"');
    3940    $Row = $Query->fetch_array();
    40     if($Row['User'] != 0)
     41    if($Row['User'] != $this->AnonymousUserId)
    4142    {
    4243      $Query = $this->Database->select('User', '*', "Id=".$Row['User']."");
     
    4445      $Result = USER_LOGGED;
    4546    } else {
    46       $Query = $this->Database->select('User', '*', "Id=1");
     47      $Query = $this->Database->select('User', '*', "Id=".$this->AnonymousUserId);
    4748      $this->User = $Query->fetch_array();
    4849      $Result = USER_NOT_LOGGED;
     
    9798  {
    9899    $SID = session_id();
    99     $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => 1));
     100    $this->Database->update('UserOnline', 'SessionId="'.$SID.'"', array('User' => $this->AnonymousUserId));
    100101    return(USER_LOGGED_OUT);
    101102  }
Note: See TracChangeset for help on using the changeset viewer.