if (isset( $projects)) { /** * get results */ /** * display results */ if (sizeof($projects) == 0) { if($pageNo==1){ Utilities::print_warning_message('No results found. Please try again.'); }else{ Utilities::print_warning_message('No more results found.'); } } else { ?> <div class="table-responsive"> <table class="table"> <tr> <th>Name</th> <th>Creation Time</th> <th>Experiments</th> </tr>
/** * Create a select input and populate it with project options from the database */ public static function create_project_select($projectId = null, $editable = true) { $editable? $disabled = '' : $disabled = 'disabled'; $userProjects = Utilities::get_all_user_projects( Session::get("gateway_id"), Session::get('username') ); echo '<select class="form-control" name="project" id="project" required ' . $disabled . '>'; if (sizeof($userProjects) > 0) { foreach ($userProjects as $project) { if ($project->projectID == $projectId) { $selected = 'selected'; } else { $selected = ''; } echo '<option value="' . $project->projectID . '" ' . $selected . '>' . $project->name . '</option>'; } } echo '</select>'; if( sizeof($userProjects) == 0 ) { Utilities::print_warning_message('<p>You must create a project before you can create an experiment. Click <a href="' . URL::to('/') . '/project/create">here</a> to create a project.</p>'); } }
/** * @param $applicationInputs * @param $experimentInputs * @internal param $environmentPath * @return array */ public static function process_inputs($applicationInputs, $experimentInputs) { $utility = new Utilities(); $experimentAssemblySuccessful = true; $newExperimentInputs = array(); //var_dump($_FILES); if (sizeof($_FILES) > 0) { if (Utilities::file_upload_successful()) { // construct unique path do { Utilities::$experimentPath = base_path() . Constant::EXPERIMENT_DATA_ROOT . str_replace(' ', '', Session::get('username') ) . md5(rand() * time()) . '/'; } while (is_dir( Utilities::$experimentPath)); // if dir already exists, try again //var_dump( Utilities::$experimentPath ); exit; // create upload directory if (!mkdir( Utilities::$experimentPath)) { Utilities::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; } } //sending application inputs in the order defined by the admins. $order = array(); foreach ($applicationInputs as $index => $input) { $order[$index] = $input->inputOrder; } array_multisort($order, SORT_ASC, $applicationInputs); foreach ($applicationInputs as $applicationInput) { $experimentInput = new InputDataObjectType(); $experimentInput = $applicationInput; //$experimentInput->name = $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]; $experimentInput->type = $applicationInput->type; } else // use previous value { $index = -1; for ($i = 0; $i < sizeof($experimentInputs); $i++) { if ($experimentInputs[$i]->name == $applicationInput->name) { $index = $i; } } if ($index >= 0) { $experimentInput->value = $experimentInputs[$index]->value; $experimentInput->type = $applicationInput->type; } } } 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 = Utilities::$experimentPath . $file['name']; // check if file already exists if (is_file($filePath)) { unlink($filePath); Utilities::print_warning_message('Uploaded file already exists! Overwriting...'); } $moveFile = move_uploaded_file($file['tmp_name'], $filePath); if ($moveFile) { Utilities::print_success_message('Upload: ' . $file['name'] . '<br>' . 'Type: ' . $file['type'] . '<br>' . 'Size: ' . ($file['size']/1024) . ' kB');//<br>' . //'Stored in: ' . $experimentPath . $file['name']); } else { Utilities::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; } $experimentInput->value = str_replace(base_path() . Constant::EXPERIMENT_DATA_ROOT, Utilities::$pathConstant , $filePath); $experimentInput->type = $applicationInput->type; } else { $index = -1; for ($i = 0; $i < sizeof($experimentInputs); $i++) { if ($experimentInputs[$i]->name == $applicationInput->name) { $index = $i; } } if ($index >= 0) { $experimentInput->value = $experimentInputs[$index]->value; $experimentInput->type = $applicationInput->type; } } } else { Utilities::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; } }
</div> <input type="hidden" name="pageNo" value="<?php echo($pageNo) ?>"/> <div style="clear: both"></div> </form> <?php /** * get results */ /** * display results */ if (sizeof($projects) == 0) { Utilities::print_warning_message('No results found. Please try again.'); } else { ?> <div class="table-responsive"> <table class="table"> <tr> <th>Name</th> <th>Creation Time</th> <th>Experiments</th> </tr> <?php