commiting uncommited changes on live site
[weblabels.fsf.org.git] / crm.fsf.org / 20131203 / files / sites / all / modules-new / views / modules / field / views_handler_argument_field_list_string.inc
1 <?php
2
3 /**
4 * @file
5 * Definition of views_handler_argument_field_list_text.
6 */
7
8 /**
9 * Argument handler for list field to show the human readable name in the
10 * summary.
11 *
12 * @ingroup views_argument_handlers
13 */
14 class views_handler_argument_field_list_string extends views_handler_argument_string {
15 /**
16 * Stores the allowed values of this field.
17 *
18 * @var array
19 */
20 var $allowed_values = NULL;
21
22 function init(&$view, &$options) {
23 parent::init($view, $options);
24 $field = field_info_field($this->definition['field_name']);
25 $this->allowed_values = list_allowed_values($field);
26 }
27
28 function option_definition() {
29 $options = parent::option_definition();
30
31 $options['summary']['contains']['human'] = array('default' => FALSE, 'bool' => TRUE);
32
33 return $options;
34 }
35
36 function options_form(&$form, &$form_state) {
37 parent::options_form($form, $form_state);
38
39 $form['summary']['human'] = array(
40 '#title' => t('Display list value as human readable'),
41 '#type' => 'checkbox',
42 '#default_value' => $this->options['summary']['human'],
43 '#dependency' => array('radio:options[default_action]' => array('summary')),
44 );
45 }
46
47
48 function summary_name($data) {
49 $value = $data->{$this->name_alias};
50 // If the list element has a human readable name show it,
51 if (isset($this->allowed_values[$value]) && !empty($this->options['summary']['human'])) {
52 return $this->case_transform(field_filter_xss($this->allowed_values[$value]), $this->options['case']);
53 }
54 // else fallback to the key.
55 else {
56 return $this->case_transform(check_plain($value), $this->options['case']);
57 }
58 }
59 }