|
@@ -1629,6 +1629,9 @@ function tripal_bulk_loader_template_field_form_default_values($mode, &$form_sta
|
|
if (!isset($table)) {
|
|
if (!isset($table)) {
|
|
$table = reset($tables);
|
|
$table = reset($tables);
|
|
}
|
|
}
|
|
|
|
+ if (!isset($record_name) and isset($form_state['storage']['template_array'][$record_id])) {
|
|
|
|
+ $record_name = $form_state['storage']['template_array'][$record_id]['record_id'];
|
|
|
|
+ }
|
|
|
|
|
|
// Chado fields
|
|
// Chado fields
|
|
$chado_fields = array();
|
|
$chado_fields = array();
|
|
@@ -1688,7 +1691,7 @@ function tripal_bulk_loader_template_field_form_default_values($mode, &$form_sta
|
|
$v['chado_field'] = $field;
|
|
$v['chado_field'] = $field;
|
|
$v['chado_field_options'] = $chado_fields;
|
|
$v['chado_field_options'] = $chado_fields;
|
|
|
|
|
|
- $v['record_name'] = (isset($form_state['values']['record_name'])) ? $form_state['values']['record_name'] : '';
|
|
|
|
|
|
+ $v['record_name'] = (isset($record_name)) ? $record_name : '';
|
|
if (isset($form_state['values']['field_title'])) {
|
|
if (isset($form_state['values']['field_title'])) {
|
|
$v['field_title'] = $form_state['values']['field_title'];
|
|
$v['field_title'] = $form_state['values']['field_title'];
|
|
}
|
|
}
|
|
@@ -1860,30 +1863,17 @@ function tripal_bulk_loader_template_field_form($form, &$form_state = NULL) {
|
|
'#suffix' => '</div>',
|
|
'#suffix' => '</div>',
|
|
);
|
|
);
|
|
|
|
|
|
- $form['fields']['basic'] = array(
|
|
|
|
- '#type' => 'markup',
|
|
|
|
- '#prefix' => '<div class="basic">',
|
|
|
|
- '#suffix' => '</div>'
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
- $form['fields']['basic']['field_type'] = array(
|
|
|
|
- '#type' => 'radios',
|
|
|
|
- '#title' => t('Type of Field'),
|
|
|
|
- '#options' => array(
|
|
|
|
- 'table field' => t('Data: A Field which maps to a column in the supplied file.'),
|
|
|
|
- 'constant' => t('Constant: Field which remains Constant throughout the file'),
|
|
|
|
- 'foreign key' => t('Record Referral: Fields which map to a record in another table'),
|
|
|
|
- ),
|
|
|
|
- '#required' => TRUE,
|
|
|
|
- '#default_value' => $values['field_type'],
|
|
|
|
- '#ajax' => array(
|
|
|
|
- 'callback' => 'tripal_bulk_loader_template_fields_ahah',
|
|
|
|
- 'wrapper' => 'tripal_bulk_loader_template-template_fields',
|
|
|
|
- 'effect' => 'fade'
|
|
|
|
- ),
|
|
|
|
|
|
+ $form['fields']['record'] = array(
|
|
|
|
+ '#type' => 'fieldset',
|
|
|
|
+ '#title' => 'Record'
|
|
);
|
|
);
|
|
-
|
|
|
|
- $form['fields']['basic']['field_group'] = array(
|
|
|
|
|
|
+ if (!empty($values['record_name'])) {
|
|
|
|
+ $form['fields']['record']['#title'] = 'Record: ' . $values['record_name'];
|
|
|
|
+ $form['fields']['record']['#collapsible'] = TRUE;
|
|
|
|
+ $form['fields']['record']['#collapsed'] = TRUE;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $form['fields']['record']['field_group'] = array(
|
|
'#type' => 'select',
|
|
'#type' => 'select',
|
|
'#title' => 'Record',
|
|
'#title' => 'Record',
|
|
'#description' => t(
|
|
'#description' => t(
|
|
@@ -1899,16 +1889,39 @@ function tripal_bulk_loader_template_field_form($form, &$form_state = NULL) {
|
|
'#required' => TRUE,
|
|
'#required' => TRUE,
|
|
);
|
|
);
|
|
|
|
|
|
- $form['fields']['basic']['record_name'] = array(
|
|
|
|
- '#type' => ($values['no_record_id']) ? 'textfield' : 'hidden',
|
|
|
|
|
|
+ $form['fields']['record']['record_name'] = array(
|
|
|
|
+ '#type' => 'textfield',
|
|
'#title' => 'Unique Record Name',
|
|
'#title' => 'Unique Record Name',
|
|
'#prefix' => '<div id="tripal_bulk_loader_template-add_record">',
|
|
'#prefix' => '<div id="tripal_bulk_loader_template-add_record">',
|
|
'#suffix' => '</div>',
|
|
'#suffix' => '</div>',
|
|
'#description' => 'A human-readable name for the record; it should be unique.',
|
|
'#description' => 'A human-readable name for the record; it should be unique.',
|
|
|
|
+ '#disabled' => ($values['no_record_id']) ? FALSE : TRUE,
|
|
'#default_value' => $values['record_name'],
|
|
'#default_value' => $values['record_name'],
|
|
);
|
|
);
|
|
|
|
+
|
|
|
|
+ $form['fields']['field'] = array(
|
|
|
|
+ '#type' => 'fieldset',
|
|
|
|
+ '#title' => 'Field',
|
|
|
|
+ );
|
|
|
|
|
|
- $form['fields']['basic']['field_title'] = array(
|
|
|
|
|
|
+ $form['fields']['field']['field_type'] = array(
|
|
|
|
+ '#type' => 'radios',
|
|
|
|
+ '#title' => t('Type of Field'),
|
|
|
|
+ '#options' => array(
|
|
|
|
+ 'table field' => t('Data: A Field which maps to a column in the supplied file.'),
|
|
|
|
+ 'constant' => t('Constant: Field which remains Constant throughout the file'),
|
|
|
|
+ 'foreign key' => t('Record Referral: Fields which map to a record in another table'),
|
|
|
|
+ ),
|
|
|
|
+ '#required' => TRUE,
|
|
|
|
+ '#default_value' => $values['field_type'],
|
|
|
|
+ '#ajax' => array(
|
|
|
|
+ 'callback' => 'tripal_bulk_loader_template_fields_ahah',
|
|
|
|
+ 'wrapper' => 'tripal_bulk_loader_template-template_fields',
|
|
|
|
+ 'effect' => 'fade'
|
|
|
|
+ ),
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ $form['fields']['field']['field_title'] = array(
|
|
'#type' => 'textfield',
|
|
'#type' => 'textfield',
|
|
'#title' => t('Human-readable Title for Field'),
|
|
'#title' => t('Human-readable Title for Field'),
|
|
'#default_value' => $values['field_title'],
|
|
'#default_value' => $values['field_title'],
|
|
@@ -1916,13 +1929,13 @@ function tripal_bulk_loader_template_field_form($form, &$form_state = NULL) {
|
|
|
|
|
|
|
|
|
|
// Chado Field
|
|
// Chado Field
|
|
- $form['fields']['chado'] = array(
|
|
|
|
|
|
+ $form['fields']['field']['chado'] = array(
|
|
'#type' => 'fieldset',
|
|
'#type' => 'fieldset',
|
|
'#title' => t('Chado Field/Column Details'),
|
|
'#title' => t('Chado Field/Column Details'),
|
|
'#description' => t('Specify the Table/Field in chado that this field maps to.'),
|
|
'#description' => t('Specify the Table/Field in chado that this field maps to.'),
|
|
);
|
|
);
|
|
|
|
|
|
- $form['fields']['chado']['chado_table'] = array(
|
|
|
|
|
|
+ $form['fields']['field']['chado']['chado_table'] = array(
|
|
'#type' => 'select',
|
|
'#type' => 'select',
|
|
'#title' => t('Chado Table'),
|
|
'#title' => t('Chado Table'),
|
|
'#options' => $values['chado_table_options'],
|
|
'#options' => $values['chado_table_options'],
|
|
@@ -1934,7 +1947,7 @@ function tripal_bulk_loader_template_field_form($form, &$form_state = NULL) {
|
|
),
|
|
),
|
|
);
|
|
);
|
|
|
|
|
|
- $form['fields']['chado']['chado_field'] = array(
|
|
|
|
|
|
+ $form['fields']['field']['chado']['chado_field'] = array(
|
|
'#type' => 'select',
|
|
'#type' => 'select',
|
|
'#title' => t('Chado Field/Column'),
|
|
'#title' => t('Chado Field/Column'),
|
|
'#options' => $values['chado_field_options'],
|
|
'#options' => $values['chado_field_options'],
|
|
@@ -1947,14 +1960,14 @@ function tripal_bulk_loader_template_field_form($form, &$form_state = NULL) {
|
|
);
|
|
);
|
|
|
|
|
|
// loading file data column
|
|
// loading file data column
|
|
- $form['fields']['columns'] = array(
|
|
|
|
|
|
+ $form['fields']['field']['columns'] = array(
|
|
'#type' => 'fieldset',
|
|
'#type' => 'fieldset',
|
|
'#title' => t('Data File Column'),
|
|
'#title' => t('Data File Column'),
|
|
'#collapsible' => TRUE,
|
|
'#collapsible' => TRUE,
|
|
'#collapsed' => ($values['field_type'] == 'table field')? FALSE : TRUE,
|
|
'#collapsed' => ($values['field_type'] == 'table field')? FALSE : TRUE,
|
|
);
|
|
);
|
|
|
|
|
|
- $form['fields']['columns']['column_number'] = array(
|
|
|
|
|
|
+ $form['fields']['field']['columns']['column_number'] = array(
|
|
'#type' => 'textfield',
|
|
'#type' => 'textfield',
|
|
'#title' => t('Column'),
|
|
'#title' => t('Column'),
|
|
'#description' => t('Specify the column in the data that this field maps to where the first column is 1.'),
|
|
'#description' => t('Specify the column in the data that this field maps to where the first column is 1.'),
|
|
@@ -1962,14 +1975,14 @@ function tripal_bulk_loader_template_field_form($form, &$form_state = NULL) {
|
|
'#default_value' => $values['column_number'],
|
|
'#default_value' => $values['column_number'],
|
|
);
|
|
);
|
|
|
|
|
|
- $form['fields']['columns']['column_exposed'] = array(
|
|
|
|
|
|
+ $form['fields']['field']['columns']['column_exposed'] = array(
|
|
'#type' => 'checkbox',
|
|
'#type' => 'checkbox',
|
|
'#title' => t('Allow Column to be set for each Bulk Loading Job'),
|
|
'#title' => t('Allow Column to be set for each Bulk Loading Job'),
|
|
'#description' => t('Adds a textbox field to the Bulk Loader Page to allow users to set this value.'),
|
|
'#description' => t('Adds a textbox field to the Bulk Loader Page to allow users to set this value.'),
|
|
'#default_value' => $values['column_exposed'],
|
|
'#default_value' => $values['column_exposed'],
|
|
);
|
|
);
|
|
|
|
|
|
- $form['fields']['columns']['column_exposed_desc'] = array(
|
|
|
|
|
|
+ $form['fields']['field']['columns']['column_exposed_desc'] = array(
|
|
'#type' => 'textfield',
|
|
'#type' => 'textfield',
|
|
'#title' => t('Description for exposed field on bulk loading job'),
|
|
'#title' => t('Description for exposed field on bulk loading job'),
|
|
'#description' => t('This description should tell the user what column should be entered here.'),
|
|
'#description' => t('This description should tell the user what column should be entered here.'),
|
|
@@ -1977,28 +1990,28 @@ function tripal_bulk_loader_template_field_form($form, &$form_state = NULL) {
|
|
);
|
|
);
|
|
|
|
|
|
// Global Value
|
|
// Global Value
|
|
- $form['fields']['constant'] = array(
|
|
|
|
|
|
+ $form['fields']['field']['constant'] = array(
|
|
'#type' => 'fieldset',
|
|
'#type' => 'fieldset',
|
|
'#title' => t('Constant'),
|
|
'#title' => t('Constant'),
|
|
'#collapsible' => TRUE,
|
|
'#collapsible' => TRUE,
|
|
'#collapsed' => ($values['field_type'] == 'constant')? FALSE : TRUE,
|
|
'#collapsed' => ($values['field_type'] == 'constant')? FALSE : TRUE,
|
|
);
|
|
);
|
|
|
|
|
|
- $form['fields']['constant']['constant_value'] = array(
|
|
|
|
|
|
+ $form['fields']['field']['constant']['constant_value'] = array(
|
|
'#type' => 'textfield',
|
|
'#type' => 'textfield',
|
|
'#title' => t('Constant Value'),
|
|
'#title' => t('Constant Value'),
|
|
'#description' => t('Specify the value you wish this field to have regardless of data file value.'),
|
|
'#description' => t('Specify the value you wish this field to have regardless of data file value.'),
|
|
'#default_value' => $values['constant_value']
|
|
'#default_value' => $values['constant_value']
|
|
);
|
|
);
|
|
|
|
|
|
- $form['fields']['constant']['constant_exposed'] = array(
|
|
|
|
|
|
+ $form['fields']['field']['constant']['constant_exposed'] = array(
|
|
'#type' => 'checkbox',
|
|
'#type' => 'checkbox',
|
|
'#title' => t('Allow Constant to be set for each Bulk Loading Job'),
|
|
'#title' => t('Allow Constant to be set for each Bulk Loading Job'),
|
|
'#description' => t('Adds a textbox field to the Create Bulk Loader Form to allow users to set this value.'),
|
|
'#description' => t('Adds a textbox field to the Create Bulk Loader Form to allow users to set this value.'),
|
|
'#default_value' => $values['constant_exposed'],
|
|
'#default_value' => $values['constant_exposed'],
|
|
);
|
|
);
|
|
|
|
|
|
- $form['fields']['constant']['constant_validate'] = array(
|
|
|
|
|
|
+ $form['fields']['field']['constant']['constant_validate'] = array(
|
|
'#type' => 'checkbox',
|
|
'#type' => 'checkbox',
|
|
'#title' => t('Ensure value is in table'),
|
|
'#title' => t('Ensure value is in table'),
|
|
'#description' => t('Checks the database when a bulk loading job is created to ensure the value entered already exists in the database.'),
|
|
'#description' => t('Checks the database when a bulk loading job is created to ensure the value entered already exists in the database.'),
|
|
@@ -2006,14 +2019,14 @@ function tripal_bulk_loader_template_field_form($form, &$form_state = NULL) {
|
|
);
|
|
);
|
|
|
|
|
|
// Foreign Key / Referrer
|
|
// Foreign Key / Referrer
|
|
- $form['fields']['foreign_key'] = array(
|
|
|
|
|
|
+ $form['fields']['field']['foreign_key'] = array(
|
|
'#type' => 'fieldset',
|
|
'#type' => 'fieldset',
|
|
'#title' => 'Record Referral',
|
|
'#title' => 'Record Referral',
|
|
'#collapsible' => TRUE,
|
|
'#collapsible' => TRUE,
|
|
'#collapsed' => ($values['field_type'] == 'foreign key')? FALSE : TRUE,
|
|
'#collapsed' => ($values['field_type'] == 'foreign key')? FALSE : TRUE,
|
|
);
|
|
);
|
|
|
|
|
|
- $form['fields']['foreign_key']['show_all_records'] = array(
|
|
|
|
|
|
+ $form['fields']['field']['foreign_key']['show_all_records'] = array(
|
|
'#type' => 'checkbox',
|
|
'#type' => 'checkbox',
|
|
'#title' => 'Refer to any record',
|
|
'#title' => 'Refer to any record',
|
|
'#description' => t('By default, the bulk loader will only allow referral to records in a foreign key relationship. To allow referral to any previous record, check this box'),
|
|
'#description' => t('By default, the bulk loader will only allow referral to records in a foreign key relationship. To allow referral to any previous record, check this box'),
|
|
@@ -2025,7 +2038,7 @@ function tripal_bulk_loader_template_field_form($form, &$form_state = NULL) {
|
|
),
|
|
),
|
|
);
|
|
);
|
|
|
|
|
|
- $form['fields']['foreign_key']['foreign_record'] = array(
|
|
|
|
|
|
+ $form['fields']['field']['foreign_key']['foreign_record'] = array(
|
|
'#type' => 'select',
|
|
'#type' => 'select',
|
|
'#title' => 'Record to refer to',
|
|
'#title' => 'Record to refer to',
|
|
'#descripion' => 'Select the record that this value should refer to. The record needs to already exist.',
|
|
'#descripion' => 'Select the record that this value should refer to. The record needs to already exist.',
|
|
@@ -2038,7 +2051,7 @@ function tripal_bulk_loader_template_field_form($form, &$form_state = NULL) {
|
|
'#default_value' => $values['foreign_record'],
|
|
'#default_value' => $values['foreign_record'],
|
|
);
|
|
);
|
|
|
|
|
|
- $form['fields']['foreign_key']['foreign_field'] = array(
|
|
|
|
|
|
+ $form['fields']['field']['foreign_key']['foreign_field'] = array(
|
|
'#type' => 'select',
|
|
'#type' => 'select',
|
|
'#title' => 'Field to refer to',
|
|
'#title' => 'Field to refer to',
|
|
'#descripion' => 'Select the record that this value should refer to. The record needs to already exist.',
|
|
'#descripion' => 'Select the record that this value should refer to. The record needs to already exist.',
|
|
@@ -2051,27 +2064,27 @@ function tripal_bulk_loader_template_field_form($form, &$form_state = NULL) {
|
|
if ($values['required'] OR !empty($values['regex-pattern'])) {
|
|
if ($values['required'] OR !empty($values['regex-pattern'])) {
|
|
$collapsed = FALSE;
|
|
$collapsed = FALSE;
|
|
}
|
|
}
|
|
- $form['fields']['additional'] = array(
|
|
|
|
|
|
+ $form['fields']['field']['additional'] = array(
|
|
'#type' => 'fieldset',
|
|
'#type' => 'fieldset',
|
|
'#title' => 'Additional Options',
|
|
'#title' => 'Additional Options',
|
|
'#collapsible' => TRUE,
|
|
'#collapsible' => TRUE,
|
|
'#collapsed' => $collapsed
|
|
'#collapsed' => $collapsed
|
|
);
|
|
);
|
|
|
|
|
|
- $form['fields']['additional']['required'] = array(
|
|
|
|
|
|
+ $form['fields']['field']['additional']['required'] = array(
|
|
'#type' => 'checkbox',
|
|
'#type' => 'checkbox',
|
|
'#title' => 'Make this field required',
|
|
'#title' => 'Make this field required',
|
|
'#default_value' => $values['required'],
|
|
'#default_value' => $values['required'],
|
|
);
|
|
);
|
|
|
|
|
|
- $form['fields']['additional']['regex_transform'] = array(
|
|
|
|
|
|
+ $form['fields']['field']['additional']['regex_transform'] = array(
|
|
'#type' => 'fieldset',
|
|
'#type' => 'fieldset',
|
|
'#title' => 'Transform Data File Value Rules',
|
|
'#title' => 'Transform Data File Value Rules',
|
|
'#collapsible' => TRUE,
|
|
'#collapsible' => TRUE,
|
|
'#collapsed' => (!empty($values['regex-pattern'])) ? FALSE : TRUE,
|
|
'#collapsed' => (!empty($values['regex-pattern'])) ? FALSE : TRUE,
|
|
);
|
|
);
|
|
|
|
|
|
- $form['fields']['additional']['regex_transform']['regex_description'] = array(
|
|
|
|
|
|
+ $form['fields']['field']['additional']['regex_transform']['regex_description'] = array(
|
|
'#type' => 'item',
|
|
'#type' => 'item',
|
|
'#markup' => 'A transformation rule allows you to transform the original value '
|
|
'#markup' => 'A transformation rule allows you to transform the original value '
|
|
.'(usually from a user submitted data file) into the form you would like it stored '
|
|
.'(usually from a user submitted data file) into the form you would like it stored '
|
|
@@ -2112,14 +2125,14 @@ function tripal_bulk_loader_template_field_form($form, &$form_state = NULL) {
|
|
);
|
|
);
|
|
|
|
|
|
// Also save the rules to ensure they are kept.
|
|
// Also save the rules to ensure they are kept.
|
|
- $form['fields']['additional']['regex_transform']['old_rules'] = array(
|
|
|
|
|
|
+ $form['fields']['field']['additional']['regex_transform']['old_rules'] = array(
|
|
'#type' => 'hidden',
|
|
'#type' => 'hidden',
|
|
'#value' => array(
|
|
'#value' => array(
|
|
'pattern' => $values['regex-pattern'],
|
|
'pattern' => $values['regex-pattern'],
|
|
'replace' => $values['regex-replace']
|
|
'replace' => $values['regex-replace']
|
|
)
|
|
)
|
|
);
|
|
);
|
|
- $form['fields']['additional']['regex_transform']['old_rules']['#value'] = serialize($form['fields']['additional']['regex_transform']['old_rules']['#value']);
|
|
|
|
|
|
+ $form['fields']['field']['additional']['regex_transform']['old_rules']['#value'] = serialize($form['fields']['additional']['regex_transform']['old_rules']['#value']);
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
|
|
|
|
@@ -2131,7 +2144,7 @@ function tripal_bulk_loader_template_field_form($form, &$form_state = NULL) {
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- $form['fields']['additional']['regex_transform']['regex_pattern'] = array(
|
|
|
|
|
|
+ $form['fields']['field']['additional']['regex_transform']['regex_pattern'] = array(
|
|
'#type' => 'textfield',
|
|
'#type' => 'textfield',
|
|
'#title' => 'Match Pattern',
|
|
'#title' => 'Match Pattern',
|
|
'#description' => 'You can use standard php regular expressions in this field to specify a '
|
|
'#description' => 'You can use standard php regular expressions in this field to specify a '
|
|
@@ -2143,7 +2156,7 @@ function tripal_bulk_loader_template_field_form($form, &$form_state = NULL) {
|
|
'#default_value' => $pattern_default,
|
|
'#default_value' => $pattern_default,
|
|
);
|
|
);
|
|
|
|
|
|
- $form['fields']['additional']['regex_transform']['regex_replace'] = array(
|
|
|
|
|
|
+ $form['fields']['field']['additional']['regex_transform']['regex_replace'] = array(
|
|
'#type' => 'textfield',
|
|
'#type' => 'textfield',
|
|
'#title' => 'Replacement Pattern',
|
|
'#title' => 'Replacement Pattern',
|
|
'#description' => 'This pattern should contain the text you want to replace the match pattern '
|
|
'#description' => 'This pattern should contain the text you want to replace the match pattern '
|
|
@@ -2155,7 +2168,7 @@ function tripal_bulk_loader_template_field_form($form, &$form_state = NULL) {
|
|
|
|
|
|
if ($values['field_type'] == 'table field') {
|
|
if ($values['field_type'] == 'table field') {
|
|
$tab = '        ';
|
|
$tab = '        ';
|
|
- $form['fields']['additional']['regex_transform']['regex_replace']['#description'] .= '<p>'
|
|
|
|
|
|
+ $form['fields']['field']['additional']['regex_transform']['regex_replace']['#description'] .= '<p>'
|
|
.'The following references are also available for data file fields: <b><#column:<i>number</i>#></b>. '
|
|
.'The following references are also available for data file fields: <b><#column:<i>number</i>#></b>. '
|
|
.'This allows you to substitute other data file values into the current field. For example, '
|
|
.'This allows you to substitute other data file values into the current field. For example, '
|
|
.'if you had the following line:<br />'
|
|
.'if you had the following line:<br />'
|
|
@@ -2269,12 +2282,15 @@ function tripal_bulk_loader_template_field_form_submit($form, &$form_state) {
|
|
}
|
|
}
|
|
|
|
|
|
// Save old transformation rules if they exist.
|
|
// Save old transformation rules if they exist.
|
|
- if ($form_state['values']['old_rules']) {
|
|
|
|
|
|
+ if (isset($form_state['values']['old_rules'])) {
|
|
$field['regex'] = unserialize($form_state['values']['old_rules']);
|
|
$field['regex'] = unserialize($form_state['values']['old_rules']);
|
|
}
|
|
}
|
|
// Deal with any additional options
|
|
// Deal with any additional options
|
|
if (!empty($form_state['values']['regex_pattern']) AND !empty($form_state['values']['regex_replace'])) {
|
|
if (!empty($form_state['values']['regex_pattern']) AND !empty($form_state['values']['regex_replace'])) {
|
|
- $field['regex']['pattern'] = array('/' . $form_state['values']['regex_pattern'] . '/');
|
|
|
|
|
|
+ if (!preg_match('/^\/.*\/$/', $form_state['values']['regex_pattern'])) {
|
|
|
|
+ $form_state['values']['regex_pattern'] = '/' . $form_state['values']['regex_pattern'] . '/';
|
|
|
|
+ }
|
|
|
|
+ $field['regex']['pattern'] = array($form_state['values']['regex_pattern']);
|
|
$field['regex']['replace'] = array($form_state['values']['regex_replace']);
|
|
$field['regex']['replace'] = array($form_state['values']['regex_replace']);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2282,16 +2298,18 @@ function tripal_bulk_loader_template_field_form_submit($form, &$form_state) {
|
|
// Save Template
|
|
// Save Template
|
|
if ($form_state['storage']['mode'] == 'create') {
|
|
if ($form_state['storage']['mode'] == 'create') {
|
|
$template[$priority]['fields'][] = $field;
|
|
$template[$priority]['fields'][] = $field;
|
|
|
|
+ $success_msg = 'Successfully Added Field to Template';
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
$template[$priority]['fields'][$form_state['storage']['field_index']] = $field;
|
|
$template[$priority]['fields'][$form_state['storage']['field_index']] = $field;
|
|
|
|
+ $success_msg = 'Successfully Updated Field';
|
|
}
|
|
}
|
|
$form_state['storage']['template']->template_array = serialize($template);
|
|
$form_state['storage']['template']->template_array = serialize($template);
|
|
$form_state['storage']['template']->changed = time();
|
|
$form_state['storage']['template']->changed = time();
|
|
$success = drupal_write_record('tripal_bulk_loader_template', $form_state['storage']['template'], array('template_id'));
|
|
$success = drupal_write_record('tripal_bulk_loader_template', $form_state['storage']['template'], array('template_id'));
|
|
|
|
|
|
if ($success) {
|
|
if ($success) {
|
|
- drupal_set_message(t('Successfully Added Field to Template'));
|
|
|
|
|
|
+ drupal_set_message(t($success_msg));
|
|
drupal_set_message(t('Template Saved.'));
|
|
drupal_set_message(t('Template Saved.'));
|
|
|
|
|
|
$form_state['rebuild'] = FALSE;
|
|
$form_state['rebuild'] = FALSE;
|