You are here

function ad_get_destination in Advertisement 7.3

Return the destination URL of an ad.

This function supports simple text fields and link fields.

Parameters

stdClass|array $ad: The ad node as an object or array.

Return value

string The destination URL.

2 calls to ad_get_destination()
ad_click in ./ad.module
Callback during a click event.
ad_field_formatter_view in ./ad.field.inc
Implements hook_field_formatter_view().

File

./ad.module, line 324
Core code for the ad module.

Code

function ad_get_destination($ad) {

  // We need to cache objects as arrays, so we might get either an object or
  // an array.
  $node = is_object($ad) ? ad_object_to_array($ad) : $ad;
  $node_type = $node['type'];
  $ad_info = ad_get_info();
  $link_field = $ad_info[$node_type]['link_field'];
  if (!empty($node[$link_field][LANGUAGE_NONE][0]['url'])) {
    return $node[$link_field][LANGUAGE_NONE][0]['url'];
  }
  elseif (!empty($node[$link_field][LANGUAGE_NONE][0]['value'])) {
    return $node[$link_field][LANGUAGE_NONE][0]['value'];
  }
  else {
    return '';
  }
}