function _link_process in Link 6.2
Same name and namespace in other branches
- 6 link.module \_link_process()
- 7 link.module \_link_process()
1 call to _link_process()
- link_field in ./
link.module - Implementation of hook_field().
File
- ./
link.inc, line 16 - Helper functions for Link field, widget and form elements.
Code
function _link_process(&$item, $delta = 0, $field, $node) {
// Trim whitespace from URL.
$item['url'] = trim($item['url']);
// if no attributes are set then make sure $item['attributes'] is an empty array - this lets $field['attributes'] override it.
if (empty($item['attributes'])) {
$item['attributes'] = array();
}
// 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'])) {
$item['url'] = NULL;
}
}
// If we don't have a title, then set it to null.
if (!isset($item['title'])) {
$item['title'] = NULL;
}
}