function theme_microdata_mapping_admin in Microdata 7
Theme function to output the table for a bundle's mappings.
1 theme call to theme_microdata_mapping_admin()
- microdata_mapping_overview in ./
microdata.admin.inc - Callback function for viewing all bundles' RDF mappings.
File
- ./
microdata.admin.inc, line 372 - Microdata administration and module settings UI.
Code
function theme_microdata_mapping_admin($variables) {
$bundle_type = $variables['bundle_type'];
$entity_type = $variables['entity_type'];
$field_mappings = $variables['field_mappings'];
$bundle_label = check_plain($variables['bundle']['label']);
$itemtypes = array();
foreach ($variables['itemtype'] as $itemtype) {
$itemtypes[] = l($itemtype, $itemtype);
}
$itemtype = !empty($itemtypes) ? implode(', ', $itemtypes) : '—';
$property_info = entity_get_property_info($entity_type);
$rows = array();
// Add the table header for this bundle.
$header = array(
t('Fields'),
t('Property Name(s)'),
t('Itemtype(s)'),
);
// Display a title for each bundle above the mappings table.
$title = "<h3>{$bundle_label}</h3>";
$title .= "<p>" . t('Item Type:') . ' ' . $itemtype . '</p>';
$fields = field_info_instances($entity_type, $bundle_type);
foreach ($fields as $field_name => $field) {
$field_mapping = $field_mappings[$field_name]['microdata_mapping'];
$field_info = field_info_field($field_name);
if (microdata_enabled(field_info_field_types($field_info['type']))) {
$rows[] = array(
'data' => theme('microdata_mapping_admin_overview_row', array(
'field' => $field,
'microdata_mapping' => $field_mapping,
)),
);
}
else {
// @TODO if the field is not microdata enabled, should it still display
// with a message?
}
if (isset($property_info['bundles'][$bundle_type]['properties'][$field_name]['property info'])) {
$properties = $property_info['bundles'][$bundle_type]['properties'][$field_name]['property info'];
$md_properties = array_filter($properties, 'microdata_enabled');
foreach ($md_properties as $property_name => $property) {
$property['label'] = $field['label'] . ' - ' . $property['label'];
$rows[] = array(
'data' => theme('microdata_mapping_admin_overview_row', array(
'field' => $property,
'microdata_mapping' => $field_mapping[$property_name],
)),
);
}
}
}
// If there are no properties, display a message inside the table.
if (!count($rows)) {
$rows[] = array(
'data' => array(
array(
'data' => t('No fields or properties have been configured for this bundle.'),
'colspan' => 5,
),
),
);
}
// Return the table for this bundle.
return array(
'#prefix' => $title,
'#theme' => 'table',
'#rows' => $rows,
'#header' => $header,
);
}