function rdfui_admin_rdf_overview_form in RDF Extensions 7.2
Menu callback; listing of field RDF mappings for a content type.
Allows the content type to be mapped to a RDF class and fields to be mapped to RDF properties.
1 string reference to 'rdfui_admin_rdf_overview_form'
- rdfui_menu in rdfui/
rdfui.module - Implements hook_menu().
File
- rdfui/
rdfui.module, line 122
Code
function rdfui_admin_rdf_overview_form($form, &$form_state, $entity_type, $bundle, $instance) {
$bundle = field_extract_bundle($entity_type, $bundle);
$fields = field_info_instances($entity_type, $bundle);
$mapping = rdf_mapping_load($entity_type, $bundle);
// Don't make assumptions about entities and only get the type if dealing with a node entity
$type = $entity_type == 'node' ? node_type_get_type($bundle) : '';
$form['rdf_mappings'] = array(
'#type' => 'vertical_tabs',
'#attached' => array(
'js' => array(
drupal_get_path('module', 'rdfui') . '/rdfui.js',
),
),
);
// Declare the fieldset and field for RDF type.
$form['type'] = array(
'#type' => 'fieldset',
'#title' => t('Type'),
'#group' => 'rdf_mappings',
'#attributes' => array(
'class' => array(
'rdf-type',
),
),
);
$form['type']['rdf_rdftype'] = array(
'#type' => 'textarea',
'#title' => t('RDF Type'),
'#attached' => array(
'js' => array(
drupal_get_path('module', 'rdfui') . '/rdfui.js',
),
),
);
// Declare the fieldset and field for RDF type.
$form['type'] = array(
'#type' => 'fieldset',
'#title' => t('Type'),
'#group' => 'rdf_mappings',
'#attributes' => array(
'class' => array(
'rdf-field',
),
),
);
$form['type']['rdf_rdftype'] = array(
'#type' => 'textarea',
'#title' => t('RDF Type'),
'#attributes' => array(
'class' => array(
'rdf-field',
),
),
);
// If this entity is a node and has a title display a fieldset for mapping.
if (isset($type->has_title)) {
$form['rdf_title'] = array(
'#type' => 'fieldset',
'#group' => 'rdf_mappings',
'#title' => $type->title_label,
'#attributes' => array(
'class' => array(
'rdf-field',
),
),
);
// Add the options for this entity's title.
rdfui_predicate_fieldset($form['rdf_title'], $mapping, 'title', 'title');
}
// Add the field for RDF type.
rdfui_rdftype_fieldset($form['type']['rdf_rdftype'], $mapping);
// Add the options for all other fields.
foreach ($fields as $field) {
$label = $field['label'];
$field_name = $field['field_name'];
$form[$field_name] = array(
'#type' => 'fieldset',
'#group' => 'rdf_mappings',
'#title' => t('@label', array(
'@label' => $label,
)),
'#attributes' => array(
'class' => array(
'rdf-field',
),
),
);
rdfui_predicate_fieldset($form[$field_name], $mapping, $field_name, $label);
}
$form['field_names'] = array(
'#type' => 'value',
'#value' => array_keys($fields),
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save mappings'),
);
// @todo where is RDFUI_CURIE_REGEX declared?
// drupal_add_js(array('rdfui' => array('termRegex' => RDFUI_CURIE_REGEX)), 'setting');
return $form;
}