| 1 |
<?php
|
| 2 |
// $Id: linkimagefield_formatter.inc,v 1.3 2009/07/25 00:26:19 johnfyoung Exp $
|
| 3 |
/**
|
| 4 |
* @file
|
| 5 |
*
|
| 6 |
* linkimagefield formatter code
|
| 7 |
* @author John Young <john@codeandcreative.com>
|
| 8 |
*/
|
| 9 |
function theme_linkimagefield_formatter_linkimage($element) {
|
| 10 |
// Inside a view $element may contain null data. In that case, just return.
|
| 11 |
if (empty($element['#item']['fid'])) {
|
| 12 |
return '';
|
| 13 |
}
|
| 14 |
|
| 15 |
$field = content_fields($element['#field_name']);
|
| 16 |
$item = $element['#item'];
|
| 17 |
|
| 18 |
$item['data']['alt'] = _linkimagefield_format_set_attribute('alt', $item, $field);
|
| 19 |
$item['data']['title'] = _linkimagefield_format_set_attribute('title', $item, $field);
|
| 20 |
$item['data']['url'] = _linkimagefield_format_set_attribute('url', $item, $field);
|
| 21 |
$item['data']['target'] = _linkimagefield_format_set_attribute('target', $item, $field);
|
| 22 |
|
| 23 |
$class = 'linkimagefield linkimagefield-'. $field['field_name'];
|
| 24 |
return theme('linkimagefield_image', $item, $item['data']['alt'], $item['data']['title'], array('class' => $class), TRUE, $item['data']['url'], $item['data']['target'], $item['data']['nofollow']);
|
| 25 |
}
|
| 26 |
|
| 27 |
function theme_linkimagefield_formatter_linkimage_justlink($element) {
|
| 28 |
$item = $element['#item'];
|
| 29 |
$field = content_fields($element['#field_name']);
|
| 30 |
|
| 31 |
// Inside a view $element may contain null data. In that case, just return.
|
| 32 |
if (empty($item['data']['url']) && empty($field['widget']['url'])) {
|
| 33 |
return '';
|
| 34 |
}
|
| 35 |
|
| 36 |
$item['data']['title'] = _linkimagefield_format_set_attribute('title', $item, $field);
|
| 37 |
$item['data']['url'] = _linkimagefield_format_set_attribute('url', $item, $field);
|
| 38 |
$item['data']['target'] = _linkimagefield_format_set_attribute('target', $item, $field);
|
| 39 |
|
| 40 |
$class = 'linkimagefield linkimagefield-justlink linkimagefield-'. $field['field_name'];
|
| 41 |
return theme('linkimagefield_justlink', $item['data']['url'], $item['data']['target'], $item['data']['title'], $class, $item['data']['nofollow']);
|
| 42 |
}
|