Browse Source

Removed camel case

pull/46/head
Ben Woodhead 13 years ago
parent
commit
759c520449
  1. 38
      BatchIngest.inc

38
BatchIngest.inc

@ -65,22 +65,22 @@ function batch_creation_form(&$form_state, $collection_pid, $content_models) {
*/ */
function batch_creation_form_validate($form, &$form_state) { function batch_creation_form_validate($form, &$form_state) {
$fieldName = 'file-location'; $field_name = 'file-location';
if (isset($_FILES['files']) && is_uploaded_file($_FILES['files']['tmp_name'][$fieldName])) { if (isset($_FILES['files']) && is_uploaded_file($_FILES['files']['tmp_name'][$field_name])) {
$file = file_save_upload($fieldName); $file = file_save_upload($field_name);
if ($file->filemime != 'application/zip') { if ($file->filemime != 'application/zip') {
form_set_error($fieldName, 'Input file must be a .zip file'); form_set_error($field_name, 'Input file must be a .zip file');
return; return;
} }
if (!$file) { if (!$file) {
form_set_error($fieldName, 'Error uploading file.'); form_set_error($field_name, 'Error uploading file.');
return; return;
} }
$form_state['values']['file'] = $file; $form_state['values']['file'] = $file;
} }
else { else {
// set error // set error
form_set_error($fieldName, 'Error uploading file.'); form_set_error($field_name, 'Error uploading file.');
return; return;
} }
} }
@ -100,27 +100,27 @@ function batch_creation_form_submit($form, &$form_state) {
} }
$namespace = $namespace_mappings[$content_model]; $namespace = $namespace_mappings[$content_model];
$namespace = preg_replace('/:.*/', '', $namespace); $namespace = preg_replace('/:.*/', '', $namespace);
$dirName = "temp" . $user->uid; $dir_name = "temp" . $user->uid;
$tmpDir = file_directory_path() . '/' . $dirName . '/'; $tmp_dir = file_directory_path() . '/' . $dir_name . '/';
mkdir($tmpDir); mkdir($tmp_dir);
$file = $form_state['values']['file']; $file = $form_state['values']['file'];
$fileName = $file->filepath; $fileName = $file->filepath;
$file_list = array(); $file_list = array();
$cmdString = "unzip -q -o -d $tmpDir \"$fileName\""; $cmdString = "unzip -q -o -d $tmp_dir \"$fileName\"";
system($cmdString, $retVal); system($cmdString, $retVal);
$dirs = array(); $dirs = array();
$doNotAdd = array('.', '..', '__MACOSX'); $do_not_add = array('.', '..', '__MACOSX');
array_push($dirs, $tmpDir); array_push($dirs, $tmp_dir);
$files = scandir($tmpDir); $files = scandir($tmp_dir);
foreach ($files as $file) { foreach ($files as $file) {
if (is_dir("$tmpDir/$file") & !in_array($file, $doNotAdd)) { if (is_dir("$tmp_dir/$file") & !in_array($file, $do_not_add)) {
array_push($dirs, $tmpDir . $file); array_push($dirs, $tmp_dir . $file);
} }
} }
foreach ($dirs as $directory) { foreach ($dirs as $directory) {
if ($inputs = opendir($directory)) { if ($inputs = opendir($directory)) {
while (FALSE !== ($file_name = readdir($inputs))) { while (FALSE !== ($file_name = readdir($inputs))) {
if (!in_array($file_name, $doNotAdd) && is_dir($file_name) == FALSE) { if (!in_array($file_name, $do_not_add) && is_dir($file_name) == FALSE) {
$ext = strrchr($file_name, '.'); $ext = strrchr($file_name, '.');
$base = preg_replace("/$ext$/", '', $file_name); $base = preg_replace("/$ext$/", '', $file_name);
$ext = substr($ext, 1); $ext = substr($ext, 1);
@ -148,7 +148,7 @@ function batch_creation_form_submit($form, &$form_state) {
foreach ($file_list as $label => $object_files) { foreach ($file_list as $label => $object_files) {
$batch['operations'][] = array('create_batch_objects', array($label, $content_model, $object_files, $collection_pid, $namespace, $metadata)); $batch['operations'][] = array('create_batch_objects', array($label, $content_model, $object_files, $collection_pid, $namespace, $metadata));
} }
$batch['operations'][] = array('recursive_directory_delete', array($tmpDir)); $batch['operations'][] = array('recursive_directory_delete', array($tmp_dir));
batch_set($batch); batch_set($batch);
batch_process(); batch_process();
} }
@ -168,7 +168,7 @@ function create_batch_objects($label, $content_model, $object_files, $collection
module_load_include('inc', 'fedora_reppository', 'api/fedora_item'); module_load_include('inc', 'fedora_reppository', 'api/fedora_item');
$cm = ContentModel::loadFromModel($content_model, 'ISLANDORACM'); $cm = ContentModel::loadFromModel($content_model, 'ISLANDORACM');
$allowedMimeTypes = $cm->getMimetypes(); $allowed_mime_types = $cm->getMimetypes();
$mime_helper = new MimeClass(); $mime_helper = new MimeClass();
$pid = fedora_item::get_next_PID_in_namespace($namespace); $pid = fedora_item::get_next_PID_in_namespace($namespace);
@ -193,7 +193,7 @@ function create_batch_objects($label, $content_model, $object_files, $collection
$use_primary = TRUE; $use_primary = TRUE;
foreach ($object_files as $ext => $filename) { foreach ($object_files as $ext => $filename) {
$file_mimetype = $mime_helper->get_mimetype($filename); $file_mimetype = $mime_helper->get_mimetype($filename);
if (in_array($file_mimetype, $allowedMimeTypes)) { if (in_array($file_mimetype, $allowed_mime_types)) {
$added = $cm->execIngestRules($filename, $file_mimetype); $added = $cm->execIngestRules($filename, $file_mimetype);
} }
else { else {

Loading…
Cancel
Save