function linkit_process_widget in Linkit 7.2
Process callback.
1 string reference to 'linkit_process_widget'
- linkit_element_info_alter in ./
linkit.module - Implements hook_element_info_alter().
File
- ./
linkit.field.inc, line 53 - Implementation for Fields and Linkit.
Code
function linkit_process_widget(&$element) {
if (!isset($element['#entity_type'])) {
return $element;
}
$field = field_info_field($element['#field_name']);
$instance = field_info_instance($element['#entity_type'], $element['#field_name'], $element['#bundle']);
if (isset($instance['settings']['linkit']['enable']) && $instance['settings']['linkit']['enable']) {
// Add base settings.
_linkit_add_settings('field');
ctools_include('plugins');
// Try to load the insert plugin we have chosen to use.
$plugin = ctools_get_plugins('linkit', 'linkit_insert', $instance['settings']['linkit']['insert_plugin']);
// Set the field ID.
$field_id = $element['#id'];
// Special treatment for link fields.
if ($element['#type'] == 'link_field') {
$field_id = $element['#id'] . '-url';
}
$field_js = array(
'data' => array(
'linkit' => array(
'fields' => array(
$field_id => array(
'insert_plugin' => $instance['settings']['linkit']['insert_plugin'],
),
),
),
),
'type' => 'setting',
);
// Spcial settings for link fields.
if ($element['#type'] == 'link_field') {
$field_js['data']['linkit']['fields'][$field_id]['no_slash'] = TRUE;
// Link fields can have a title field.
if (isset($instance['settings']['title']) && in_array($instance['settings']['title'], array(
'optional',
'required',
))) {
$field_js['data']['linkit']['fields'][$field_id]['title_field'] = $element['#id'] . '-title';
}
}
// Attach js files and settings Linkit needs.
$element += array(
'#attached' => array(
'js' => array(
$plugin['javascript'],
$field_js,
),
),
);
// Add fake button to the element suffix.
$element['#field_suffix'] = '<a class="button linkit-field-button linkit-field-' . $field_id . '" href="#">' . t('Search') . '</a>';
}
return $element;
}