Changeset 27572


Ignore:
Timestamp:
03/06/14 21:54:48 (5 years ago)
Author:
rvelices
Message:

small code rewrite on history search page (still memory issues for large number of lines in history)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/history.php

    r27240 r27572  
    226226  } 
    227227 
     228  /*TODO - no need to get a huge number of rows from db (should take only what needed for display + SQL_CALC_FOUND_ROWS*/ 
    228229  $data = trigger_event('get_history', array(), $page['search'], $types); 
    229230  usort($data, 'history_compare'); 
     
    285286  WHERE id IN ('.implode(',', array_keys($category_ids)).') 
    286287;'; 
    287     $uppercats_of = simple_hash_from_query($query, 'id', 'uppercats'); 
     288    $uppercats_of = query2array($query, 'id', 'uppercats'); 
    288289 
    289290    $name_of_category = array(); 
     
    310311  WHERE id IN ('.implode(',', array_keys($image_ids)).') 
    311312;'; 
    312     // $label_of_image = simple_hash_from_query($query, 'id', 'label'); 
    313     $label_of_image = array(); 
    314     $filesize_of_image = array(); 
    315     $file_of_image = array(); 
    316     $path_of_image = array(); 
    317     $representative_ext_of_image = array(); 
    318  
    319     $result = pwg_query($query); 
    320     while ($row = pwg_db_fetch_assoc($result)) 
    321     { 
    322       $label_of_image[ $row['id'] ] = trigger_event('render_element_description', $row['label']); 
    323  
    324       if (isset($row['filesize'])) 
    325       { 
    326         $filesize_of_image[ $row['id'] ] = $row['filesize']; 
    327       } 
    328  
    329       $file_of_image[ $row['id'] ] = $row['file']; 
    330       $path_of_image[ $row['id'] ] = $row['path']; 
    331       $representative_ext_of_image[ $row['id'] ] = $row['representative_ext']; 
    332     } 
     313    $image_infos = query2array($query, 'id'); 
    333314  } 
    334315 
     
    361342    if (isset($line['image_type']) and $line['image_type'] == 'high') 
    362343    { 
    363       if (isset($filesize_of_image[$line['image_id']])) 
    364       { 
    365         $summary['total_filesize'] += $filesize_of_image[$line['image_id']]; 
    366       } 
     344      $summary['total_filesize'] += @intval($image_infos[$line['image_id']]['filesize']); 
    367345    } 
    368346 
     
    422400        ); 
    423401 
    424       if (isset($file_of_image[$line['image_id']])) 
     402      if (isset($image_infos[$line['image_id']])) 
    425403      { 
    426404        $element = array( 
    427405          'id' => $line['image_id'], 
    428           'file' => $file_of_image[$line['image_id']], 
    429           'path' => $path_of_image[$line['image_id']], 
    430           'representative_ext' => $representative_ext_of_image[$line['image_id']], 
     406          'file' => $image_infos[$line['image_id']]['file'], 
     407          'path' => $image_infos[$line['image_id']]['path'], 
     408          'representative_ext' => $image_infos[$line['image_id']]['representative_ext'], 
    431409          ); 
    432410        $thumbnail_display = $page['search']['fields']['display_thumbnail']; 
     
    439417      $image_title = '('.$line['image_id'].')'; 
    440418 
    441       if (isset($label_of_image[$line['image_id']])) 
     419      if (isset($image_infos[$line['image_id']]['label'])) 
    442420      { 
    443         $image_title.= ' '.$label_of_image[$line['image_id']]; 
     421        $image_title.= ' '.trigger_event('render_element_description', $image_infos[$line['image_id']]['label']); 
    444422      } 
    445423      else 
     
    660638$template->assign( 
    661639  array( 
    662     'user_options' => simple_hash_from_query($query, 'id','username'), 
     640    'user_options' => query2array($query, 'id','username'), 
    663641    'user_options_selected' => array(@$form['user']) 
    664642  ) 
Note: See TracChangeset for help on using the changeset viewer.