Ignore:
Timestamp:
Apr 7, 2020, 10:15:48 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Improved code formatting.
File:
1 edited

Legend:

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

    r859 r880  
    1111    // Get source text record from database by ID
    1212    $DbResult = $this->Database->query('SELECT * FROM `'.$Table.'` WHERE `ID`='.$TextID);
    13     if($DbResult->num_rows > 0)
     13    if ($DbResult->num_rows > 0)
    1414    {
    1515      $SourceText = $DbResult->fetch_assoc();
     
    1919          'AND (`Language` = '.$this->System->Config['OriginalLanguage'].') AND (`VersionStart` = '.$SourceText['VersionStart'].') '.
    2020          'AND (`VersionEnd` = '.$SourceText['VersionEnd'].')');
    21       if($DbResult->num_rows > 0)
     21      if ($DbResult->num_rows > 0)
    2222      {
    2323        $EnglishText = $DbResult->fetch_assoc();
     
    2525        // Get all similar english texts
    2626        $Filter = array();
    27         foreach($Group['Items'] as $GroupItem)
     27        foreach ($Group['Items'] as $GroupItem)
    2828        {
    29           if(($GroupItem['Visible'] == 1) and ($EnglishText[$GroupItem['Column']] != ''))
     29          if (($GroupItem['Visible'] == 1) and ($EnglishText[$GroupItem['Column']] != ''))
    3030            $Filter[] = '(`'.$GroupItem['Column'].'` = "'.addslashes($EnglishText[$GroupItem['Column']]).'")';
    3131        }
    32         if(count($Filter) > 0) $Filter = ' AND ('.implode(' OR ', $Filter).')';
     32        if (count($Filter) > 0) $Filter = ' AND ('.implode(' OR ', $Filter).')';
    3333          else $Filter = ' AND 0';
    3434
    3535          $Query = 'SELECT * FROM `'.$Table.'` WHERE (`Language` = '.$this->System->Config['OriginalLanguage'].')'.$Filter;
    3636          $DbResult = $this->Database->query($Query);
    37           while($EnglishFound = $DbResult->fetch_assoc())
     37          while ($EnglishFound = $DbResult->fetch_assoc())
    3838          {
    3939            // Get user translation paired to found english item entry
     
    4141              ') AND (`Entry` = '.$EnglishFound['Entry'].') AND (`VersionStart` = '.$EnglishFound['VersionStart'].
    4242              ') AND (`VersionEnd` = '.$EnglishFound['VersionEnd'].')');
    43             if($DbResult2->num_rows > 0)
     43            if ($DbResult2->num_rows > 0)
    4444            {
    4545              // Update existed user translation
     
    4747              $Modified = false;
    4848              $Values = '`Language` = '.$Language;
    49               if($Language != $ExistedText['Language']) $Modified = true;
     49              if ($Language != $ExistedText['Language']) $Modified = true;
    5050
    5151              $Completable = true;
    5252              $CompleteParts = $ExistedText['CompleteParts'];
    53               foreach($Group['Items'] as $GroupItem)
    54               {
    55                 if($GroupItem['Visible'] == 1)
    56                 {
    57                   if($EnglishFound[$GroupItem['Column']] == $EnglishText[$GroupItem['Column']])
     53              foreach ($Group['Items'] as $GroupItem)
     54              {
     55                if ($GroupItem['Visible'] == 1)
     56                {
     57                  if ($EnglishFound[$GroupItem['Column']] == $EnglishText[$GroupItem['Column']])
    5858                  {
    59                     if(array_key_exists($GroupItem['Column'], $_POST))
     59                    if (array_key_exists($GroupItem['Column'], $_POST))
    6060                    {
    61                       if($_POST[$GroupItem['Column']] != $ExistedText[$GroupItem['Column']])
     61                      if ($_POST[$GroupItem['Column']] != $ExistedText[$GroupItem['Column']])
    6262                        $Modified = true;
    6363
     
    6666                    }
    6767                  }
    68                   if((($CompleteParts & (1 << ($GroupItem['Sequence'] - 1))) == 0) and
     68                  if ((($CompleteParts & (1 << ($GroupItem['Sequence'] - 1))) == 0) and
    6969                      ($EnglishFound[$GroupItem['Column']] != '')) $Completable = false;
    7070                }
    7171              }
    72               if($Completable) $NewComplete = 1; // All parts of text are completed. Make entire text as completed
     72              if ($Completable) $NewComplete = 1; // All parts of text are completed. Make entire text as completed
    7373                else $NewComplete = 0;
    7474
    7575              // Update completion status for edited translation item
    76               if($SourceText['ID'] == $ExistedText['ID'])
     76              if ($SourceText['ID'] == $ExistedText['ID'])
    7777              {
    7878                $NewComplete = $Complete; // Our original user text, set complete according user choice
    79                 if($Complete == 1)
    80                 {
    81                   foreach($Group['Items'] as $GroupItem)
    82                     if($GroupItem['Visible'] == 1) $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1));
     79                if ($Complete == 1)
     80                {
     81                  foreach ($Group['Items'] as $GroupItem)
     82                    if ($GroupItem['Visible'] == 1) $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1));
    8383                }
    8484              }
    8585              $Values .= ', `Complete`='.$NewComplete.', `CompleteParts` = '.$CompleteParts;
    86               if(($NewComplete != $ExistedText['Complete']) or ($CompleteParts != $ExistedText['CompleteParts']))
     86              if (($NewComplete != $ExistedText['Complete']) or ($CompleteParts != $ExistedText['CompleteParts']))
    8787                $Modified = true;
    8888
    8989              $Values .= ', `ModifyTime` = NOW()';
    90               if($Modified)
     90              if ($Modified)
    9191              {
    9292                // Update user translation
     
    114114              $CompleteParts = 0;
    115115              $Completable = true;
    116               foreach($Group['Items'] as $GroupItem)
     116              foreach ($Group['Items'] as $GroupItem)
    117117              {
    118118                $Columns .= ', `'.$GroupItem['Column'].'`';
    119                 if($GroupItem['Visible'] == 1)
    120                 {
    121                   if($EnglishFound[$GroupItem['Column']] == $EnglishText[$GroupItem['Column']])
     119                if ($GroupItem['Visible'] == 1)
     120                {
     121                  if ($EnglishFound[$GroupItem['Column']] == $EnglishText[$GroupItem['Column']])
    122122                  {
    123123                    // Read form user data
    124                     if(array_key_exists($GroupItem['Column'], $_POST))
     124                    if (array_key_exists($GroupItem['Column'], $_POST))
    125125                    {
    126126                      $Values .= ', "'.$_POST[$GroupItem['Column']].'"';
     
    128128                    } else $Values .= ', "'.addslashes($EnglishFound[$GroupItem['Column']]).'"';
    129129                  } else $Values .= ', "'.addslashes($EnglishFound[$GroupItem['Column']]).'"';
    130                   if((($CompleteParts & (1 << ($GroupItem['Sequence'] - 1))) == 0) and ($EnglishFound[$GroupItem['Column']] != '')) $Completable = false;
     130                  if ((($CompleteParts & (1 << ($GroupItem['Sequence'] - 1))) == 0) and ($EnglishFound[$GroupItem['Column']] != '')) $Completable = false;
    131131                } else
    132132                {
     
    135135                }
    136136              }
    137               if($Completable) $NewComplete = 1; // All parts of text are completed. Make entire text as completed
     137              if ($Completable) $NewComplete = 1; // All parts of text are completed. Make entire text as completed
    138138                else $NewComplete = 0;
    139139              // Update completion status for edited translation item
    140               if($SourceText['ID'] == $EnglishFound['ID'])
     140              if ($SourceText['ID'] == $EnglishFound['ID'])
    141141              {
    142142                $TakeID = $TextID;
    143143                $NewComplete = $Complete; // Our original user text, set complete according user choice
    144                 if($Complete == 1)
    145                 {
    146                   foreach($Group['Items'] as $GroupItem)
    147                     if($GroupItem['Visible'] == 1) $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1));
     144                if ($Complete == 1)
     145                {
     146                  foreach ($Group['Items'] as $GroupItem)
     147                    if ($GroupItem['Visible'] == 1) $CompleteParts |= (1 << ($GroupItem['Sequence'] - 1));
    148148                }
    149149              }
     
    171171      } else $Output .= ShowMessage('Anglický originál k překladu nenalezen.', MESSAGE_CRITICAL);
    172172    } else $Output .= ShowMessage('Zadaná položka nenalezena.', MESSAGE_CRITICAL);
    173     return($Output);
     173    return $Output;
    174174  }
    175175
     
    183183    unset($Message);
    184184    $this->System->ModuleManager->Modules['FrontPage']->HandleLoginForm();
    185     if(isset($Message)) $Output .= ShowMessage($Message, $MessageType);
     185    if (isset($Message)) $Output .= ShowMessage($Message, $MessageType);
    186186
    187187    $GroupId = LoadGroupIdParameter();
    188188    $Group = $TranslationTree[$GroupId];
    189189    $Table = $Group['TablePrefix'];
    190     if($this->System->User->Licence(LICENCE_USER))
    191     {
    192       if(array_key_exists('ID', $_POST) and is_numeric($_POST['ID']))
     190    if ($this->System->User->Licence(LICENCE_USER))
     191    {
     192      if (array_key_exists('ID', $_POST) and is_numeric($_POST['ID']))
    193193      {
    194194        $Entry = $_POST['entry'] * 1;
    195195        $TextID = $_POST['ID'] * 1;
    196196        $Language = $_POST['Language'] * 1;
    197         if(array_key_exists('End', $_POST)) $Complete = 1;
     197        if (array_key_exists('End', $_POST)) $Complete = 1;
    198198          else $Complete = 0;
    199199
     
    207207    {
    208208      // User automatically logged out. Show login dialog and allow to save retry.
    209       if(array_key_exists('ID', $_POST) and array_key_exists('entry', $_POST) and array_key_exists('Language', $_POST) and array_key_exists('user', $_POST))
     209      if (array_key_exists('ID', $_POST) and array_key_exists('entry', $_POST) and array_key_exists('Language', $_POST) and array_key_exists('user', $_POST))
    210210      {
    211211        $Output .= 'Byli jste automaticky odhlášeni. Pro <strong>Uložení překladu</strong> se musíte přihlásit zde:<br /><br />'.
     
    216216          '<input type="hidden" name="Language" value="'.$_POST['Language'].'" />';
    217217
    218         foreach($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)
     218        foreach ($TranslationTree[$GroupId]['Items'] as $Index => $TextItem)
    219219        {
    220           if(array_key_exists($TextItem['Column'], $_POST)) $Value = $_POST[$TextItem['Column']]; else $Value = '';
     220          if (array_key_exists($TextItem['Column'], $_POST)) $Value = $_POST[$TextItem['Column']]; else $Value = '';
    221221          $Output .= '<input id="'.$TextItem['Column'].'" name="'.$TextItem['Column'].'" type="hidden" value="'.htmlspecialchars($Value).'" />';
    222222        }
     
    232232      } else $Output = ShowMessage('Nezadány požadované údaje.', MESSAGE_CRITICAL);
    233233    }
    234     return($Output);
     234    return $Output;
    235235  }
    236236
     
    246246    $redirecting = $DbResult->fetch_assoc();
    247247
    248     switch($redirecting['Redirecting'])
     248    switch ($redirecting['Redirecting'])
    249249    {
    250250      case 1:
     
    254254        break;
    255255      case 2:
    256         if($next <> '')
     256        if ($next <> '')
    257257          $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'.
    258258            'setTimeout("parent.location.href=\''.htmlspecialchars_decode($next).'\'", 1500)'.
     
    260260          break;
    261261      case 3:
    262         if($prev <> '')
     262        if ($prev <> '')
    263263          $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'.
    264264            'setTimeout("parent.location.href=\''.htmlspecialchars_decode($prev).'\'", 1500)'.
     
    269269    $Output .= sprintf(T('You can be redirected automatically from this page. You can set where you want to be transfered here: %s'), '<a href="'.
    270270      $this->System->Link('/options/').'" title="'.T('User settings').'">'.T('Options').'</a>');
    271     return($Output);
     271    return $Output;
    272272  }
    273273}
Note: See TracChangeset for help on using the changeset viewer.