<button name="search" type="submit" class="btn btn-primary" value="Search"><span class="glyphicon glyphicon-search"></span> Search</button> <p class="help-block">You can use * as a wildcard character. Tip: search for * alone to retrieve all of your experiments.</p> </form> <?php if (isset($_POST['search'])) { /** * get results */ $experiments = get_search_results(); //var_dump($experiments[0]); if (sizeof($experiments) == 0) { print_warning_message('No results found. Please try again.'); } else { echo ' <div class="table-responsive"> <table class="table"> <tr> <th>Name</th> <th>Application</th> <th>Description</th> <!--<th>Resource</th>--> <th>Creation Time</th> <th>Status</th> </tr> '; foreach ($experiments as $experiment) { $applicationInterface = get_application_interface($experiment->applicationId);
/** * @param $applicationInputs * @param $experimentInputs * @internal param $environmentPath * @return array */ function process_inputs($applicationInputs, $experimentInputs) { global $experimentPath; $experimentAssemblySuccessful = true; $newExperimentInputs = array(); //var_dump($_FILES); if (sizeof($_FILES) > 0) { if (file_upload_successful()) { // construct unique path do { $experimentPath = EXPERIMENT_DATA_ROOT . str_replace(' ', '', $_SESSION['username']) . md5(rand() * time()) . '/'; } while (is_dir($experimentPath)); // if dir already exists, try again // create upload directory if (!mkdir($experimentPath)) { print_error_message('<p>Error creating upload directory! Please try again later or report a bug using the link in the Help menu.</p>'); $experimentAssemblySuccessful = false; } } else { $experimentAssemblySuccessful = false; } } foreach ($applicationInputs as $applicationInput) { $experimentInput = new DataObjectType(); $experimentInput->key = $applicationInput->name; $experimentInput->metaData = $applicationInput->metaData; //$experimentInput->type = $applicationInput->type; //$experimentInput->type = DataType::STRING; if ($applicationInput->type == DataType::STRING || $applicationInput->type == DataType::INTEGER || $applicationInput->type == DataType::FLOAT) { if (isset($_POST[$applicationInput->name]) && trim($_POST[$applicationInput->name]) != '') { $experimentInput->value = $_POST[$applicationInput->name]; } else { $index = -1; for ($i = 0; $i < sizeof($experimentInputs); $i++) { if ($experimentInputs[$i]->key == $applicationInput->name) { $index = $i; } } if ($index >= 0) { $experimentInput->value = $experimentInputs[$index]->value; } } } elseif ($applicationInput->type == DataType::URI) { //var_dump($_FILES[$applicationInput->name]->name); if ($_FILES[$applicationInput->name]['name']) { $file = $_FILES[$applicationInput->name]; // // move file to experiment data directory // $filePath = $experimentPath . $file['name']; // check if file already exists if (is_file($filePath)) { unlink($filePath); print_warning_message('Uploaded file already exists! Overwriting...'); } $moveFile = move_uploaded_file($file['tmp_name'], $filePath); if ($moveFile) { print_success_message('Upload: ' . $file['name'] . '<br>' . 'Type: ' . $file['type'] . '<br>' . 'Size: ' . $file['size'] / 1024 . ' kB'); //<br>' . //'Stored in: ' . $experimentPath . $file['name']); } else { print_error_message('<p>Error moving uploaded file ' . $file['name'] . '! Please try again later or report a bug using the link in the Help menu.</p>'); $experimentAssemblySuccessful = false; } global $pathConstant; $experimentInput->value = str_replace(EXPERIMENT_DATA_ROOT, $pathConstant, $filePath); } else { $index = -1; for ($i = 0; $i < sizeof($experimentInputs); $i++) { if ($experimentInputs[$i]->key == $applicationInput->name) { $index = $i; } } if ($index >= 0) { $experimentInput->value = $experimentInputs[$index]->value; } } } else { print_error_message('I cannot accept this input type yet!'); } //$experimentInputs[] = $experimentInput; /* $index = -1; for ($i = 0; $i < sizeof($experimentInputs); $i++) { if ($experimentInputs[$i]->key == $experimentInput->key) { $index = $i; } } if ($index >= 0) { unset($experimentInputs[$index]); } */ //$experimentInputs[] = $experimentInput; $newExperimentInputs[] = $experimentInput; } if ($experimentAssemblySuccessful) { return $newExperimentInputs; } else { return false; } }