You are here

function schemaorg_ui_term_load in Schema.org 7

Loads the schema.org term for a particular Drupal field or rdftype.

2 calls to schemaorg_ui_term_load()
schemaorg_ui_form_field_ui_field_edit_form_alter in modules/schemaorg_ui/schemaorg_ui.module
Implements hook_form_FORM_ID_alter().
schemaorg_ui_form_node_type_form_alter in modules/schemaorg_ui/schemaorg_ui.module
Implements hook_form_FORM_ID_alter().

File

modules/schemaorg_ui/schemaorg_ui.module, line 201
User interface for setting the schema.org mappings

Code

function schemaorg_ui_term_load($type, $bundle, $field) {
  $terms = array();
  $mapping = rdf_mapping_load($type, $bundle);
  if ($field == 'rdftype' && !empty($mapping['rdftype'])) {
    $terms = $mapping['rdftype'];
  }
  elseif (!empty($mapping[$field]['predicates'])) {
    $terms = $mapping[$field]['predicates'];
  }

  // Return the first schema: term.
  foreach ($terms as $term) {
    if (strpos(trim($term), 'schema:') === 0) {
      return str_replace('schema:', '', $term);
    }
  }
}