function rich_snippets_has_schemaorg_mapping in Rich Snippets 7
Returns TRUE if the field is mapped to a Schema.org schema or property.
This function is an inexact science because the indexing callbacks do not have any information about the entity type or bundle the passed entity belongs to. Therefore we have to guess a little.
Parameters
stdClass $entity: The entity object being indexed.
string $field_name: The machine name of the field being indexed.
Return value
bool Our best guess at whether this field is mapped.
2 calls to rich_snippets_has_schemaorg_mapping()
- rich_snippets_apachesolr_image_indexing_callback in ./
rich_snippets.apachesolr.inc - Indexing callback that stores the image uri.
- rich_snippets_apachesolr_text_indexing_callback in ./
rich_snippets.apachesolr.inc - Indexing callback that stores text.
File
- ./
rich_snippets.apachesolr.inc, line 94 - Apache Solr Search Integration hook implementations and helper functions.
Code
function rich_snippets_has_schemaorg_mapping($entity, $field_name) {
$field_info = field_info_field($field_name);
foreach ($field_info['bundles'] as $entity_type => $bundles) {
$bundles = array_flip($bundles);
$bundle = rich_snippets_extract_bundle($entity_type, $entity);
if ($bundle && isset($bundles[$bundle])) {
$rdf_mapping = rdf_mapping_load($entity_type, $bundle);
if ($schemata = rich_snippets_get_schema_from_predicates($rdf_mapping, $field_name)) {
return TRUE;
}
}
}
return FALSE;
}