You are here

function theme_rdfx_mapping_admin_overview in RDF Extensions 7.2

Theme function to output the table for a bundle's mappings.

1 theme call to theme_rdfx_mapping_admin_overview()
rdfx_mapping_overview in ./rdfx.admin.inc
Callback function for viewing all bundles' RDF mappings.

File

./rdfx.admin.inc, line 73

Code

function theme_rdfx_mapping_admin_overview($variables) {
  $bundle_label = $variables['bundle']['label'];
  $bundle = $variables['bundle'];
  $real_fields = $variables['real_fields'];
  $fake_fields = $variables['fake_fields'];
  $rows = array();

  // Add the table header for this bundle.
  $header = array(
    t('Fields'),
    t('RDF predicates'),
    t('Mapping type'),
    t('Datatype'),
  );
  if (module_exists('rdfui')) {
    $header[] = t('Operations');
  }

  // Display a title for each bundle above the mappings table. If RDF UI is
  // enabled, also add an 'edit' link.
  $title = "<h3>{$bundle_label}</h3>";
  $edit_link = module_exists('rdfui') && !empty($bundle['edit_path']) ? ' (' . l(t('edit'), $bundle['edit_path']) . ')' : '';
  $title .= "<p>" . t('RDF Types:') . ' ' . $variables['rdftype'] . $edit_link . '</p>';

  // List all of the Field API fields and their mappings.
  foreach ($real_fields as $name => $field) {
    $rows[] = array(
      'data' => theme('rdfx_mapping_admin_overview_row', array(
        'field' => $field,
        'field_name' => $name,
        'edit_path' => $field['edit_path'],
      )),
    );
  }

  // Add any non-Field API entity attributes.
  foreach ($fake_fields as $name => $field) {
    $rows[] = array(
      'data' => theme('rdfx_mapping_admin_overview_row', array(
        'field' => $field,
        'field_name' => $name,
        'edit_path' => $field['edit_path'],
      )),
    );
  }

  // If there are no mappings, display a message inside the table.
  if (!count($rows)) {
    $rows[] = array(
      'data' => array(
        array(
          'data' => t('No mappings have been configured for this bundle.'),
          'colspan' => 5,
        ),
      ),
    );
  }

  // Return the table for this bundle.
  return array(
    '#prefix' => $title,
    '#theme' => 'table',
    '#rows' => $rows,
    '#header' => $header,
  );
}