Ignore:
Timestamp:
Feb 11, 2010, 12:29:29 AM (15 years ago)
Author:
plg
Message:

feature 1141 added: multiple select and progress bar with uploadify (jQuery
plugin).

Note: the HTML upload is disabled but I will provide a switch, either you use
Uploadify OR you use HTML multiple file boxes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/upload_form/upload.php

    r4829 r4875  
    7676if (isset($_POST['submit_upload']))
    7777{
     78//   echo '<pre>POST'."\n"; print_r($_POST); echo '</pre>';
     79//   echo '<pre>FILES'."\n"; print_r($_FILES); echo '</pre>';
     80//   echo '<pre>SESSION'."\n"; print_r($_SESSION); echo '</pre>';
     81//   exit();
     82 
    7883  $category_id = null;
    7984  if ('existing' == $_POST['category_type'])
     
    112117
    113118  $image_ids = array();
    114   $page['thumbnails'] = array();
    115      
    116   $starttime = get_moment();
    117  
     119       
     120  if (isset($_FILES) and !empty($_FILES['image_upload']))
     121  {
     122    $starttime = get_moment();
     123
    118124  foreach ($_FILES['image_upload']['error'] as $idx => $error)
    119125  {
     
    197203
    198204        // TODO: if $image_id is not an integer, something went wrong
    199 
    200         // we could return the list of properties from the add_uploaded_file
    201         // function, but I like the "double check". And it costs nothing
    202         // compared to the upload process.
    203         $thumbnail = array();
     205      }
     206    }
     207  }
     208 
     209  $endtime = get_moment();
     210  $elapsed = ($endtime - $starttime) * 1000;
     211  // printf('%.2f ms', $elapsed);
     212
     213  } // if (!empty($_FILES))
     214
     215  if (isset($_POST['upload_id']))
     216  {
     217    // we're on a multiple upload, with uploadify and so on
     218    $image_ids = $_SESSION['uploads'][ $_POST['upload_id'] ];
     219
     220    associate_images_to_categories(
     221      $image_ids,
     222      array($category_id)
     223      );
     224
     225    $query = '
     226UPDATE '.IMAGES_TABLE.'
     227  SET level = '.$_POST['level'].'
     228  WHERE id IN ('.implode(', ', $image_ids).')
     229;';
     230    pwg_query($query);
     231   
     232    invalidate_user_cache();
     233  }
     234 
     235  $page['thumbnails'] = array();
     236  foreach ($image_ids as $image_id)
     237  {
     238    // we could return the list of properties from the add_uploaded_file
     239    // function, but I like the "double check". And it costs nothing
     240    // compared to the upload process.
     241    $thumbnail = array();
    204242     
    205         $query = '
     243    $query = '
    206244SELECT
    207245    file,
     
    211249  WHERE id = '.$image_id.'
    212250;';
    213         $image_infos = mysql_fetch_assoc(pwg_query($query));
    214 
    215         $thumbnail['file'] = $image_infos['file'];
    216      
    217         $thumbnail['src'] = get_thumbnail_location(
    218           array(
    219             'path' => $image_infos['path'],
    220             'tn_ext' => $image_infos['tn_ext'],
    221             )
    222           );
    223 
    224         // TODO: when implementing this plugin in Piwigo core, we should have
    225         // a function get_image_name($name, $file) (if name is null, then
    226         // compute a temporary name from filename) that would be also used in
    227         // picture.php. UPDATE: in fact, "get_name_from_file($file)" already
    228         // exists and is used twice (element_set_unit + comments, but not in
    229         // picture.php I don't know why) with the same pattern if
    230         // (empty($name)) {$name = get_name_from_file($file)}, a clean
    231         // function get_image_name($name, $file) would be better
    232         $thumbnail['title'] = get_name_from_file($image_infos['file']);
    233 
    234         $thumbnail['link'] = PHPWG_ROOT_PATH.'admin.php?page=picture_modify'
    235           .'&amp;image_id='.$image_id
    236           .'&amp;cat_id='.$category_id
    237           ;
    238 
    239         array_push($page['thumbnails'], $thumbnail);
    240       }
    241     }
     251    $image_infos = mysql_fetch_assoc(pwg_query($query));
     252
     253    $thumbnail['file'] = $image_infos['file'];
     254   
     255    $thumbnail['src'] = get_thumbnail_location(
     256      array(
     257        'path' => $image_infos['path'],
     258        'tn_ext' => $image_infos['tn_ext'],
     259        )
     260      );
     261
     262    // TODO: when implementing this plugin in Piwigo core, we should have
     263    // a function get_image_name($name, $file) (if name is null, then
     264    // compute a temporary name from filename) that would be also used in
     265    // picture.php. UPDATE: in fact, "get_name_from_file($file)" already
     266    // exists and is used twice (element_set_unit + comments, but not in
     267    // picture.php I don't know why) with the same pattern if
     268    // (empty($name)) {$name = get_name_from_file($file)}, a clean
     269    // function get_image_name($name, $file) would be better
     270    $thumbnail['title'] = get_name_from_file($image_infos['file']);
     271
     272    $thumbnail['link'] = PHPWG_ROOT_PATH.'admin.php?page=picture_modify'
     273      .'&amp;image_id='.$image_id
     274      .'&amp;cat_id='.$category_id
     275      ;
     276
     277    array_push($page['thumbnails'], $thumbnail);
    242278  }
    243279 
    244   $endtime = get_moment();
    245   $elapsed = ($endtime - $starttime) * 1000;
    246   // printf('%.2f ms', $elapsed);
    247 
    248280  if (!empty($page['thumbnails']))
    249281  {
     
    312344  );
    313345
     346$template->assign(
     347    array(
     348      'upload_mode' => 'multiple',
     349      'upload_id' => md5(rand()),
     350      'session_id' => session_id(),
     351      'pwg_token' => get_pwg_token(),
     352    )
     353  );
     354
     355$template->append(
     356  'head_elements',
     357  '<link rel="stylesheet" type="text/css" href="'.UPLOAD_FORM_PATH.'uploadify/uploadify.css">'."\n"
     358  );
     359
    314360if (isset($page['thumbnails']))
    315361{
Note: See TracChangeset for help on using the changeset viewer.