Show
Ignore:
Timestamp:
03/09/07 17:28:49 (6 years ago)
Author:
plg
Message:

New: #images.high_filesize was added so that we can sum the filesizes in the
filtered history. #images.high_filesize is filled during metadata
synchronization.

Bug fixed: in getAttribute XML function, when asking "filesize", it was
returning high_filesize. The regex was too simple.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/admin/history.php

    r1881 r1883  
    228228   
    229229  $query = ' 
    230 SELECT COUNT(*) 
    231   FROM '.HISTORY_TABLE.' 
    232   WHERE '.$where_separator.' 
    233 ;'; 
    234  
    235   // echo '<pre>'.$query.'</pre>'; 
    236    
    237   list($page['nb_lines']) = mysql_fetch_row(pwg_query($query)); 
    238  
    239   $query = ' 
    240230SELECT 
    241231    date, 
     
    250240  FROM '.HISTORY_TABLE.' 
    251241  WHERE '.$where_separator.' 
    252   LIMIT '.$page['start'].', '.$conf['nb_logs_page'].' 
    253242;'; 
    254243 
     244  // LIMIT '.$page['start'].', '.$conf['nb_logs_page'].' 
     245 
    255246  $result = pwg_query($query); 
    256   $history_lines = $user_ids = $category_ids = $image_ids = array(); 
     247 
     248  $page['nb_lines'] = mysql_num_rows($result); 
     249   
     250  $history_lines = array(); 
     251  $user_ids = array(); 
     252  $category_ids = array(); 
     253  $image_ids = array(); 
     254  $tag_ids = array(); 
     255   
    257256  while ($row = mysql_fetch_assoc($result)) 
    258257  { 
     
    315314  { 
    316315    $query = ' 
    317 SELECT id, IF(name IS NULL, file, name) AS label 
     316SELECT 
     317    id, 
     318    IF(name IS NULL, file, name) AS label, 
     319    filesize, 
     320    high_filesize 
    318321  FROM '.IMAGES_TABLE.' 
    319322  WHERE id IN ('.implode(',', array_keys($image_ids)).') 
    320323;'; 
    321     $label_of_image = simple_hash_from_query($query, 'id', 'label'); 
     324    // $label_of_image = simple_hash_from_query($query, 'id', 'label'); 
     325    $label_of_image = array(); 
     326    $filesize_of_image = array(); 
     327    $high_filesize_of_image = array(); 
     328     
     329    $result = pwg_query($query); 
     330    while ($row = mysql_fetch_array($result)) 
     331    { 
     332      $label_of_image[ $row['id'] ] = $row['label']; 
     333 
     334      if (isset($row['filesize'])) 
     335      { 
     336        $filesize_of_image[ $row['id'] ] = $row['filesize']; 
     337      } 
     338 
     339      if (isset($row['high_filesize'])) 
     340      { 
     341        $high_filesize_of_image[ $row['id'] ] = $row['high_filesize']; 
     342      } 
     343    } 
     344 
     345    // echo '<pre>'; print_r($high_filesize_of_image); echo '</pre>'; 
    322346  } 
    323347   
    324348  $i = 0; 
     349  $first_line = $page['start'] + 1; 
     350  $last_line = $page['start'] + $conf['nb_logs_page']; 
     351 
     352  $total_filesize = 0; 
    325353 
    326354  foreach ($history_lines as $line) 
    327355  { 
     356    if (isset($line['image_type'])) 
     357    { 
     358      if ($line['image_type'] == 'high') 
     359      { 
     360        if (isset($high_filesize_of_image[$line['image_id']])) 
     361        { 
     362          $total_filesize+= $high_filesize_of_image[$line['image_id']]; 
     363        } 
     364      } 
     365      else 
     366      { 
     367        if (isset($filesize_of_image[$line['image_id']])) 
     368        { 
     369          $total_filesize+= $filesize_of_image[$line['image_id']]; 
     370        } 
     371      } 
     372    } 
     373     
     374    $i++; 
     375     
     376    if ($i < $first_line or $i > $last_line) 
     377    { 
     378      continue; 
     379    } 
     380     
    328381    $template->assign_block_vars( 
    329382      'detail', 
     
    338391        'IMAGE'     => isset($line['image_id']) 
    339392          ? ( isset($label_of_image[$line['image_id']]) 
    340                 ? $label_of_image[$line['image_id']] 
    341                 : 'deleted '.$line['image_id']) 
    342           : $line['image_id'], 
     393                ? sprintf( 
     394                    '(%u) %s', 
     395                    $line['image_id'], 
     396                    $label_of_image[$line['image_id']] 
     397                  ) 
     398                : sprintf( 
     399                    '(%u) deleted ', 
     400                    $line['image_id'] 
     401                  ) 
     402            ) 
     403          : '', 
    343404        'TYPE'      => $line['image_type'], 
    344405        'SECTION'   => $line['section'], 
     
    349410          : '', 
    350411        'TAGS'       => $line['tag_ids'], 
    351         'T_CLASS'   => ($i++ % 2) ? 'row1' : 'row2', 
     412        'T_CLASS'   => ($i % 2) ? 'row1' : 'row2', 
    352413        ) 
    353414      ); 
    354415  } 
     416 
     417  $template->assign_block_vars( 
     418    'summary', 
     419    array( 
     420      'FILESIZE' => $total_filesize.' KB', 
     421      ) 
     422    ); 
    355423} 
    356424