diff --git a/include/rawpheno.function.measurements.inc b/include/rawpheno.function.measurements.inc index 82988ec..84b67ca 100644 --- a/include/rawpheno.function.measurements.inc +++ b/include/rawpheno.function.measurements.inc @@ -1176,6 +1176,51 @@ function rawpheno_function_plot_exists($plot, $project_id) { /** + * Function to get stock_id number of a stock name in chado.stock. + * NOTE: AGL applies only to when saving data. Validation (germplasm exists) + * is based on stock w/o this token. + * + * @param $stock_name + * A string, the name of the stock. + * @param $project_name + * A string, the name of the project. + * + * @return + * An integer, the stock id number. + */ +function rawpheno_function_getstockid($stock_name, $project_name) { + // Calling all modules implementing hook_rawpheno_AGILE_stock_name_alter(): + drupal_alter('rawpheno_AGILE_stock_name', $stock_name, $project_name); + + // Limit the search to project organism. + $result = chado_query( + "SELECT stock_id FROM {stock} WHERE name = :name LIMIT 1", + array(':name' => $stock_name) + ); + + return ($result) ? $result->fetchField() : 0; +} + + +/** + * Function: get project name. + * + * @param $project_id + * An integer value, the project id number. + * + * @return + * A string value, the name for the project from chado.project table. + */ +function rawpheno_function_getproject($project_id) { + $result = chado_query("SELECT name FROM {project} WHERE project_id = :project_id LIMIT 1", array( + ':project_id' => $project_id, + )); + + return ($result) ? $result->fetchField() : 0; +} + + +/** * Function to get environment data files. * * @param $project diff --git a/include/rawpheno.tripaldownload.inc b/include/rawpheno.tripaldownload.inc index 81d4335..2121e6c 100644 --- a/include/rawpheno.tripaldownload.inc +++ b/include/rawpheno.tripaldownload.inc @@ -380,7 +380,7 @@ function rawpheno_trpdownload_generate_file($variables, $job_id = NULL) { foreach ($rows as $row) { // To file... to screen... - $percent = round(($cur_line / $total_lines) * 100); + $percent = (($cur_line / $total_lines) * 100); if ($percent % 10 == 0 && $past_percent != $percent) { drush_print($percent . '% complete...'); } diff --git a/include/rawpheno.upload.excel.inc b/include/rawpheno.upload.excel.inc index 8cb9acf..b6fc647 100755 --- a/include/rawpheno.upload.excel.inc +++ b/include/rawpheno.upload.excel.inc @@ -25,6 +25,9 @@ function rawpheno_load_spreadsheet($project_id, $arr_newheaders, $fid, $plantpro $plantprop_headers = unserialize($plantprop_headers); $arr_newheaders = unserialize($arr_newheaders); + // Project name. + $project_name = rawpheno_function_getproject($project_id); + // First we load the file. $file = file_load($fid); @@ -85,6 +88,13 @@ function rawpheno_load_spreadsheet($project_id, $arr_newheaders, $fid, $plantpro // print "\nNow parsing each row and saving it to the database...\nNumber of rows saved: \n"; $i = 0; + // Skip columns. + $skip = array(); + // Project name. + $project_name = rawpheno_function_getproject($project_id); + // Calling all modules implementing hook_rawpheno_ignorecols_valsave_alter(): + drupal_alter('rawpheno_ignorecols_valsave', $skip, $project_name); + // Each row in the spreadsheet. foreach ($xls_obj as $row) { // Create progress update by computing the number of rows saved in percent. @@ -134,9 +144,9 @@ function rawpheno_load_spreadsheet($project_id, $arr_newheaders, $fid, $plantpro // Process the name column first since we need a plant_id before we can insert any more data. // Name column header goes into pheno_plant. // Check if stock name exists. - $stock_id = NULL; - $r = chado_query('SELECT stock_id FROM {stock} WHERE name=:name', array(':name' => trim($row[$name_index]))); - if ($r) $stock_id = $r->fetchField(); + unset($stock_id); + $stock_id = rawpheno_function_getstockid(trim($row[$name_index]), $project_name); + // print $stock_id . ' -- ' . $row[$name_index] . "\n"; // Determine if name has a stock id number. if (isset($stock_id) && $stock_id > 0) { @@ -226,6 +236,14 @@ function rawpheno_load_spreadsheet($project_id, $arr_newheaders, $fid, $plantpro // Read each row and each cell. // Each row will be an array where name is always the first element. foreach($row as $cell_index => $cell_entry) { + // Skip this cell when col from durpal_alter hook matches the col. + $h = rawpheno_function_delformat($header[$cell_index]); + + if (count($skip) > 0 && in_array($h, $skip)) { + // print 'skipping value : ' . $h . '=' . $cell_entry . "\n"; + continue; + } + // For consistency, convert all variations of not applicable to NA. if (is_string($cell_entry) && in_array(strtolower($cell_entry), $not_applicable)) { $cell_entry = 'NA'; @@ -312,6 +330,11 @@ function rawpheno_load_spreadsheet($project_id, $arr_newheaders, $fid, $plantpro // THE REST OF THE COLUMN HEADERS // Everything else into pheno_measurements. elseif (!empty($cell_colheader) && $cell_entry != 'NA') { + if (in_array($cell_colheader, $skip)) { + // print 'skipping header : ' . $cell_colheader . "\n"; + continue; + } + // Get the cvterm_id for the trait measurement. $type_id = rawpheno_get_trait_id($cell_colheader); @@ -535,6 +558,13 @@ function rawpheno_validate_excel_file($file, $project_id, $source) { // Variations of Not Applicable. $not_applicable = array('na', 'n/a', 'n.a.'); + // Skip columns. + $skip = array(); + // Project name. + $project_name = rawpheno_function_getproject($project_id); + // Calling all modules implementing hook_rawpheno_ignorecols_valsave_alter(): + drupal_alter('rawpheno_ignorecols_valsave', $skip, $project_name); + // Iterate though each row. $num_errored_rows = 0; $storage = array(); @@ -557,12 +587,18 @@ function rawpheno_validate_excel_file($file, $project_id, $source) { $o = 0; foreach ($row as $r) { $without_format = rawpheno_function_delformat($r); + + // To maintain index of both cells and header, tag either to skip or process + // based on headers in drupal_alter hook. + $s = (in_array($without_format, $skip)) ? 1 : 0; + $no_units = rawpheno_get_trait_name($r); $header[] = array( 'no format' => $without_format, 'original' => $r, 'units' => rawpheno_function_unit($without_format), 'no units' => $no_units, + 'skip' => $s, ); // Store index number of Plot trait requirements. @@ -596,6 +632,7 @@ function rawpheno_validate_excel_file($file, $project_id, $source) { $row_has_error = FALSE; foreach ($row as $column_index => $cell) { + if ($header[$column_index]['skip'] == 1) continue; $column_name = $header[$column_index]['no units']; if (empty($column_name)) continue; diff --git a/include/rawpheno.upload.form.inc b/include/rawpheno.upload.form.inc index 687b28c..7ace69f 100755 --- a/include/rawpheno.upload.form.inc +++ b/include/rawpheno.upload.form.inc @@ -218,6 +218,7 @@ function rawpheno_upload_form_stage_review(&$form, &$form_state) { // The project id number the spreadsheet and column headers are specific to. $project_id = $form_state['values']['sel_project']; + $project_name = rawpheno_function_getproject($project_id); // FIND NEW HEADERS. // First step, determine which headers/traits need to be described. @@ -230,6 +231,10 @@ function rawpheno_upload_form_stage_review(&$form, &$form_state) { // when no project id is selected, user will be stopped and is requested to retry the process. if ($file AND !empty($project_id)) { $new_header = rawpheno_indicate_new_headers($file, $project_id); + + // Calling all modules implementing hook_rawpheno_AGILE_stock_name_alter(): + drupal_alter('rawpheno_ignorecols_newcolumn', $new_header, $project_name); + $form_state['multistep_values']['new_headers'] = $new_header; } else { diff --git a/include/rawpheno.validation.inc b/include/rawpheno.validation.inc index dc6e64e..4fc2b12 100644 --- a/include/rawpheno.validation.inc +++ b/include/rawpheno.validation.inc @@ -232,6 +232,8 @@ function validator_column_exists_validate_header($header, $project_id) { $nospace_header = array(); foreach ($header as $h) { + if ($h['skip'] == 1) continue; + $delformat_header[] = $h['no units']; $nospace_header[] = str_replace(' ','', $h['no format']); } @@ -265,6 +267,8 @@ function validator_column_exists_validate_header($header, $project_id) { // or closing paren. $invalid_format = array(); foreach($header as $f) { + if ($f['skip'] == 1) continue; + $h = trim(str_replace(array("\n", "\r", " "), ' ', $f['original'])); $is_valid = rawpheno_valid_trait_format($h); diff --git a/rawpheno.module b/rawpheno.module index 58dd8ef..0899d99 100755 --- a/rawpheno.module +++ b/rawpheno.module @@ -326,6 +326,10 @@ function rawpheno_preprocess_rawpheno_upload_form_master(&$variables, $hook) { $variables['rel_url'] = url('phenotypes/raw/instructions'); // Page Title $variables['page_title'] = variable_get('rawpheno_upload_title'); + // Support Email. + $support_email = ''; + drupal_alter('rawpheno_support_email', $support_email); + $variables['support_email'] = $support_email; // Needs url in help window and links in stage 3. $variables['page_url'] = @@ -334,7 +338,8 @@ function rawpheno_preprocess_rawpheno_upload_form_master(&$variables, $hook) { 'rawpheno_download' => url('phenotypes/raw/download'), 'rawpheno_instructions' => url('phenotypes/raw/instructions'), 'rawpheno_upload' => url('phenotypes/raw/upload'), - 'rawpheno_backup' => url('phenotypes/raw/backup') + 'rawpheno_backup' => url('phenotypes/raw/backup'), + 'rawpheno_demo' => url('phenotypes/raw/videos'), ); // Stages in upload page. @@ -1106,11 +1111,15 @@ function rawpheno_block_view($delta = '') { $u = explode('.', $url); $hostname = (empty($u[0])) ? $url : ucfirst($u[0]); + $support_email = ''; + drupal_alter('rawpheno_support_email', $support_email); + $content = theme('rawpheno_notification_block', array( 'alert' => $alert, 'username' => $user, 'hostname' => $hostname, 'file_count' => $file_count, + 'support_email' => $support_email, 'path_module' => base_path() . $path . '/', 'path_phenotypes_raw' => $GLOBALS['base_url'] . '/phenotypes/raw/', 'path_phenotypes_video' => file_create_url('public://') . 'tutorial_files/rawpheno_videos/', diff --git a/theme/css/rawpheno.notification.block.style.css b/theme/css/rawpheno.notification.block.style.css index 8754e74..e06f7b9 100755 --- a/theme/css/rawpheno.notification.block.style.css +++ b/theme/css/rawpheno.notification.block.style.css @@ -196,6 +196,13 @@ font-size: 1em; } +#rawpheno-notification-helptopic-select { + font-size: 1em; + margin: 2px 0 10px 0; + padding: 5px; + width: 90%; +} + /* Media query - apply stype when viewport is 1500px */ @media(max-width: 1500px) { #rawpheno-notification-block-wrapper { diff --git a/theme/js/rawpheno.notification.block.script.js b/theme/js/rawpheno.notification.block.script.js index 4398dd6..c46a89b 100755 --- a/theme/js/rawpheno.notification.block.script.js +++ b/theme/js/rawpheno.notification.block.script.js @@ -45,6 +45,18 @@ whyBackupInfo.slideUp().hide(); }); + + // Convert help topic select box to a jump menu. + if ($('#rawpheno-notification-helptopic-select').length) { + $('#rawpheno-notification-helptopic-select').change(function() { + var url = $(this).attr('value'); + + if (url) { + window.open(url, '_blank'); + } + }); + } + } }; }(jQuery)); diff --git a/theme/js/rawpheno.upload.script.js b/theme/js/rawpheno.upload.script.js index 79342f0..c2dd59e 100755 --- a/theme/js/rawpheno.upload.script.js +++ b/theme/js/rawpheno.upload.script.js @@ -26,6 +26,12 @@ collapseLink.once(function() { $(this).click(function(event) { event.preventDefault(); + + // Check if select project message is on. + if (!$('#float-text').is(':hidden')) { + $('#float-text').hide(); + } + if (helpWindow.is(':hidden')) { helpWindow.slideDown(speed, function() { collapseLink.text('Close window'); diff --git a/theme/rawpheno_notification_block.tpl.php b/theme/rawpheno_notification_block.tpl.php index f980878..264234b 100755 --- a/theme/rawpheno_notification_block.tpl.php +++ b/theme/rawpheno_notification_block.tpl.php @@ -68,12 +68,19 @@