Changeset 831 for trunk/Modules


Ignore:
Timestamp:
Aug 24, 2015, 9:57:27 PM (9 years ago)
Author:
chronos
Message:
  • Removed: Do not use fixed number for text group item index. Do not exclude all other groups for mass translation except spell rank.
  • Modified: Translation save page redirection part of code moved to separate method.
  • Fixed: Translation save condition for empty original text items.
Location:
trunk/Modules
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Translation/Save.php

    r826 r831  
    4242
    4343            // Get all similar english texts
    44             $Filter = '';
     44            $Filter = array();
    4545            foreach($Group['Items'] as $GroupItem)
    46               if(($GroupItem['Visible'] == 1) and ($EnglishText[$GroupItem['Column']] != ''))
    47               $Filter .= ' OR (`'.$GroupItem['Column'].'` = "'.addslashes($EnglishText[$GroupItem['Column']]).'")';
    48             if(substr($Filter, 0, 3) == ' OR') $Filter = ' AND ('.substr($Filter, 3).')';
    49 
    50             $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE (`Language` = '.$this->System->Config['OriginalLanguage'].')'.$Filter);
     46              if(($GroupItem['Visible'] == 1))
     47              $Filter[] = '(`'.$GroupItem['Column'].'` = "'.addslashes($EnglishText[$GroupItem['Column']]).'")';
     48            if(count($Filter) > 0) $Filter = ' AND ('.implode(' OR ', $Filter).')';
     49
     50            $Query = 'SELECT * FROM `'.$Table.'` WHERE (`Language` = '.$this->System->Config['OriginalLanguage'].')'.$Filter;
     51            echo($Query."\n");
     52            $DbResult = $this->Database->query($Query);
    5153            while($EnglishFound = $DbResult->fetch_assoc())
    5254            {
     
    120122                $CompleteParts = 0;
    121123                $Completable = true;
    122                 $OnlyRank = true;
    123124                foreach($Group['Items'] as $GroupItem)
    124125                {
     
    131132                      if(array_key_exists($GroupItem['Column'], $_POST))
    132133                      {
    133                         if (44 <> $GroupItem['Id']) $OnlyRank = false;
    134134                        $Values .= ', "'.$_POST[$GroupItem['Column']].'"';
    135135                        $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1));
     
    144144                }
    145145                if($Completable) $NewComplete = 1; // All parts of text are completed. Make entire text as completed
    146                 else $NewComplete = 0;
     146                  else $NewComplete = 0;
    147147                if($SourceText['ID'] == $EnglishFound['ID'])
    148148                {
     
    156156                $Columns .= ', `Complete`, `CompleteParts`';
    157157                $Values .= ', '.$NewComplete.', '.$CompleteParts;
    158 
    159                 if (!$OnlyRank)
    160                 {
    161                   $this->Database->query('INSERT INTO `'.$Table.'` ('.$Columns.') VALUES ('.$Values.')');
    162                   $LastID = $this->Database->insert_id;
    163 
    164                   $Output .= 'Text <a href="'.$this->System->Link('/form.php?group='.
    165                     $GroupId.'&amp;ID='.$LastID).'">'.$LastID.'</a> ze skupiny <a href="TranslationList.php?group='.
    166                     $GroupId.'&amp;user=0&amp;action=filter">'.$TranslationTree[$GroupId]['Name'].'</a> uložen jako '.
    167                     $CompleteText[$NewComplete].'. Převzat z <a href="form.php?group='.$GroupId.'&amp;ID='.$TextID.'">'.$TextID.'</a>.<br/>';
    168                   $this->System->ModuleManager->Modules['Log']->WriteLog('Text <a href="'.
    169                     $this->System->Link('/form.php?group='.$GroupId.'&amp;ID='.$LastID).'">'.
    170                     $LastID.'</a> ze skupiny <a href="TranslationList.php?group='.
    171                     $GroupId.'&amp;user=0&amp;text=&amp;entry=&amp;action=filter">'.
    172                     $TranslationTree[$GroupId]['Name'].'</a> uložen jako '.$CompleteText[$NewComplete].
    173                     '. Převzat z <a href="form.php?group='.$GroupId.'&amp;ID='.$TextID.'">'.$TextID.'</a>.', LOG_TYPE_TRANSLATION);
    174                 }
     158                $this->Database->query('INSERT INTO `'.$Table.'` ('.$Columns.') VALUES ('.$Values.')');
     159                $LastID = $this->Database->insert_id;
     160
     161                $Output .= 'Text <a href="'.$this->System->Link('/form.php?group='.
     162                  $GroupId.'&amp;ID='.$LastID).'">'.$LastID.'</a> ze skupiny <a href="TranslationList.php?group='.
     163                  $GroupId.'&amp;user=0&amp;action=filter">'.$TranslationTree[$GroupId]['Name'].'</a> uložen jako '.
     164                  $CompleteText[$NewComplete].'. Převzat z <a href="form.php?group='.$GroupId.'&amp;ID='.$TextID.'">'.$TextID.'</a>.<br/>';
     165                $this->System->ModuleManager->Modules['Log']->WriteLog('Text <a href="'.
     166                  $this->System->Link('/form.php?group='.$GroupId.'&amp;ID='.$LastID).'">'.
     167                  $LastID.'</a> ze skupiny <a href="TranslationList.php?group='.
     168                  $GroupId.'&amp;user=0&amp;text=&amp;entry=&amp;action=filter">'.
     169                  $TranslationTree[$GroupId]['Name'].'</a> uložen jako '.$CompleteText[$NewComplete].
     170                  '. Převzat z <a href="form.php?group='.$GroupId.'&amp;ID='.$TextID.'">'.$TextID.'</a>.', LOG_TYPE_TRANSLATION);
    175171              }
    176172            }
     
    178174        } else $Output .= ShowMessage('Zadaná položka nenalezena.', MESSAGE_CRITICAL);
    179175
    180 
    181         // Address and redirecting
    182         $Output .= '<br />Překládat: <a href="TranslationList.php?group='.$GroupId.'&amp;state=1&amp;user=0&entry=">Nepřeložené</a> ';
    183 
    184         $prev = FollowingTran($TextID, $Table, $GroupId, True);
    185         $next = FollowingTran($TextID, $Table, $GroupId);
    186         $Output .= '<br /><br />';
    187         $DbResult = $this->Database->query('SELECT `Redirecting` FROM `User` WHERE `ID`='.$this->System->User->Id);
    188         $redirecting = $DbResult->fetch_assoc();
    189 
    190         switch($redirecting['Redirecting'])
    191         {
    192           case 1:
    193             $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'.
    194                 'setTimeout("parent.location.href=\''.htmlspecialchars_decode('TranslationList.php?group='.$GroupId.'&amp;state=1&amp;user=0').'\'", 1500)'.
    195                 '</script>';
    196             break;
    197           case 2:
    198             if($next <> '')
    199               $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'.
    200               'setTimeout("parent.location.href=\''.htmlspecialchars_decode($next).'\'", 1500)'.
    201               '</script>';
    202             break;
    203           case 3:
    204             if($prev <> '')
    205               $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'.
    206               'setTimeout("parent.location.href=\''.htmlspecialchars_decode($prev).'\'", 1500)'.
    207               '</script>';
    208             break;
    209         }
    210 
    211         $Output .= 'Z této stránky můžete být automaticky přesměrování. Nastavit kam chcete být přesměrování si můžete v <a href="'.
    212           $this->System->Link('/Options.php').'" title="Nastavení uživatele">Nastavení</a>';
     176        $Output .= $this->ShowRedirection($GroupId, $Table, $TextID);
    213177
    214178        // Update flag for experience info load
     
    245209    return($Output);
    246210  }
     211
     212  function ShowRedirection($GroupId, $Table, $TextID)
     213  {
     214        // Address and redirecting
     215        $Output = '<br />Překládat: <a href="TranslationList.php?group='.$GroupId.'&amp;state=1&amp;user=0&entry=">Nepřeložené</a> ';
     216
     217        $prev = FollowingTran($TextID, $Table, $GroupId, True);
     218        $next = FollowingTran($TextID, $Table, $GroupId);
     219        $Output .= '<br /><br />';
     220        $DbResult = $this->Database->query('SELECT `Redirecting` FROM `User` WHERE `ID`='.$this->System->User->Id);
     221        $redirecting = $DbResult->fetch_assoc();
     222
     223        switch($redirecting['Redirecting'])
     224        {
     225                case 1:
     226                        $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'.
     227                                        'setTimeout("parent.location.href=\''.htmlspecialchars_decode('TranslationList.php?group='.$GroupId.'&amp;state=1&amp;user=0').'\'", 1500)'.
     228                                        '</script>';
     229                        break;
     230                case 2:
     231                        if($next <> '')
     232                                $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'.
     233                                                'setTimeout("parent.location.href=\''.htmlspecialchars_decode($next).'\'", 1500)'.
     234                                                '</script>';
     235                                break;
     236                case 3:
     237                        if($prev <> '')
     238                                $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'.
     239                                                'setTimeout("parent.location.href=\''.htmlspecialchars_decode($prev).'\'", 1500)'.
     240                                                '</script>';
     241                                break;
     242        }
     243
     244        $Output .= 'Z této stránky můžete být automaticky přesměrování. Nastavit kam chcete být přesměrování si můžete v <a href="'.
     245          $this->System->Link('/Options.php').'" title="Nastavení uživatele">Nastavení</a>';
     246    return($Output);
     247  }
    247248}
  • trunk/Modules/Translation/TranslationList.php

    r817 r831  
    184184                              ')';
    185185          }
    186       if($Filter['State'] == CompletionState::All) $Filter['SQL'] .= $UserFilter.$VersionFilter.'';
    187       else if($Filter['State'] == CompletionState::NotTranslated) $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.$this->System->Config['OriginalLanguage'].') '.
     186      if($Filter['State'] == CompletionState::All) {
     187        $Filter['SQL'] .= $UserFilter.$VersionFilter;
     188      } else
     189      if($Filter['State'] == CompletionState::NotTranslated) {
     190        $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.$this->System->Config['OriginalLanguage'].') '.
    188191          'AND NOT EXISTS(SELECT 1 FROM `'.$Table.'` AS `Sub` WHERE '.
    189192          '(`Sub`.`Language` <> '.$this->System->Config['OriginalLanguage'].') '.$LanguageFilterSub.$UserFilter.
    190193          ' AND (`Sub`.`Entry` = `T`.`Entry`) AND (`Sub`.`Complete` = 1) AND '.
    191194          '(`Sub`.`VersionStart` = `T`.`VersionStart`) AND (`Sub`.`VersionEnd` = `T`.`VersionEnd`))';
    192       else if($Filter['State'] == CompletionState::Translated) $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Complete` = 1)';
    193       else if($Filter['State'] == CompletionState::NotFinished) $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Language` != '.$this->System->Config['OriginalLanguage'].
     195      } else
     196      if($Filter['State'] == CompletionState::Translated) {
     197        $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Complete` = 1)';
     198      } else
     199      if($Filter['State'] == CompletionState::NotFinished) {
     200        $Filter['SQL'] .= $UserFilter.$LanguageFilter.$VersionFilter.' AND (`T`.`Language` != '.$this->System->Config['OriginalLanguage'].
    194201      ') AND (`T`.`Complete` = 0)';
    195       else if($Filter['State'] == CompletionState::Original) $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.$this->System->Config['OriginalLanguage'].')';
    196       else if($Filter['State'] == CompletionState::NotFinishedNotTranslated) $Filter['SQL'] .= $UserFilter.$VersionFilter.$WithoutAlter.
     202      } else
     203      if($Filter['State'] == CompletionState::Original) {
     204        $Filter['SQL'] .= $VersionFilter.' AND (`T`.`Language` = '.$this->System->Config['OriginalLanguage'].')';
     205      } else
     206      if($Filter['State'] == CompletionState::NotFinishedNotTranslated) {
     207        $Filter['SQL'] .= $UserFilter.$VersionFilter.$WithoutAlter.
    197208      ' AND (`T`.`Language` != '.$this->System->Config['OriginalLanguage'].
    198       ') AND (`T`.`Complete` = 0)'.
    199           '';
    200       else if($Filter['State'] == CompletionState::Missing1) {
     209      ') AND (`T`.`Complete` = 0)';
     210      } else
     211      if($Filter['State'] == CompletionState::Missing1) {
    201212        $Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '.$this->System->Config['OriginalLanguage'];
    202213        $Filter['SQL'] .= ' AND ('.implode(' OR ', $ItemsVar).') ';
    203       }
    204       else if($Filter['State'] == CompletionState::Missing2) {
     214      } else
     215      if($Filter['State'] == CompletionState::Missing2) {
    205216        $Filter['SQL'] .= $UserFilter.$VersionFilter.' AND (`T`.`Complete` = 1) AND `T`.`Language` != '.$this->System->Config['OriginalLanguage'];
    206217        $Filter['SQL'] .= ' '. $WithoutAlter;
  • trunk/Modules/Wiki/Wiki.php

    r816 r831  
    3737  function LoadPages()
    3838  {
    39     $DbResult = $this->Database->select('WikiPage', '*', 'VisibleInMenu=1');
     39    $DbResult = $this->Database->select('WikiPage', '*', '`VisibleInMenu`=1');
    4040    while($DbRow = $DbResult->fetch_assoc())
    4141    {
Note: See TracChangeset for help on using the changeset viewer.