function _simpleads_ads_data in SimpleAds 7
Helper function. Builts array for templates.
Parameters
object $node:
2 calls to _simpleads_ads_data()
- template_preprocess_views_simpleads in includes/
simpleads.theme.inc - Preprocess for SimpleAds Views template. views-simpleads.tpl.php
- _simpleads_load_ads in includes/
simpleads.helper.inc - Helper function. Returns data array for an adertisement block.
File
- includes/
simpleads.helper.inc, line 56 - SimpleAds Helper functions.
Code
function _simpleads_ads_data($node) {
$data =& drupal_static(__FUNCTION__);
if (is_object($node)) {
$type = 'graphic';
if (isset($node->field_ad_type[$node->language]) && !empty($node->field_ad_type[$node->language][0]['value'])) {
$type = $node->field_ad_type[$node->language][0]['value'];
}
$destination_url = "";
if (isset($node->field_ad_url[$node->language]) && !empty($node->field_ad_url[$node->language][0]['value'])) {
$destination_url = $node->field_ad_url[$node->language][0]['value'];
}
$image = "";
$image_uri = "";
$alt = "";
if (isset($node->field_ad_image[$node->language]) && !empty($node->field_ad_image[$node->language][0]['uri'])) {
$image = file_create_url($node->field_ad_image[$node->language][0]['uri']);
$alt = $node->field_ad_image[$node->language][0]['alt'];
$image_uri = $node->field_ad_image[$node->language][0]['uri'];
}
$flash = "";
if (isset($node->field_ad_flash[$node->language]) && !empty($node->field_ad_flash[$node->language][0]['uri'])) {
$flash = file_create_url($node->field_ad_flash[$node->language][0]['uri']);
}
$text_ad = "";
$text_format = "plain_text";
if (isset($node->field_ad_text[$node->language]) && !empty($node->field_ad_text[$node->language][0]['value'])) {
if (isset($node->field_ad_text[$node->language]) && $node->field_ad_text[$node->language][0]['format'] != $text_format) {
$text_format = $node->field_ad_text[$node->language][0]['format'];
$text_ad = check_markup($node->field_ad_text[$node->language][0]['value'], $text_format);
}
else {
$text_ad = strip_tags($node->field_ad_text[$node->language][0]['value']);
}
}
$target = TRUE;
if (isset($node->field_ad_url_taget[$node->language]) && $node->field_ad_url_taget[$node->language][0]['value'] == 0) {
$target = FALSE;
}
$data = array(
'type' => $type,
'url' => url('simpleads/redirect/' . $node->nid, array(
'absolute' => TRUE,
)),
'destination_url' => $destination_url,
'target' => $target,
'image' => $image,
'image_uri' => $image_uri,
'alt' => $alt,
'nid' => $node->nid,
'node' => $node,
'text' => $text_ad,
'text_format' => $text_format,
'flash' => $flash,
);
drupal_alter('simpleads', $data);
return $data;
}
}