function dfp_entity_view in Doubleclick for Publishers (DFP) 7.2
Same name and namespace in other branches
- 7 dfp.module \dfp_entity_view()
Implements hook_entity_view().
File
- ./
dfp.module, line 171
Code
function dfp_entity_view($entity, $type, $view_mode, $langcode) {
$dfp_targeting_terms =& drupal_static('dfp_entity_targeting_terms', array());
if (variable_get('dfp_enable_ad_categories', 0) && $view_mode == 'full') {
// If this entity is itself a taxonomy term add it to the
// dfp_targetting_terms array. Check it to see if a DFP Ad Category
// has been assigned to it. If so, add that term to the array instead. Note
// that we check all types of entities here because any fieldable entity can
// have a taxonomy term reference field attached to it.
if ($type == 'taxonomy_term') {
$dfp_targeting_terms[] = _dfp_get_ad_category($entity, TRUE);
}
// Find all taxonomy terms attached to the given entity and add them to the
// dfp_targeting_terms array. Check each term to see if a DFP Ad Category
// has been assigned to it. If so, add that term to the array instead.
foreach (element_children($entity->content) as $key) {
if (isset($entity->content[$key]['#field_type']) && $entity->content[$key]['#field_type'] == 'taxonomy_term_reference') {
$terms = field_view_field($type, $entity, $key);
if (isset($terms['#items']) && is_array($terms['#items'])) {
foreach ($terms['#items'] as $item) {
if (array_key_exists('taxonomy_term', $item)) {
$dfp_targeting_terms[] = _dfp_get_ad_category($item['taxonomy_term'], TRUE);
}
}
}
}
}
$dfp_targeting_terms = array_unique($dfp_targeting_terms);
}
}