Ignore:
Timestamp:
Feb 1, 2010, 9:49:50 PM (15 years ago)
Author:
george
Message:
  • Opraveno: Chyba zobrazování seznamu překladů. Nově přepracován a sjednocen systém stránkování překladů s využitím funkce GetPageList.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/TranslationList.php

    r311 r315  
    33include('includes/global.php');
    44
    5 ShowPage();
    6 
    7 $TranslationItemPerPage = 200;
    8 $GroupId = LoadGroupIdParameter();
    9 if(array_key_exists('connexion_id', $_GET)) {
    10   $_SESSION['connexion_id'] = $_GET['connexion_id'];
    11 }
    12 $Table = $TranslationTree[$GroupId]['TablePrefix'];
    13 if(array_key_exists('action', $_GET)) $Action = $_GET['action']; else $Action = '';
    14 
    15 $ID = mysql_fetch_row($Database->SQLCommand('SELECT max(VersionEnd) FROM '.$TranslationTree[$GroupId]['TablePrefix']));
    16 $BuildNumber_max = $ID[0];
    17 
    18 if(($Action != 'userall') and ($Action != 'grouplist'))
    19   echo('Skupina: <strong>'.$TranslationTree[$GroupId]['Name'].'</strong><br />');
    20 
    21 function WritePages($Address, $Where)
    22 {
    23   global $Database, $TranslationItemPerPage, $Table;
    24    
    25   $Line = mysql_fetch_row($Database->SQLCommand('SELECT count(*) FROM '.$Table.' '.$Where));       
    26   $CountLists = $Line[0] / $TranslationItemPerPage;
    27        
    28   echo('Počet položek: <strong>'.$Line[0].'</strong><br />
    29     Zobrazit stránku: ');
    30 
    31   $limitx = 0;
    32   for($i = 0; $i < $CountLists; ++$i)
    33   {
    34     $limity = $TranslationItemPerPage;
    35     $limitx = $i * $limity;
    36     $Page = $i + 1;
    37     if($_SESSION['limitx'] == $limitx) echo('<strong>'.$Page.'</strong> ');
    38       else echo('<a href="'.$Address.'&amp;limitx='.$limitx.'&amp;limity='.$limity.'">'.$Page.'</a> ');
    39   }
    40        
    41   if(!array_key_exists('limitx', $_SESSION)) $_SESSION['limitx'] = 0;
    42   if($_SESSION['limitx'] > $limitx) $_SESSION['limitx'] = 0; 
    43 }
    44 
    45 function WriteQuests($sql, $limit, $address)
    46 {
    47   global $Database, $order, $desc, $TranslationTree, $GroupId, $Table;
     5function WriteQuests($Query)
     6{
     7  global $Database, $TranslationTree, $GroupId, $Table, $Action;
    488 
    49   // Check if order column exists
    50   $Items = $TranslationTree[$GroupId]['Items'];
    51   $I = 0;
    52   while(($I < count($Items)) and ($Items[$I]['MangosColumn'] != $order)) $I++;
    53   if($I >= count($Items)) $order = 'ID';       
    54 
    55   if($limit <> '') $limit = 'LIMIT '.$limit;
    56 
    57   if($address <> 'selection')
    58   {
    59     if($order <> '') $order = 'ORDER BY '.$order;
    60     if($desc <> 'desc') $desc = 'desc'; else $desc = '';
    61   } else
    62   {
    63     $order = '';
    64     $desc = '';
    65   }
    66  
     9  // Get total item count
     10  $DbResult = $Database->SQLCommand('SELECT COUNT(*) FROM ('.$Query.') AS T');
     11  $DbRow = mysql_fetch_row($DbResult);
     12  $PageList = GetPageList($DbRow[0]);   
     13 
     14  echo($PageList['Output']);
     15
    6716  $TableColumns = array(
    6817    array('Name' => 'ID', 'Title' => 'Pořadové číslo'),
     
    7120    array('Name' => 'VersionStart', 'Title' => 'Verze'),
    7221  );
    73   if($address == 'selection') $TableColumns[] = array('Name' => 'CountQuests', 'Title' => 'Výskyt');
    74   else if($address == 'connexion') $TableColumns[] = array('Name' => '', 'Title' => 'Již přeložil');
    75   else if($address <> 'notran') $TableColumns[] = array('Name' => 'User', 'Title' => 'Překladatel');
     22  if($Action == 'selection') $TableColumns[] = array('Name' => 'CountQuests', 'Title' => 'Výskyt');
     23  else if($Action == 'connexion') $TableColumns[] = array('Name' => '', 'Title' => 'Již přeložil');
     24  else if($Action <> 'notran') $TableColumns[] = array('Name' => 'UserName', 'Title' => 'Překladatel');
    7625   
    7726  $Order = GetOrderTableHeader($TableColumns, 'VersionStart', 1);
     
    7928  echo($Order['Output']);
    8029   
    81   //print_r($TranslationTree[$GroupId]['Items']);
    82   $ID = $Database->SQLCommand($sql.' '.$Order['SQL'].' '.$limit);
    83   while($Line = mysql_fetch_assoc($ID))
    84   {
    85     //print_r($Line);
    86   echo('<tr><td><a href="form.php?group='.$GroupId.'&amp;ID='.$Line['ID'].'">'.$Line['ID'].'</a></td>
    87       <td>'.$Line['entry'].'</td>
    88       <td>'.htmlspecialchars($Line[$TranslationTree[$GroupId]['Items'][0]['Column']]).'</td>
    89     <td>'.GetVersionWOW($Line['VersionStart']).'-'.GetVersionWOW($Line['VersionEnd']).'</td>');
    90     if($address == 'selection') echo('<td>'.$Line['CountQuest'].'</td>');
    91   else if($address <> 'notran') echo('<td>'.$Line['User'].'</td>');
     30  $DbResult = $Database->SQLCommand($Query.' '.$Order['SQL'].' '.$PageList['SQLLimit']);
     31  while($Line = mysql_fetch_assoc($DbResult))
     32  {
     33    echo('<tr><td><a href="form.php?group='.$GroupId.'&amp;ID='.$Line['ID'].'">'.$Line['ID'].'</a></td><td>'.$Line['entry'].'</td>'.
     34      '<td>'.htmlspecialchars($Line[$TranslationTree[$GroupId]['Items'][0]['Column']]).'</td>'.
     35      '<td>'.GetVersionWOW($Line['VersionStart']).'-'.GetVersionWOW($Line['VersionEnd']).'</td>');
     36    if($Action == 'selection') echo('<td>'.$Line['CountQuest'].'</td>');
     37      else if($Action <> 'notran') echo('<td>'.$Line['User'].'</td>');
    9238    echo('</tr>');
    9339  }
    9440  echo('</table>');     
     41 
     42  echo($PageList['Output']);
    9543}
    9644
     
    10351        <strong>Vypsání nepřeložených textů s limitem na stránku</strong><br /><br />');
    10452
    105   WritePages('?group='.$GroupId.'&amp;action=notran', 'AS items WHERE items.Language = 0 AND
    106     NOT EXISTS(SELECT 1 FROM '.$Table.' AS sub WHERE sub.Language <> 0 AND sub.entry = items.entry AND VersionEnd = "'.$BuildNumber_max.'"  AND VersionEnd = "'.$BuildNumber_max.'")');
    107 
    10853  WriteQuests('SELECT * FROM '.$Table.' AS items WHERE (items.Language = 0) AND
    109     NOT EXISTS(SELECT 1 FROM '.$Table.' AS sub WHERE (sub.Language <> 0) AND (sub.entry = items.entry)  AND VersionEnd = "'.$BuildNumber_max.'" AND VersionEnd = "'.$BuildNumber_max.'")', $_SESSION['limitx'].','.$_SESSION['limity'], 'notran');
     54    NOT EXISTS(SELECT 1 FROM '.$Table.' AS sub WHERE (sub.Language <> 0) AND (sub.entry = items.entry) AND VersionEnd = "'.$BuildNumber_max.'" AND VersionEnd = "'.$BuildNumber_max.'")');
    11055}
    11156
     
    11459  global $GroupId, $Table, $BuildNumber_max, $Database;
    11560 
     61  if(array_key_exists('connexion_id', $_GET)) $_SESSION['connexion_id'] = $_GET['connexion_id'];
     62
    11663 //SELECT * FROM spell WHERE entry IN(SELECT entry FROM connexion_item WHERE connexion = 1)
    11764  $Line = mysql_fetch_assoc($Database->SQLCommand('SELECT Name FROM connexion WHERE `Id` = '.$_SESSION['connexion_id']));
     
    12067        <strong>Vypsání souvislostí ze skupiny '.$Line['Name'].'</strong><br /><br />');
    12168
    122   WritePages('?group='.$GroupId.'&amp;action=connexion', ' WHERE Language = 0 AND entry IN(SELECT entry FROM connexion_item WHERE connexion = '.$_SESSION['connexion_id'].') AND VersionEnd = "'.$BuildNumber_max.'" AND VersionEnd = "'.$BuildNumber_max.'"');
    123    WriteQuests('SELECT *, (SELECT sub.User FROM '.$Table.' as sub WHERE sub.entry  = '.$Table.'.entry AND Language <> 0 LIMIT 1) as UserID, (SELECT user.user FROM user WHERE user.id = UserID) as User FROM '.$Table.' WHERE Language = 0 AND entry IN(SELECT entry FROM connexion_item WHERE connexion = '.$_SESSION['connexion_id'].') AND VersionEnd = "'.$BuildNumber_max.'" AND VersionEnd = "'.$BuildNumber_max.'"', $_SESSION['limitx'].','.$_SESSION['limity'], 'connexion');
     69   WriteQuests('SELECT *, (SELECT sub.User FROM '.$Table.' as sub WHERE sub.entry  = '.$Table.'.entry AND Language <> 0 LIMIT 1) as UserID, (SELECT user.user FROM user WHERE user.id = UserID) AS UserName FROM '.$Table.' WHERE Language = 0 AND entry IN(SELECT entry FROM connexion_item WHERE connexion = '.$_SESSION['connexion_id'].') AND VersionEnd = "'.$BuildNumber_max.'" AND VersionEnd = "'.$BuildNumber_max.'"');
    12470}
    12571
     
    15197        <strong>Vypsání nedokončených textů s limitem na stránku</strong><br /><br />');
    15298
    153   WritePages('?group='.$GroupId.'&amp;action=notran', 'AS items WHERE items.Language = 0 AND
    154     NOT EXISTS(SELECT 1 FROM '.$Table.' AS sub WHERE (sub.Language <> 0) AND (sub.entry = items.entry)  AND (sub.Complete = 1) AND VersionEnd = "'.$BuildNumber_max.'") AND
    155     EXISTS(SELECT 1 FROM '.$Table.' AS sub WHERE sub.Language <> 0 AND sub.entry = items.entry  AND (sub.Complete = 0) AND VersionEnd = "'.$BuildNumber_max.'") AND VersionEnd = "'.$BuildNumber_max.'"');
    156 
    15799  WriteQuests('SELECT * FROM '.$Table.' AS items WHERE (items.Language = 0) AND
    158100    NOT EXISTS(SELECT 1 FROM '.$Table.' AS sub WHERE (sub.Language <> 0) AND (sub.entry = items.entry)  AND (sub.Complete = 1) AND VersionEnd = "'.$BuildNumber_max.'") AND
    159    EXISTS(SELECT 1 FROM '.$Table.' AS sub WHERE (sub.Language <> 0) AND (sub.entry = items.entry)  AND (sub.Complete = 0) AND VersionEnd = "'.$BuildNumber_max.'") AND VersionEnd = "'.$BuildNumber_max.'"', $_SESSION['limitx'].','.$_SESSION['limity'], 'nocomplete');
     101   EXISTS(SELECT 1 FROM '.$Table.' AS sub WHERE (sub.Language <> 0) AND (sub.entry = items.entry)  AND (sub.Complete = 0) AND VersionEnd = "'.$BuildNumber_max.'") AND VersionEnd = "'.$BuildNumber_max.'"');
    160102}
    161103
     
    167109     <a title="Přeložené texty, můžete zde hlasovat, nebo opravovat texty" href="?group='.$GroupId.'&amp;action=Translate">Přeložené texty</a><br /><br />');
    168110     
    169   WritePages('?group='.$GroupId.'&amp;action=Translate', 'WHERE '.$Table.'.Language <> 0 AND '.$Table.'.Complete = 1');
    170        
    171   WriteQuests('SELECT *, (SELECT user.user FROM user WHERE user.id = '.$Table.'.user) as User FROM
    172     '.$Table.' WHERE '.$Table.'.Language <> 0 AND '.$Table.'.Complete = 1', $_SESSION['limitx'].','.$_SESSION['limity'], 'Translate');}
     111  WriteQuests('SELECT `'.$Table.'`.*, `user`.`user` AS `UserName` FROM `'.$Table.'` JOIN `user` ON `user`.`id` = `'.$Table.'`.`User` WHERE (`'.$Table.'`.`Language` <> 0) AND (`'.$Table.'`.`Complete` = 1)');
     112}
    173113
    174114function UserTranslated()
     
    178118  echo('<a title="Zobrazit texty podle vlastního filtru" href="?group='.$GroupId.'&amp;action=filter">Filtr textů</a> ->
    179119        <a title="Přeložené questy přilášeného uživatele" href="?group='.$GroupId.'&amp;action=my">Moje překlady</a><br /><br />');
    180   WriteQuests('SELECT *, (SELECT `user`.`user` FROM `user` WHERE `user`.`id` = '.$Table.'.`user`) AS `User` FROM `'.$Table.'` Where `user` = '.$_SESSION['UserID'], '', 'my');
     120  WriteQuests('SELECT *, (SELECT `user`.`user` FROM `user` WHERE `user`.`id` = '.$Table.'.`user`) AS `UserName` FROM `'.$Table.'` Where `user` = '.$_SESSION['UserID']);
    181121}
    182122
     
    187127  echo('<a title="Zobrazit texty podle vlastního filtru" href="?group='.$GroupId.'&amp;action=filter">Filtr textů</a> ->
    188128    <a title="Nedokončené texty" href="?group='.$GroupId.'&amp;action=mydevelop">Rozepsané překlady</a><br /><br />');
    189   WriteQuests('SELECT *, (SELECT `user`.`user` FROM `user` WHERE `user`.`id` = `'.$Table.'`.`user`) AS `User` FROM `'.$Table.'` Where `user` = '.$_SESSION['UserID'].' AND `Complete` = 0', '', 'mydevelop');
     129  WriteQuests('SELECT *, (SELECT `user`.`user` FROM `user` WHERE `user`.`id` = `'.$Table.'`.`user`) AS `UserName` FROM `'.$Table.'` WHERE `user` = '.$_SESSION['UserID'].' AND `Complete` = 0');
    190130}
    191131
     
    207147  if($WhereUsers == '') $WhereUsers = '0'; 
    208148 
    209   WriteQuests('SELECT *, (SELECT `user`.`user` FROM `user` WHERE `user`.`id` = `'.$Table.'`.`user`) AS `User` FROM `'.$Table.'` WHERE '.$WhereUsers, '', 'users');
     149  WriteQuests('SELECT *, (SELECT `user`.`user` FROM `user` WHERE `user`.`id` = `'.$Table.'`.`user`) AS `UserName` FROM `'.$Table.'` WHERE '.$WhereUsers);
    210150}
    211151
     
    291231        '<strong>Vypis překladů uživatele '.$Line[0].': </strong><br /><br />');
    292232      if(array_key_exists('not', $_GET))
    293         WriteQuests('SELECT *, (SELECT `user`.`user` FROM `user` WHERE `user`.`id` = `'.$Table.'`.`user`) AS `User` FROM `'.$Table.'` Where `Complete` = 0 AND `user` = '.$_GET['user'], '', 'userid');
    294       else WriteQuests('SELECT *, (SELECT `user`.`user` FROM `user` WHERE `user`.`id` = `'.$Table.'`.`user`) AS `User` FROM `'.$Table.'` Where `user` = '.$_GET['user'], '', 'userid');
     233        WriteQuests('SELECT *, (SELECT `user`.`user` FROM `user` WHERE `user`.`id` = `'.$Table.'`.`user`) AS `UserName` FROM `'.$Table.'` Where `Complete` = 0 AND `user` = '.$_GET['user']);
     234      else WriteQuests('SELECT *, (SELECT `user`.`user` FROM `user` WHERE `user`.`id` = `'.$Table.'`.`user`) AS `UserName` FROM `'.$Table.'` Where `user` = '.$_GET['user']);
    295235    } else echo('Nebyl nalezen uživatel se zadaným id');
    296236  } else echo('Je nutno zadat id uživatele.');
     
    305245  else ErrorMessage('Nebyl zadán text k vyhledání.');
    306246 
    307   $sql = 'SELECT *, (SELECT `user`.`user` FROM `user` WHERE `user`.`id` = `'.$Table.'`.`user`) AS `User` FROM `'.$Table.'` WHERE `ID` LIKE "%'.$Search.'%"
     247  $sql = 'SELECT *, (SELECT `user`.`user` FROM `user` WHERE `user`.`id` = `'.$Table.'`.`user`) AS `UserName` FROM `'.$Table.'` WHERE `ID` LIKE "%'.$Search.'%"
    308248    OR `entry` LIKE "%'.$Search.'%"
    309249    OR `Language` LIKE "%'.$Search.'%"
     
    315255  }
    316256   
    317   WriteQuests($sql, '', 'search='.$Search);
     257  WriteQuests($sql);
    318258}
    319259
     
    326266  else $Search = '';
    327267 
    328   $sql = 'SELECT *, (SELECT `user`.`user` FROM `user` WHERE `user`.`id` = `'.$Table.'`.`user`) AS `User` FROM `'.$Table.'` WHERE `entry` LIKE "'.$Search.'"';
     268  $sql = 'SELECT *, (SELECT `user`.`user` FROM `user` WHERE `user`.`id` = `'.$Table.'`.`user`) AS `UserName` FROM `'.$Table.'` WHERE `entry` LIKE "'.$Search.'"';
    329269   
    330   WriteQuests($sql, '', 'searchentry='.$Search);
     270  WriteQuests($sql);
    331271}
    332272
     
    339279        <strong>Výpis všech textů s limitem na stránku</strong><br /><br />');
    340280
    341   WritePages('?group='.$GroupId.'&amp;action=all', ' AS `items` WHERE (`items`.`Language` = 0)');
    342 
    343   WriteQuests('SELECT * FROM `'.$Table.'` AS `items` WHERE (`items`.`Language` = 0)', $_SESSION['limitx'].','.$_SESSION['limity'], 'all');
     281  WriteQuests('SELECT * FROM `'.$Table.'` AS `items` WHERE (`items`.`Language` = 0)');
    344282}
    345283
     
    396334  //  WriteQuests("SELECT * FROM quests Where user = ".$_SESSION['UserID']." AND Complete = '0'", '', 'mydevelop');
    397335}
     336
     337
     338ShowPage();
     339
     340$GroupId = LoadGroupIdParameter();
     341$Table = $TranslationTree[$GroupId]['TablePrefix'];
     342if(array_key_exists('action', $_GET)) $Action = $_GET['action']; else $Action = '';
     343
     344$ID = mysql_fetch_row($Database->SQLCommand('SELECT max(VersionEnd) FROM '.$TranslationTree[$GroupId]['TablePrefix']));
     345$BuildNumber_max = $ID[0];
     346
     347if(($Action != 'userall') and ($Action != 'grouplist'))
     348  echo('Skupina: <strong>'.$TranslationTree[$GroupId]['Name'].'</strong><br />');
    398349
    399350if($Action == 'notran') Nontranslated();
Note: See TracChangeset for help on using the changeset viewer.