You are here

function _link_process in Link 6

Same name and namespace in other branches
  1. 6.2 link.inc \_link_process()
  2. 7 link.module \_link_process()
1 call to _link_process()
link_field in ./link.module
Implementation of hook_field().

File

./link.module, line 246
Defines simple link field types.

Code

function _link_process(&$item, $delta = 0, $field, $node) {

  // Remove the target attribute if not selected.
  if (!$item['attributes']['target'] || $item['attributes']['target'] == "default") {
    unset($item['attributes']['target']);
  }

  // Trim whitespace from URL.
  $item['url'] = trim($item['url']);

  // Serialize the attributes array.
  $item['attributes'] = serialize($item['attributes']);

  // Don't save an invalid default value (e.g. 'http://').
  if (isset($field['widget']['default_value'][$delta]['url']) && $item['url'] == $field['widget']['default_value'][$delta]['url'] && is_object($node)) {
    if (!link_validate_url($item['url'])) {
      unset($item['url']);
    }
  }
}