function rdfx_mapping_overview in RDF Extensions 7.2
Callback function for viewing all bundles' RDF mappings.
1 string reference to 'rdfx_mapping_overview'
- rdfx_menu in ./
rdfx.module - Implements hook_menu().
File
- ./
rdfx.admin.inc, line 6
Code
function rdfx_mapping_overview() {
$render = array();
$entities = entity_get_info();
$fields = field_info_instances();
$render['tabs'] = array(
'#type' => 'vertical_tabs',
);
// Create a tab for each entity.
foreach ($entities as $entity_type => $entity) {
$render['tabs'][$entity_type] = array(
'#type' => 'fieldset',
'#title' => $entity['label'],
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
// The bundle's RDF mapping array may contain mappings for entity attributes
// that are not fields. The bundle's field array may contain fields that are
// not in the RDF mapping array. In order to ensure we get all the available
// fields and all the mapped entity attributes, we compare the arrays.
foreach ($entity['bundles'] as $bundle_name => $bundle) {
$rows = array();
$real_fields = array();
$fake_fields = array();
$bundle_fields = $fields[$entity_type][$bundle_name];
$bundle['edit_path'] = NULL;
$rdf_mapping = $bundle['rdf_mapping'];
if (isset($bundle['admin']['real path'])) {
$bundle['edit_path'] = $bundle['admin']['real path'] . '/rdf';
}
// Set RDF type.
if (isset($rdf_mapping['rdftype'])) {
$rdftype = implode(', ', $rdf_mapping['rdftype']);
unset($rdf_mapping['rdftype']);
}
foreach ($rdf_mapping as $field_name => $mapping_info) {
// Gather Field API fields.
if (isset($bundle_fields[$field_name])) {
$real_fields[$field_name]['rdf_mapping'] = $mapping_info;
$real_fields[$field_name]['label'] = $fields[$entity_type][$bundle_name][$field_name]['label'];
$real_fields[$field_name]['edit_path'] = $bundle['edit_path'];
unset($bundle_fields[$field_name]);
}
else {
$fake_fields[$field_name]['rdf_mapping'] = $mapping_info;
$fake_fields[$field_name]['label'] = $field_name;
$fake_fields[$field_name]['edit_path'] = $field_name == 'title' ? $bundle['edit_path'] : NULL;
}
}
// Theme this bundle's table and add it to it's parent entity's tab.
$variables = array(
'bundle' => $bundle,
'rdftype' => $rdftype,
'real_fields' => $real_fields,
'fake_fields' => $fake_fields,
);
$render['tabs'][$entity_type][$bundle_name] = theme('rdfx_mapping_admin_overview', $variables);
}
}
return $render;
}