function chado_pub_node_form_add_pub_table_props
1.x pub_form.inc | chado_pub_node_form_add_pub_table_props(&$form, $form_state, $properties_list,
&$d_properties, &$d_removed, $d_volume, $d_volumetitle, $d_issue, $d_pages, $d_series_name) |
1 call to chado_pub_node_form_add_pub_table_props()
- chado_pub_form in tripal_pub/
includes/ pub_form.inc
File
- tripal_pub/
includes/ pub_form.inc, line 613
Code
function chado_pub_node_form_add_pub_table_props(&$form, $form_state, $properties_list,
&$d_properties, &$d_removed, $d_volume, $d_volumetitle, $d_issue, $d_pages, $d_series_name) {
$num_properties = 0;
$rank = 0;
// add properties that are actually part of the pub table
foreach ($properties_list as $type_id => $prop) {
// skip any properties that the user requested to delete through a previous
// AHAH callback or through the current AHAH callback
if ($d_removed["$type_id-$rank"]) {
continue;
}
if ($form_state['post']["remove-$type_id-$rank"]) {
$d_removed["$type_id-$rank"] = 1;
continue;
}
// if any of the properties match the fields in the pub table then we
// want to include those automatically
if (($prop->name == 'Volume' and $d_volume) or
($prop->name == 'Issue' and $d_issue) or
($prop->name == 'Pages' and $d_pages) or
($prop->name == 'Volume Title' and $d_volumetitle) or
($prop->name == 'Journal Name' and $d_series_name)) {
$d_properties[$type_id][$rank]['name'] = $prop->name;
$d_properties[$type_id][$rank]['id'] = $type_id;
$d_properties[$type_id][$rank]['definition'] = $prop->definition;
$num_properties++;
if ($prop->name == 'Volume') {
$d_properties[$type_id][$rank]['value'] = $d_volume;
}
if ($prop->name == 'Issue') {
$d_properties[$type_id][$rank]['value'] = $d_issue;
}
if ($prop->name == 'Pages') {
$d_properties[$type_id][$rank]['value'] = $d_pages;
}
if ($prop->name == 'Volume Title') {
$d_properties[$type_id][$rank]['value'] = $d_volumetitle;
}
if ($prop->name == 'Journal Name') {
$d_properties[$type_id][$rank]['value'] = $d_series_name;
}
// determine how many rows we need in the textarea
$rows = 1;
if (preg_match('/Abstract/', $prop->name)) {
$rows = 10;
}
if ($prop->name == 'Authors') {
$rows = 2;
}
// add in the fields
$form['properties'][$type_id][$rank]["prop_id-$type_id-$rank"] = array(
'#type' => 'item',
'#value' => $prop->name
);
$form['properties'][$type_id][$rank]["prop_value-$type_id-$rank"] = array(
'#type' => 'textarea',
'#default_value' => $d_properties[$type_id][$rank]['value'],
'#cols' => 50,
'#rows' => $rows,
'#description' => $description,
);
$form['properties'][$type_id][$rank]["remove-$type_id-$rank"] = array(
'#type' => 'image_button',
'#value' => t('Remove'),
'#src' => drupal_get_path('theme', 'tripal') . '/images/minus.png',
'#ahah' => array(
'path' => "tripal_pub/properties/minus/$type_id/$rank",
'wrapper' => 'tripal-pub-edit-properties-table',
'event' => 'click',
'method' => 'replace',
),
'#attributes' => array('onClick' => 'return false;'),
);
}
}
return $num_properties;
}