Changeset 1883 for trunk/admin


Ignore:
Timestamp:
Mar 9, 2007, 5:28:49 PM (17 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.

Location:
trunk/admin
Files:
6 edited

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
  • trunk/admin/include/functions_metadata.php

    r1717 r1883  
    106106  $datas = array();
    107107  $tags_of = array();
     108  $has_high_images = array();
     109
     110  $image_ids = array();
     111  foreach ($files as $id => $file)
     112  {
     113    array_push($image_ids, $id);
     114  }
     115 
     116  $query = '
     117SELECT id
     118  FROM '.IMAGES_TABLE.'
     119  WHERE has_high = \'true\'
     120    AND id IN (
     121'.wordwrap(implode(', ', $image_ids), 80, "\n").'
     122)
     123;';
     124
     125  $result = pwg_query($query);
     126  while ($row = mysql_fetch_array($result))
     127  {
     128    array_push($has_high_images, $row['id']);
     129  }
    108130
    109131  foreach ($files as $id => $file)
     
    117139      $data['width'] = $image_size[0];
    118140      $data['height'] = $image_size[1];
     141    }
     142
     143    if (in_array($id, $has_high_images))
     144    {
     145      $high_file = dirname($file).'/pwg_high/'.basename($file);
     146
     147      $data['high_filesize'] = floor(filesize($high_file)/1024);
    119148    }
    120149 
     
    162191        'width',
    163192        'height',
     193        'high_filesize',
    164194        'date_metadata_update'
    165195        );
  • trunk/admin/picture_modify.php

    r1861 r1883  
    263263  );
    264264
     265if ($row['has_high'] == 'true')
     266{
     267  $template->assign_block_vars(
     268    'high',
     269    array(
     270      'FILESIZE' => isset($row['high_filesize'])
     271        ? $row['high_filesize'].' KB'
     272        : l10n('unknown'),
     273      )
     274    );
     275}
     276
    265277// creation date
    266278unset($day, $month, $year);
  • trunk/admin/site_reader_local.php

    r1717 r1883  
    158158  global $conf;
    159159
    160   $update_fields = array('filesize', 'width', 'height');
     160  $update_fields = array('filesize', 'width', 'height', 'high_filesize');
    161161
    162162  if ($conf['use_exif'])
     
    182182
    183183// returns a hash of attributes (metadata+filesize+width,...) for file
    184 function get_element_metadata($file)
     184function get_element_metadata($file, $has_high = false)
    185185{
    186186  global $conf;
     
    200200  }
    201201
     202  if ($has_high)
     203  {
     204    $high_file = dirname($file).'/pwg_high/'.basename($file);
     205   
     206    $data['high_filesize'] = floor(filesize($high_file)/1024);
     207  }
     208 
    202209  if ($conf['use_exif'])
    203210  {
  • trunk/admin/site_reader_remote.php

    r1204 r1883  
    4848    );
    4949  $this->metadata_attributes = array(
    50     'filesize', 'width', 'height'
     50    'filesize', 'width', 'height', 'high_filesize'
    5151    );
    5252
     
    8989    }
    9090
    91     $this->metadata_attributes = array_merge(
    92       $this->metadata_attributes,
    93       explode(',', getAttribute($info_xml_element, 'metadata'))
    94       );
    95 
     91    $additional_metadata = getAttribute($info_xml_element, 'metadata');
     92
     93    if ($additional_metadata != '')
     94    {
     95      $this->metadata_attributes = array_merge(
     96        $this->metadata_attributes,
     97        explode(',', $additional_metadata)
     98        );
     99    }
     100   
    96101    $this->build_structure($xml_content, '', 0);
    97102
     
    180185
    181186// returns a hash of attributes (metadata+width,...) for file
    182 function get_element_metadata($file)
     187function get_element_metadata($file, $has_high = false)
    183188{
    184189  return $this->get_element_attributes(
  • trunk/admin/site_update.php

    r1458 r1883  
    776776  $datas = array();
    777777  $tags_of = array();
     778
     779  $has_high_images = array();
     780
     781  $image_ids = array();
     782  foreach ($files as $id => $file)
     783  {
     784    array_push($image_ids, $id);
     785  }
     786
     787  if (count($image_ids) > 0)
     788  {
     789    $query = '
     790SELECT id
     791  FROM '.IMAGES_TABLE.'
     792  WHERE has_high = \'true\'
     793    AND id IN (
     794'.wordwrap(implode(', ', $image_ids), 80, "\n").'
     795)
     796;';
     797
     798    $result = pwg_query($query);
     799    while ($row = mysql_fetch_array($result))
     800    {
     801      array_push($has_high_images, $row['id']);
     802    }
     803  }
     804 
    778805  foreach ( $files as $id=>$file )
    779806  {
    780     $data = $site_reader->get_element_metadata($file);
     807    $data = $site_reader->get_element_metadata(
     808      $file,
     809      in_array($id, $has_high_images)
     810      );
     811   
    781812    if ( is_array($data) )
    782813    {
     
    814845    if (count($datas) > 0)
    815846    {
     847      // echo '<pre>', print_r($datas); echo '</pre>';
     848     
    816849      mass_updates(
    817850        IMAGES_TABLE,
Note: See TracChangeset for help on using the changeset viewer.