5 * filefield_handler_field_data.inc
7 * Provides a handler for displaying values within the serialized data column.
9 class filefield_handler_field_data
extends views_handler_field_node
{
11 function option_definition() {
12 $options = parent
::option_definition();
13 $options['data_key'] = array('default' => 'description');
17 function options_form(&$form, &$form_state) {
18 parent
::options_form($form, $form_state);
21 $info = filefield_data_info();
22 foreach ($info as
$key => $data) {
23 $options[$key] = $data['title'] .
' (' .
$data['module'] .
')';
26 $form['data_key'] = array(
27 '#title' => t('Data key'),
29 '#options' => $options,
31 '#default_value' => $this->options
['data_key'],
32 '#description' => t('The data column may contain only a few or none any of these data options. The name of the module that provides the data is shown in parentheses.'),
37 function admin_summary() {
38 // Display the data to be displayed.
39 $info = filefield_data_info();
40 return isset($info[$this->options
['data_key']]['title']) ?
$info[$this->options
['data_key']]['title'] : $this->options
['data_key'];
43 function render($values) {
44 $values = drupal_clone($values); // Prevent affecting the original.
45 $data = unserialize($values->{$this->field_alias
});
46 $values->{$this->field_alias
} = filefield_data_value($this->options
['data_key'], $data[$this->options
['data_key']]);
48 // Copied from views_handler_field_node(). We just remove the call to
49 // sanitize_value() from the original call, becaue our value has already
50 // been cleaned by filefield_data_value().
51 return $this->render_link($values->{$this->field_alias
}, $values);