Index: admin/media.php
===================================================================
--- admin/media.php	(revision 1145)
+++ admin/media.php	(revision 1159)
@@ -132,6 +132,6 @@
 
 # Adding a file
-if ($dir && !empty($_FILES['upfile']))
-{
+if ($dir && !empty($_FILES['upfile'])) {
+  // only one file per request : @see option singleFileUploads in admin/js/jsUpload/jquery.fileupload
   $upfile = array('name' => $_FILES['upfile']['name'][0],
                   'type' => $_FILES['upfile']['type'][0],
@@ -141,34 +141,36 @@
                   );
 
-	try {
-    files::uploadStatus($upfile);
-
-    $core->media->uploadFile($upfile['tmp_name'],$upfile['name']);
-
-    if (!empty($_SERVER['HTTP_X_REQUESTED_WITH'])) {
-      header('Content-type: application/json');
-      $message = array();
+  if (!empty($_SERVER['HTTP_X_REQUESTED_WITH'])) {
+    header('Content-type: application/json');
+    $message = array();
+
+    try {
+      files::uploadStatus($upfile);
+      $new_file_id = $core->media->uploadFile($upfile['tmp_name'], $upfile['name']);
+
       $message['files'][] = array('name' => $upfile['name'],
-                                  'size' => $upfile['size']
+                                  'size' => $upfile['size'],
+                                  'html' => mediaItemLine($core->media->getFile($new_file_id), count($dir['files']))
                                   );
-
-      echo json_encode($message);
-      exit();
-    } else {
-        http::redirect($page_url.'&d='.rawurlencode($d).'&upok=1');
-    }
-	} catch (Exception $e) {
-    if (!empty($_SERVER['HTTP_X_REQUESTED_WITH'])) {
-      header('Content-type: application/json');
-      $message = array();
+    } catch (Exception $e) {
       $message['files'][] = array('name' => $upfile['name'],
                                   'error' => $e->getMessage()
                                   );
-      echo json_encode($message);
-      exit();
-    } else {
+    }
+    echo json_encode($message);
+    exit();
+  } else {
+    try {
+      files::uploadStatus($upfile);
+
+      $f_title = (isset($_POST['upfiletitle']) ? $_POST['upfiletitle'] : '');
+      $f_private = (isset($_POST['upfilepriv']) ? $_POST['upfilepriv'] : false);
+
+      $core->media->uploadFile($upfile['tmp_name'], $upfile['name'], $f_title, $f_private);
+      http::redirect($page_url.'&d='.rawurlencode($d).'&upok=1');
+    } catch (Exception $e) {
       $core->error->add($e->getMessage());
     }
-	}
+  }
 }
 
@@ -319,20 +321,46 @@
 	echo '<div class="two-cols">';
 	
-	echo
-  '<div class="col">'.
+ 	if ($user_ui_enhanceduploader) {
+    echo
+      '<div class="col enhanced_uploader">';
+  } else {
+    echo
+      '<div class="col">';
+  }
+
+  echo
   '<fieldset id="add-file-f"><legend>'.__('Add files').'</legend>'.
   '<p>'.__('Please take care to publish media that you own and that are not protected by copyright.').'</p>'.
   ' <form id="fileupload" action="'.html::escapeURL($page_url).'" method="POST" enctype="multipart/form-data">'.
   '<div>'.form::hidden(array('MAX_FILE_SIZE'),DC_MAX_UPLOAD_SIZE).
-    $core->formNonce().'</div>'.
+  $core->formNonce().'</div>';
+
+  echo
   '<div class="fileupload-buttonbar">'.
   '<label class="button-add button" for="upfile">'.__('Add files').
-  '<input type="file" id="upfile" name="upfile[]" multiple="multiple" data-url="'.html::escapeURL($page_url).'" />'.
+  '<span class="one-file"> ('.sprintf(__('Maximum size %s'),files::size(DC_MAX_UPLOAD_SIZE)).')</span>'.
+    '<input type="file" id="upfile" name="upfile[]"'.($user_ui_enhanceduploader?' multiple="mutiple"':'').' data-url="'.html::escapeURL($page_url).'" />'.
   '</label>'.
-  '</span>'.
+  '</span>';
+
+  echo
+	'<p class="one-file"><label for="upfiletitle">'.__('Title:').form::field(array('upfiletitle','upfiletitle'),35,255).'</label></p>'.
+	'<p class="one-file"><label for="upfilepriv" class="classic">'.form::checkbox(array('upfilepriv','upfilepriv'),1).' '.
+  __('Private').'</label></p>';
+
+	if (!$user_ui_enhanceduploader) {
+		echo
+		'<p class="one-file form-help info">'.__('To send several files at the same time, you can activate the enhanced uploader in').
+		' <a href="preferences.php?tab=user-options">'.__('My preferences').'</a></p>';
+	}
+
+  echo
   '<input class="button start" type="submit" value="'.__('Send').'"/>'.
-  '</div>'.
-  '<table role="presentation" class="table table-striped"><tbody class="files" data-toggle="modal-gallery" data-target="#modal-gallery"></tbody></table>'.
-    form::hidden(array('d'),$d).'</p>'.
+  '</div>';
+
+
+  echo
+  '<table role="presentation" class="table-files table table-striped"><tbody class="files" data-toggle="modal-gallery" data-target="#modal-gallery"></tbody></table>'.
+  '<div>'.form::hidden(array('d'),$d).'</div>'.
   '</fieldset>'.
   '</form>'.
