Changeset 102 for trunk


Ignore:
Timestamp:
Feb 18, 2009, 7:47:12 AM (16 years ago)
Author:
george
Message:
  • Upraveno: Optimalizace načítání seznamu překladatelů na stránce Stahování.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/download.php

    r98 r102  
    33session_start();
    44
    5 if(!array_key_exists('ExportSetting', $_SESSION))
    6   $_SESSION['ExportSetting'] = $_COOKIE['ExportSetting'];
     5if(!array_key_exists('ExportSetting', $_SESSION))
     6  if(array_key_exists('ExportSetting', $_COOKIE))
     7    $_SESSION['ExportSetting'] = $_COOKIE['ExportSetting'];
     8        else $_SESSION['ExportSetting'] = array();
    79 
    810setcookie('ExportSetting', $_SESSION['ExportSetting']);
     
    266268</script>');
    267269    echo('<form name="ListUser" action="?action=parameters" method="post">');
    268     $Query = 'SELECT T.user, T.ID, T.TranslatedCount FROM (SELECT user, ID, (';
     270
     271    $Columns = '';
     272    $Joins = '';
    269273    foreach($TranslationTree as $Group)
    270274      if($Group['TablePrefix'] != '')
    271         $Query .= '(SELECT COUNT(*) FROM '.$Group['TablePrefix'].' WHERE (user = user.ID) AND (Complete = 1) AND (Language <> 0)) + ';
    272     $Query .= ' 0) AS TranslatedCount FROM `user` ORDER BY user) AS T WHERE T.TranslatedCount > 0 ORDER BY T.TranslatedCount DESC';
    273     //echo($Query);
    274         $ID = $Database->SQLCommand($Query);
    275        
     275      {
     276            $Columns .= 'COALESCE(T'.$Group['Id'].'.Count, 0) + ';
     277        $Joins .= ' LEFT JOIN (SELECT User, COUNT(User) as Count FROM `'.$Group['TablePrefix'].'` WHERE (Complete = 1) AND (Language <> 0) GROUP BY User) as T'.$Group['Id'].' ON user.ID=T'.$Group['Id'].'.User';
     278      }
     279
     280    $Query = 'SELECT T.ID, T.TranslatedCount, T.user FROM (SELECT user.ID, user.user, ('.substr($Columns, 0, -3).') as TranslatedCount FROM `user`'.$Joins.') AS T WHERE T.TranslatedCount > 0 ORDER BY T.TranslatedCount DESC';
     281    $ID = $Database->SQLCommand($Query);
     282
    276283        // Rebuild user order list
    277284        $Users = array();
    278         while($Line = mysql_fetch_array($ID)) $Users[$Line['ID']] = $Line;
     285        while($Line = mysql_fetch_assoc($ID)) $Users[$Line['ID']] = $Line;
    279286        $UsersOrder = explode(',', $ExportSetting['users-order']);
    280287        foreach($Users as $User)
Note: See TracChangeset for help on using the changeset viewer.