Ignore:
Timestamp:
Apr 10, 2024, 11:49:39 PM (9 months ago)
Author:
chronos
Message:
  • Fixed: More form input fields validation.
  • Modified: Code cleanup.
File:
1 edited

Legend:

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

    r893 r900  
    257257
    258258    $Query = 'SELECT `T`.`ModifyTime`, `T`.`ID`, `T`.`Entry`, `T`.`VersionStart`, `T`.`VersionEnd`, '.
    259         '`T`.`'.$TranslationTree[$Filter['Group']]['Items'][0]['Column'].'`, '.
    260         '`User`.`Name` AS `UserName`, `User`.`ID` AS `UserId`, '.
    261         '`Language`.`Name` AS `LanguageName`, `TS`.`Version` AS `VersionStartText`, `TE`.`Version` AS `VersionEndText` '.
    262         'FROM `'.$Table.'` AS `T` '.
    263         'LEFT JOIN `User` ON `User`.`ID` = `T`.`User` '.
    264         'LEFT JOIN `Language` ON `Language`.`ID` = `T`.`Language` '.
    265         'LEFT JOIN `ClientVersion` AS `TS` ON `TS`.`BuildNumber` = `T`.`VersionStart` '.
    266         'LEFT JOIN `ClientVersion` AS `TE` ON `TE`.`BuildNumber` = `T`.`VersionEnd` '.
    267         'WHERE 1 '.$Filter['SQL'];
     259      '`T`.`'.$TranslationTree[$Filter['Group']]['Items'][0]['Column'].'`, '.
     260      '`User`.`Name` AS `UserName`, `User`.`ID` AS `UserId`, '.
     261      '`Language`.`Name` AS `LanguageName`, `TS`.`Version` AS `VersionStartText`, `TE`.`Version` AS `VersionEndText` '.
     262      'FROM `'.$Table.'` AS `T` '.
     263      'LEFT JOIN `User` ON `User`.`ID` = `T`.`User` '.
     264      'LEFT JOIN `Language` ON `Language`.`ID` = `T`.`Language` '.
     265      'LEFT JOIN `ClientVersion` AS `TS` ON `TS`.`BuildNumber` = `T`.`VersionStart` '.
     266      'LEFT JOIN `ClientVersion` AS `TE` ON `TE`.`BuildNumber` = `T`.`VersionEnd` '.
     267      'WHERE 1 '.$Filter['SQL'];
    268268
    269269    // Get total item count
    270     $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `TT`');
     270    $DbResult = $this->Database->query('SELECT COUNT(*) FROM ('.$Query.') AS `TT`');   
    271271    $DbRow = $DbResult->fetch_row();
    272272    $PageList = GetPageList($DbRow[0]);
     
    274274    $Output .= $PageList['Output'];
    275275    $TableColumns = array(
    276         array('Name' => 'ID', 'Title' => T('Number')),
    277         array('Name' => 'Entry', 'Title' => T('Item')),
    278         array('Name' => $TranslationTree[$Filter['Group']]['Items'][0]['Column'], 'Title' => T('Name')),
    279         array('Name' => 'VersionStart', 'Title' => T('From version')),
    280         array('Name' => 'VersionEnd', 'Title' => T('To version')),
    281         array('Name' => 'LanguageName', 'Title' => T('Language')),
    282         array('Name' => 'UserName', 'Title' => T('Translator')),
    283         array('Name' => 'ModifyTime', 'Title' => T('Date')),
     276      array('Name' => 'ID', 'Title' => T('Number')),
     277      array('Name' => 'Entry', 'Title' => T('Item')),
     278      array('Name' => $TranslationTree[$Filter['Group']]['Items'][0]['Column'], 'Title' => T('Name')),
     279      array('Name' => 'VersionStart', 'Title' => T('From version')),
     280      array('Name' => 'VersionEnd', 'Title' => T('To version')),
     281      array('Name' => 'LanguageName', 'Title' => T('Language')),
     282      array('Name' => 'UserName', 'Title' => T('Translator')),
     283      array('Name' => 'ModifyTime', 'Title' => T('Date')),
    284284    );
    285285
    286286    $Order = GetOrderTableHeader($TableColumns, 'VersionStart', 1);
    287287    $Output .= '<table class="BaseTable">'.
    288         $Order['Output'];
     288      $Order['Output'];
    289289
    290290    $DbResult = $this->Database->query($Query.' '.$Order['SQL'].' '.$PageList['SQLLimit']);
    291291    while ($Line = $DbResult->fetch_assoc())
    292292    {
     293      $Text = $Line[$TranslationTree[$Filter['Group']]['Items'][0]['Column']];
     294      if ($Text != null) $Text = htmlspecialchars($Text);
     295
    293296      $Output .= '<tr><td><a href="'.$this->System->Link('/form.php?group='.$Filter['Group'].'&amp;ID='.$Line['ID']).'">'.$Line['ID'].'</a></td>'.
    294297        '<td>'.$Line['Entry'].'</td>'.
    295         '<td>'.htmlspecialchars($Line[$TranslationTree[$Filter['Group']]['Items'][0]['Column']]).'</td>'.
     298        '<td>'.$Text.'</td>'.
    296299        '<td><a href="'.$this->System->Link('/client-version/?action=item&amp;id='.
    297300          GetVersionWOWId($Line['VersionStart'])).'">'.GetVersionWOW($Line['VersionStart']).'</a></td>'.
     
    317320    $Total = 0;
    318321    foreach ($TranslationTree as $Group)
     322    {
    319323      if ($Group['TablePrefix'] != '')
    320324      {
     
    326330        $Total += $Line[0];
    327331      }
    328       $Output .= '<tr><td><strong>'.T('Total').'</strong></td><td><strong>'.$Total.'</strong></td></tr>'.
    329           '</table>';
    330       return $Output;
     332    }
     333    $Output .= '<tr><td><strong>'.T('Total').'</strong></td><td><strong>'.$Total.'</strong></td></tr>'.
     334      '</table>';
     335    return $Output;
    331336  }
    332337
     
    338343    $GroupId = GetParameter('group', 0, true);
    339344    if ($GroupId == 0) $Output = ShowMessage('Skupina nenalezena', MESSAGE_CRITICAL);
    340     else {
     345    else
     346    {
    341347      $Table = $TranslationTree[$GroupId]['TablePrefix'];
    342348
    343349      $Output = '<h3>'.T('Basic text filtering').'</h3><br/>'.
    344           '<table class="BaseTable"><tr><th>'.T('Link').'</th><th>'.T('Description').'</th></tr>'.
    345           '<tr><td><a title="'.T('All texts available in group').'" href="?group='.$GroupId.'&amp;state=4">'.T('All').'</a></td>'.
    346           '<td>'.T('Show all available original texts in group').'</td></tr>'.
    347           '<tr><td><a title="'.T('Translated texts, you can modify them here').'" href="?group='.$GroupId.'&amp;state=2">'.T('Translated').'</a></td>'.
    348           '<td>'.T('Show only translated texts').'</td></tr>'.
    349           '<tr><td><a title="'.T('Untranslated texts').'" href="?group='.$GroupId.'&amp;state=1">'.T('Untranslated').'</a></td>'.
    350           '<td>'.T('Not yet translated texts which need to be translated').'</td></tr>'.
    351           '<tr><td><a title="'.T('Unfinished texts').'" href="?group='.$GroupId.'&amp;state=3">'.T('Unfinished').'</a></td>'.
    352           '<td>'.T('Texts marked as unfinished').'</td></tr>';
     350        '<table class="BaseTable"><tr><th>'.T('Link').'</th><th>'.T('Description').'</th></tr>'.
     351        '<tr><td><a title="'.T('All texts available in group').'" href="?group='.$GroupId.'&amp;state=4">'.T('All').'</a></td>'.
     352        '<td>'.T('Show all available original texts in group').'</td></tr>'.
     353        '<tr><td><a title="'.T('Translated texts, you can modify them here').'" href="?group='.$GroupId.'&amp;state=2">'.T('Translated').'</a></td>'.
     354        '<td>'.T('Show only translated texts').'</td></tr>'.
     355        '<tr><td><a title="'.T('Untranslated texts').'" href="?group='.$GroupId.'&amp;state=1">'.T('Untranslated').'</a></td>'.
     356        '<td>'.T('Not yet translated texts which need to be translated').'</td></tr>'.
     357        '<tr><td><a title="'.T('Unfinished texts').'" href="?group='.$GroupId.'&amp;state=3">'.T('Unfinished').'</a></td>'.
     358        '<td>'.T('Texts marked as unfinished').'</td></tr>';
    353359
    354360      if ($User->Licence(LICENCE_USER))
     
    361367
    362368      $Output .= '<tr><td><form action="?group='.$GroupId.'&amp;entry=" method="post"><div>'.
    363           '<input type="text" name="text" size="8" />'.
    364           '<input type="submit" value="'.T('Search').'" />'.
    365           '</div></form>'.
    366           '</td><td>'.T('Search using text').'</td></tr>';
     369        '<input type="text" name="text" size="8" />'.
     370        '<input type="submit" value="'.T('Search').'" />'.
     371        '</div></form>'.
     372        '</td><td>'.T('Search using text').'</td></tr>';
    367373
    368374      $Output .= '<tr><td><form action="?group='.$GroupId.'&amp;text=" method="post"><div>'.
    369           '<input type="text" name="entry" size="8" />'.
    370           '<input type="submit" value="'.T('Search').'" />'.
    371           '</div></form>'.
    372           '</td><td>'.T('Show by datbase text ID').'</td></tr>';
     375        '<input type="text" name="entry" size="8" />'.
     376        '<input type="submit" value="'.T('Search').'" />'.
     377        '</div></form>'.
     378        '</td><td>'.T('Show by datbase text ID').'</td></tr>';
    373379
    374380      $Output .= '</table>';
     
    396402  function ShowList()
    397403  {
    398     $User = ModuleUser::Cast($this->System->GetModule('User'))->User;
     404    $User = ModuleUser::Cast($this->System->GetModule('User'))->User;   
    399405    $DbResult = $this->Database->query('SELECT COUNT(*) FROM `Group`');
    400406    $DbRow = $DbResult->fetch_row();
     
    448454    {
    449455      $Output = '<h3>Vložení nové překladové skupiny</h3>'.
    450           '<form action="?action=groupaddfinish" method="post">'.
    451           '<table>'.
    452           '<tr><td>Název:</td><td><input type="text" name="Name"/></td></tr>'.
    453           '<tr><td>Název tabulky v databázi:</td><td>Text<input type="text" name="TablePrefix"/></td></tr>'.
    454           '<tr><td colspan="2"><input type="submit" name="add" value="Přidat"/></td></tr>'.
    455           '</table></form>';
     456        '<form action="?action=groupaddfinish" method="post">'.
     457        '<table>'.
     458        '<tr><td>Název:</td><td><input type="text" name="Name"/></td></tr>'.
     459        '<tr><td>Název tabulky v databázi:</td><td>Text<input type="text" name="TablePrefix"/></td></tr>'.
     460        '<tr><td colspan="2"><input type="submit" name="add" value="Přidat"/></td></tr>'.
     461        '</table></form>';
    456462    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    457463    return $Output;
Note: See TracChangeset for help on using the changeset viewer.