@@ -7,68 +7,68 @@ |
||
7 | 7 | * values by allowing the views administrator to select deltas. |
8 | 8 | */ |
9 | 9 | class content_handler_sort extends views_handler_sort { |
10 | - var $content_field; |
|
10 | + var $content_field; |
|
11 | 11 | |
12 | - function construct() { |
|
12 | + function construct() { |
|
13 | 13 | parent::construct(); |
14 | 14 | |
15 | 15 | $this->content_field = content_fields($this->definition['content_field_name']); |
16 | 16 | $this->additional_fields = $this->definition['additional fields']; |
17 | - } |
|
17 | + } |
|
18 | 18 | |
19 | - function option_definition() { |
|
19 | + function option_definition() { |
|
20 | 20 | $options = parent::option_definition(); |
21 | 21 | $options['delta'] = array('default' => -1); |
22 | 22 | |
23 | 23 | return $options; |
24 | - } |
|
24 | + } |
|
25 | 25 | |
26 | - /** |
|
27 | - * Add a delta selector for multiple fields. |
|
28 | - */ |
|
29 | - function options_form(&$form, &$form_state) { |
|
26 | + /** |
|
27 | + * Add a delta selector for multiple fields. |
|
28 | + */ |
|
29 | + function options_form(&$form, &$form_state) { |
|
30 | 30 | $field = $this->content_field; |
31 | 31 | parent::options_form($form, $form_state); |
32 | 32 | |
33 | 33 | // Only add the form gadget if the field is multiple. |
34 | 34 | if ($field['multiple']) { |
35 | - $max_delta = $field['multiple']; |
|
36 | - // 1 means unlimited. |
|
37 | - if ($max_delta == 1) { |
|
35 | + $max_delta = $field['multiple']; |
|
36 | + // 1 means unlimited. |
|
37 | + if ($max_delta == 1) { |
|
38 | 38 | $max_delta = 10; |
39 | - } |
|
39 | + } |
|
40 | 40 | |
41 | - $options = array('-1' => t('All')); |
|
42 | - for ($i = 0; $i < $max_delta; $i++) { |
|
41 | + $options = array('-1' => t('All')); |
|
42 | + for ($i = 0; $i < $max_delta; $i++) { |
|
43 | 43 | $options[$i] = $i + 1; |
44 | - } |
|
45 | - $form['delta'] = array( |
|
44 | + } |
|
45 | + $form['delta'] = array( |
|
46 | 46 | '#type' => 'select', |
47 | 47 | '#options' => $options, |
48 | 48 | '#default_value' => $this->options['delta'], |
49 | 49 | '#title' => t('Delta'), |
50 | 50 | '#description' => t('The delta allows you to select which item in a multiple value field will be used for sorting. Select "1" to use the first item, "2" for the second item, and so on. If you select "All", each item in the field will create a new row, which may appear to cause duplicates.'), |
51 | - ); |
|
51 | + ); |
|
52 | + } |
|
52 | 53 | } |
53 | - } |
|
54 | 54 | |
55 | - function ensure_my_table() { |
|
55 | + function ensure_my_table() { |
|
56 | 56 | if (!isset($this->table_alias)) { |
57 | - $join = $this->get_join(); |
|
58 | - if (!isset($join->extra)) { |
|
57 | + $join = $this->get_join(); |
|
58 | + if (!isset($join->extra)) { |
|
59 | 59 | $join->extra = array(); |
60 | - } |
|
61 | - $delta = isset($this->options['delta']) ? $this->options['delta'] : -1; |
|
62 | - if ($delta != -1) { |
|
60 | + } |
|
61 | + $delta = isset($this->options['delta']) ? $this->options['delta'] : -1; |
|
62 | + if ($delta != -1) { |
|
63 | 63 | $join->extra[] = array( |
64 | - 'field' => 'delta', |
|
65 | - 'value' => $delta, |
|
66 | - 'numeric' => TRUE, |
|
64 | + 'field' => 'delta', |
|
65 | + 'value' => $delta, |
|
66 | + 'numeric' => TRUE, |
|
67 | 67 | ); |
68 | - } |
|
68 | + } |
|
69 | 69 | |
70 | - $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); |
|
70 | + $this->table_alias = $this->query->ensure_table($this->table, $this->relationship, $join); |
|
71 | 71 | } |
72 | 72 | return $this->table_alias; |
73 | - } |
|
73 | + } |
|
74 | 74 | } |
75 | 75 | \ No newline at end of file |
@@ -62,7 +62,7 @@ |
||
62 | 62 | $join->extra[] = array( |
63 | 63 | 'field' => 'delta', |
64 | 64 | 'value' => $delta, |
65 | - 'numeric' => TRUE, |
|
65 | + 'numeric' => true, |
|
66 | 66 | ); |
67 | 67 | } |
68 | 68 |
@@ -7,36 +7,36 @@ |
||
7 | 7 | * for field-specific subclasses to use if they need to. |
8 | 8 | */ |
9 | 9 | class content_handler_filter_many_to_one extends views_handler_filter_many_to_one { |
10 | - var $content_field; |
|
10 | + var $content_field; |
|
11 | 11 | |
12 | - function construct() { |
|
12 | + function construct() { |
|
13 | 13 | parent::construct(); |
14 | 14 | $this->content_field = content_fields($this->definition['content_field_name']); |
15 | 15 | $this->additional_fields = $this->definition['additional fields']; |
16 | 16 | $field = $this->content_field; |
17 | 17 | $this->value_title = $field['widget']['label']; |
18 | - } |
|
18 | + } |
|
19 | 19 | |
20 | - function get_value_options() { |
|
20 | + function get_value_options() { |
|
21 | 21 | $this->value_options = $this->allowed_values(); |
22 | - } |
|
22 | + } |
|
23 | 23 | |
24 | - // Get allowed values from hook_allowed_values(), if any, |
|
25 | - // or from content_allowed_values(); |
|
26 | - function allowed_values() { |
|
24 | + // Get allowed values from hook_allowed_values(), if any, |
|
25 | + // or from content_allowed_values(); |
|
26 | + function allowed_values() { |
|
27 | 27 | $field = $this->content_field; |
28 | 28 | $function = $field['module'] .'_allowed_values'; |
29 | 29 | if ($this->value_form_type == 'select') { |
30 | - // Select elements accept multidimensional arrays to support optgroups. |
|
31 | - $options = function_exists($function) ? $function($field) : content_allowed_values($field, FALSE); |
|
32 | - // For selects, HTML should be filtered out and entities left unencoded. |
|
33 | - // See content_allowed_values / content_filter_xss / filter_xss. |
|
34 | - content_allowed_values_filter_html($options); |
|
30 | + // Select elements accept multidimensional arrays to support optgroups. |
|
31 | + $options = function_exists($function) ? $function($field) : content_allowed_values($field, FALSE); |
|
32 | + // For selects, HTML should be filtered out and entities left unencoded. |
|
33 | + // See content_allowed_values / content_filter_xss / filter_xss. |
|
34 | + content_allowed_values_filter_html($options); |
|
35 | 35 | } |
36 | 36 | else { |
37 | - $options = function_exists($function) ? $function($field) : content_allowed_values($field); |
|
37 | + $options = function_exists($function) ? $function($field) : content_allowed_values($field); |
|
38 | 38 | } |
39 | 39 | return (array) $options; |
40 | - } |
|
40 | + } |
|
41 | 41 | |
42 | 42 | } |
43 | 43 | \ No newline at end of file |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | // or from content_allowed_values(); |
26 | 26 | function allowed_values() { |
27 | 27 | $field = $this->content_field; |
28 | - $function = $field['module'] .'_allowed_values'; |
|
28 | + $function = $field['module'].'_allowed_values'; |
|
29 | 29 | if ($this->value_form_type == 'select') { |
30 | 30 | // Select elements accept multidimensional arrays to support optgroups. |
31 | 31 | $options = function_exists($function) ? $function($field) : content_allowed_values($field, FALSE); |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | else { |
37 | 37 | $options = function_exists($function) ? $function($field) : content_allowed_values($field); |
38 | 38 | } |
39 | - return (array) $options; |
|
39 | + return (array)$options; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | } |
43 | 43 | \ No newline at end of file |
@@ -32,8 +32,7 @@ |
||
32 | 32 | // For selects, HTML should be filtered out and entities left unencoded. |
33 | 33 | // See content_allowed_values / content_filter_xss / filter_xss. |
34 | 34 | content_allowed_values_filter_html($options); |
35 | - } |
|
36 | - else { |
|
35 | + } else { |
|
37 | 36 | $options = function_exists($function) ? $function($field) : content_allowed_values($field); |
38 | 37 | } |
39 | 38 | return (array) $options; |
@@ -28,7 +28,7 @@ |
||
28 | 28 | $function = $field['module'] .'_allowed_values'; |
29 | 29 | if ($this->value_form_type == 'select') { |
30 | 30 | // Select elements accept multidimensional arrays to support optgroups. |
31 | - $options = function_exists($function) ? $function($field) : content_allowed_values($field, FALSE); |
|
31 | + $options = function_exists($function) ? $function($field) : content_allowed_values($field, false); |
|
32 | 32 | // For selects, HTML should be filtered out and entities left unencoded. |
33 | 33 | // See content_allowed_values / content_filter_xss / filter_xss. |
34 | 34 | content_allowed_values_filter_html($options); |
@@ -7,12 +7,12 @@ |
||
7 | 7 | * for field-specific subclasses to use if they need to. |
8 | 8 | */ |
9 | 9 | class content_handler_argument extends views_handler_argument { |
10 | - var $content_field; |
|
10 | + var $content_field; |
|
11 | 11 | |
12 | - function construct() { |
|
12 | + function construct() { |
|
13 | 13 | parent::construct(); |
14 | 14 | |
15 | 15 | $this->content_field = content_fields($this->definition['content_field_name']); |
16 | 16 | $this->additional_fields = $this->definition['additional fields']; |
17 | - } |
|
17 | + } |
|
18 | 18 | } |
19 | 19 | \ No newline at end of file |
@@ -6,43 +6,43 @@ |
||
6 | 6 | * Handler for 'content_handler_argument_many_to_one' style. |
7 | 7 | */ |
8 | 8 | class content_handler_argument_many_to_one extends views_handler_argument_many_to_one { |
9 | - var $content_field; |
|
9 | + var $content_field; |
|
10 | 10 | |
11 | - function construct() { |
|
11 | + function construct() { |
|
12 | 12 | parent::construct(); |
13 | 13 | |
14 | 14 | $this->content_field = content_fields($this->definition['content_field_name']); |
15 | 15 | $this->additional_fields = $this->definition['additional fields']; |
16 | - } |
|
16 | + } |
|
17 | 17 | |
18 | - function summary_name($data) { |
|
18 | + function summary_name($data) { |
|
19 | 19 | $options = $this->allowed_values(); |
20 | 20 | $value = $data->{$this->name_alias}; |
21 | 21 | if (isset($options[$value])) { |
22 | - $value = $options[$value]; |
|
22 | + $value = $options[$value]; |
|
23 | 23 | } |
24 | 24 | else { |
25 | - $value = parent::summary_name($data); |
|
25 | + $value = parent::summary_name($data); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | return $value; |
29 | - } |
|
29 | + } |
|
30 | 30 | |
31 | - function title_query() { |
|
31 | + function title_query() { |
|
32 | 32 | $options = $this->allowed_values(); |
33 | 33 | $values = $this->value; |
34 | 34 | foreach ($values as $key => $value) { |
35 | - if (isset($options[$value])) { |
|
35 | + if (isset($options[$value])) { |
|
36 | 36 | $values[$key] = $options[$value]; |
37 | - } |
|
37 | + } |
|
38 | 38 | } |
39 | 39 | return $values; |
40 | - } |
|
40 | + } |
|
41 | 41 | |
42 | - function allowed_values() { |
|
42 | + function allowed_values() { |
|
43 | 43 | $field = $this->content_field; |
44 | 44 | $function = $field['module'] .'_allowed_values'; |
45 | 45 | $options = function_exists($function) ? $function($field) : content_allowed_values($field); |
46 | 46 | return (array) $options; |
47 | - } |
|
47 | + } |
|
48 | 48 | } |
49 | 49 | \ No newline at end of file |
@@ -41,8 +41,8 @@ |
||
41 | 41 | |
42 | 42 | function allowed_values() { |
43 | 43 | $field = $this->content_field; |
44 | - $function = $field['module'] .'_allowed_values'; |
|
44 | + $function = $field['module'].'_allowed_values'; |
|
45 | 45 | $options = function_exists($function) ? $function($field) : content_allowed_values($field); |
46 | - return (array) $options; |
|
46 | + return (array)$options; |
|
47 | 47 | } |
48 | 48 | } |
49 | 49 | \ No newline at end of file |
@@ -20,8 +20,7 @@ |
||
20 | 20 | $value = $data->{$this->name_alias}; |
21 | 21 | if (isset($options[$value])) { |
22 | 22 | $value = $options[$value]; |
23 | - } |
|
24 | - else { |
|
23 | + } else { |
|
25 | 24 | $value = parent::summary_name($data); |
26 | 25 | } |
27 | 26 |
@@ -7,11 +7,11 @@ |
||
7 | 7 | * for field-specific subclasses to use if they need to. |
8 | 8 | */ |
9 | 9 | class content_handler_filter_numeric extends views_handler_filter_numeric { |
10 | - var $content_field; |
|
10 | + var $content_field; |
|
11 | 11 | |
12 | - function construct() { |
|
12 | + function construct() { |
|
13 | 13 | parent::construct(); |
14 | 14 | $this->content_field = content_fields($this->definition['content_field_name']); |
15 | 15 | $this->additional_fields = $this->definition['additional fields']; |
16 | - } |
|
16 | + } |
|
17 | 17 | } |
18 | 18 | \ No newline at end of file |
@@ -10,17 +10,17 @@ |
||
10 | 10 | // Ensure compatibility with Views pre 2.4, where the |
11 | 11 | // views_handler_filter_float class lived in views_handler_filter_numeric.inc. |
12 | 12 | if (!class_exists('views_handler_filter_float')) { |
13 | - // Manually include the parent class. |
|
14 | - $definition = views_fetch_handler_data('views_handler_filter_numeric'); |
|
15 | - views_include_handler($definition, 'handler'); |
|
13 | + // Manually include the parent class. |
|
14 | + $definition = views_fetch_handler_data('views_handler_filter_numeric'); |
|
15 | + views_include_handler($definition, 'handler'); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | class content_handler_filter_float extends views_handler_filter_float { |
19 | - var $content_field; |
|
19 | + var $content_field; |
|
20 | 20 | |
21 | - function construct() { |
|
21 | + function construct() { |
|
22 | 22 | parent::construct(); |
23 | 23 | $this->content_field = content_fields($this->definition['content_field_name']); |
24 | 24 | $this->additional_fields = $this->definition['additional fields']; |
25 | - } |
|
25 | + } |
|
26 | 26 | } |
27 | 27 | \ No newline at end of file |
@@ -9,129 +9,129 @@ discard block |
||
9 | 9 | * field and formatter handling can extend this class. |
10 | 10 | */ |
11 | 11 | class content_handler_field_multiple extends content_handler_field { |
12 | - var $defer_query; |
|
12 | + var $defer_query; |
|
13 | 13 | |
14 | - function init(&$view, $options) { |
|
14 | + function init(&$view, $options) { |
|
15 | 15 | $field = $this->content_field; |
16 | 16 | parent::init($view, $options); |
17 | 17 | |
18 | 18 | $this->defer_query = !empty($options['multiple']['group']) && $field['multiple']; |
19 | 19 | |
20 | 20 | if ($this->defer_query) { |
21 | - // Grouped field: ditch the existing additional_fields (field columns + delta). |
|
22 | - // In the main query we'll only need: |
|
23 | - // - vid, which will be used to retrieve the actual values in pre_render, |
|
24 | - // - node type and nid, which wil be used in the pseudo-node used when |
|
25 | - // rendering. |
|
26 | - $this->additional_fields = array( |
|
21 | + // Grouped field: ditch the existing additional_fields (field columns + delta). |
|
22 | + // In the main query we'll only need: |
|
23 | + // - vid, which will be used to retrieve the actual values in pre_render, |
|
24 | + // - node type and nid, which wil be used in the pseudo-node used when |
|
25 | + // rendering. |
|
26 | + $this->additional_fields = array( |
|
27 | 27 | 'type' => array('table' => 'node', 'field' => 'type'), |
28 | 28 | 'nid' => array('table' => 'node', 'field' => 'nid'), |
29 | - ); |
|
30 | - if ($view->base_table == 'node_revisions') { |
|
29 | + ); |
|
30 | + if ($view->base_table == 'node_revisions') { |
|
31 | 31 | $this->additional_fields['vid'] = array('table' => 'node_revisions', 'field' => 'vid'); |
32 | - } |
|
33 | - else { |
|
32 | + } |
|
33 | + else { |
|
34 | 34 | $this->additional_fields['vid'] = array('table' => 'node', 'field' => 'vid'); |
35 | - } |
|
35 | + } |
|
36 | + } |
|
36 | 37 | } |
37 | - } |
|
38 | 38 | |
39 | - function option_definition() { |
|
39 | + function option_definition() { |
|
40 | 40 | $options = parent::option_definition(); |
41 | 41 | |
42 | 42 | $options['multiple'] = array( |
43 | - 'contains' => array( |
|
43 | + 'contains' => array( |
|
44 | 44 | 'group' => array('default' => TRUE), |
45 | 45 | 'multiple_number' => array('default' => ''), |
46 | 46 | 'multiple_from' => array('default' => ''), |
47 | 47 | 'multiple_reversed' => array('default' => FALSE), |
48 | - ), |
|
48 | + ), |
|
49 | 49 | ); |
50 | 50 | |
51 | 51 | return $options; |
52 | - } |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Provide 'group multiple values' option. |
|
56 | - */ |
|
57 | - function options_form(&$form, &$form_state) { |
|
54 | + /** |
|
55 | + * Provide 'group multiple values' option. |
|
56 | + */ |
|
57 | + function options_form(&$form, &$form_state) { |
|
58 | 58 | parent::options_form($form, $form_state); |
59 | 59 | |
60 | 60 | $field = $this->content_field; |
61 | 61 | $options = $this->options; |
62 | 62 | |
63 | 63 | $form['multiple'] = array( |
64 | - '#access' => $field['multiple'], |
|
65 | - '#weight' => 1, |
|
64 | + '#access' => $field['multiple'], |
|
65 | + '#weight' => 1, |
|
66 | 66 | ); |
67 | 67 | $form['multiple']['group'] = array( |
68 | - '#title' => t('Group multiple values'), |
|
69 | - '#type' => 'checkbox', |
|
70 | - '#default_value' => $options['multiple']['group'], |
|
71 | - '#description' => t('If unchecked, each item in the field will create a new row, which may appear to cause duplicates. This setting is not compatible with click-sorting in table displays.'), |
|
68 | + '#title' => t('Group multiple values'), |
|
69 | + '#type' => 'checkbox', |
|
70 | + '#default_value' => $options['multiple']['group'], |
|
71 | + '#description' => t('If unchecked, each item in the field will create a new row, which may appear to cause duplicates. This setting is not compatible with click-sorting in table displays.'), |
|
72 | 72 | ); |
73 | 73 | // Make the string translatable by keeping it as a whole rather than |
74 | 74 | // translating prefix and suffix separately. |
75 | 75 | list($prefix, $suffix) = explode('@count', t('Show @count value(s)')); |
76 | 76 | $form['multiple']['multiple_number'] = array( |
77 | - '#type' => 'textfield', |
|
78 | - '#size' => 5, |
|
79 | - '#field_prefix' => $prefix, |
|
80 | - '#field_suffix' => $suffix, |
|
81 | - '#default_value' => $options['multiple']['multiple_number'], |
|
82 | - '#prefix' => '<div class="container-inline">', |
|
83 | - '#process' => array('views_process_dependency'), |
|
84 | - '#dependency' => array('edit-options-multiple-group' => array(TRUE)), |
|
77 | + '#type' => 'textfield', |
|
78 | + '#size' => 5, |
|
79 | + '#field_prefix' => $prefix, |
|
80 | + '#field_suffix' => $suffix, |
|
81 | + '#default_value' => $options['multiple']['multiple_number'], |
|
82 | + '#prefix' => '<div class="container-inline">', |
|
83 | + '#process' => array('views_process_dependency'), |
|
84 | + '#dependency' => array('edit-options-multiple-group' => array(TRUE)), |
|
85 | 85 | ); |
86 | 86 | list($prefix, $suffix) = explode('@count', t('starting from @count')); |
87 | 87 | $form['multiple']['multiple_from'] = array( |
88 | - '#type' => 'textfield', |
|
89 | - '#size' => 5, |
|
90 | - '#field_prefix' => $prefix, |
|
91 | - '#field_suffix' => $suffix, |
|
92 | - '#default_value' => $options['multiple']['multiple_from'], |
|
93 | - '#process' => array('views_process_dependency'), |
|
94 | - '#dependency' => array('edit-options-multiple-group' => array(TRUE)), |
|
95 | - '#description' => t('(first item is 0)'), |
|
88 | + '#type' => 'textfield', |
|
89 | + '#size' => 5, |
|
90 | + '#field_prefix' => $prefix, |
|
91 | + '#field_suffix' => $suffix, |
|
92 | + '#default_value' => $options['multiple']['multiple_from'], |
|
93 | + '#process' => array('views_process_dependency'), |
|
94 | + '#dependency' => array('edit-options-multiple-group' => array(TRUE)), |
|
95 | + '#description' => t('(first item is 0)'), |
|
96 | 96 | ); |
97 | 97 | $form['multiple']['multiple_reversed'] = array( |
98 | - '#title' => t('Reversed'), |
|
99 | - '#type' => 'checkbox', |
|
100 | - '#default_value' => $options['multiple']['multiple_reversed'], |
|
101 | - '#suffix' => '</div>', |
|
102 | - '#process' => array('views_process_dependency'), |
|
103 | - '#dependency' => array('edit-options-multiple-group' => array(TRUE)), |
|
104 | - '#description' => t('(start from last values)'), |
|
98 | + '#title' => t('Reversed'), |
|
99 | + '#type' => 'checkbox', |
|
100 | + '#default_value' => $options['multiple']['multiple_reversed'], |
|
101 | + '#suffix' => '</div>', |
|
102 | + '#process' => array('views_process_dependency'), |
|
103 | + '#dependency' => array('edit-options-multiple-group' => array(TRUE)), |
|
104 | + '#description' => t('(start from last values)'), |
|
105 | 105 | ); |
106 | - } |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * Determine if this field is click sortable. |
|
110 | - */ |
|
111 | - function click_sortable() { |
|
108 | + /** |
|
109 | + * Determine if this field is click sortable. |
|
110 | + */ |
|
111 | + function click_sortable() { |
|
112 | 112 | $field = $this->content_field; |
113 | 113 | $options = $this->options; |
114 | 114 | |
115 | 115 | // Grouped fields are not click-sortable. |
116 | 116 | return !empty($this->definition['click sortable']) && !$this->defer_query; |
117 | - } |
|
117 | + } |
|
118 | 118 | |
119 | - function query() { |
|
119 | + function query() { |
|
120 | 120 | // If this is not a grouped field, use the generic query(). |
121 | 121 | if (!$this->defer_query) { |
122 | - return parent::query(); |
|
122 | + return parent::query(); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | // Grouped field: do NOT call ensure_my_table, only add additional fields. |
126 | 126 | $this->add_additional_fields(); |
127 | 127 | $this->field_alias = $this->aliases['vid']; |
128 | - } |
|
128 | + } |
|
129 | 129 | |
130 | - function pre_render(&$values) { |
|
130 | + function pre_render(&$values) { |
|
131 | 131 | // If there are no values to render (displaying a summary, or query returned no results), |
132 | 132 | // or if this is not a grouped field, do nothing specific. |
133 | 133 | if (isset($this->view->build_info['summary']) || empty($values) || !$this->defer_query) { |
134 | - return parent::pre_render($values); |
|
134 | + return parent::pre_render($values); |
|
135 | 135 | } |
136 | 136 | |
137 | 137 | $field = $this->content_field; |
@@ -143,82 +143,82 @@ discard block |
||
143 | 143 | $vids = array(); |
144 | 144 | $this->field_values = array(); |
145 | 145 | foreach ($values as $result) { |
146 | - if (isset($result->{$this->field_alias})) { |
|
146 | + if (isset($result->{$this->field_alias})) { |
|
147 | 147 | $vids[] = $result->{$this->field_alias}; |
148 | - } |
|
148 | + } |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | // It may happend that the multiple values field is related to a non |
152 | 152 | // required relation for which no node data related to the field being |
153 | 153 | // processed here is available. |
154 | 154 | if (empty($vids)) { |
155 | - return parent::pre_render($values); |
|
155 | + return parent::pre_render($values); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | // List columns to retrieve. |
159 | 159 | $alias = content_views_tablename($field); |
160 | 160 | // Prefix aliases with '_' to avoid clashing with field columns names. |
161 | 161 | $query_columns = array( |
162 | - 'vid AS _vid', |
|
163 | - "delta as _delta", |
|
164 | - // nid is needed to generate the links for 'link to node' option. |
|
165 | - 'nid AS _nid', |
|
162 | + 'vid AS _vid', |
|
163 | + "delta as _delta", |
|
164 | + // nid is needed to generate the links for 'link to node' option. |
|
165 | + 'nid AS _nid', |
|
166 | 166 | ); |
167 | 167 | // The actual field columns. |
168 | 168 | foreach ($db_info['columns'] as $column => $attributes) { |
169 | - $query_columns[] = "$attributes[column] AS $column"; |
|
169 | + $query_columns[] = "$attributes[column] AS $column"; |
|
170 | 170 | } |
171 | 171 | $query = 'SELECT '. implode(', ', $query_columns) . |
172 | - ' FROM {'. $db_info['table'] ."}". |
|
173 | - " WHERE vid IN (". implode(',', $vids) .')'. |
|
174 | - " ORDER BY _nid ASC, _delta ". ($options['multiple']['multiple_reversed'] ? 'DESC' : 'ASC'); |
|
172 | + ' FROM {'. $db_info['table'] ."}". |
|
173 | + " WHERE vid IN (". implode(',', $vids) .')'. |
|
174 | + " ORDER BY _nid ASC, _delta ". ($options['multiple']['multiple_reversed'] ? 'DESC' : 'ASC'); |
|
175 | 175 | $result = db_query($query); |
176 | 176 | |
177 | 177 | while ($item = db_fetch_array($result)) { |
178 | - // Clean up the $item from vid and delta. We keep nid for now. |
|
179 | - $vid = $item['_vid']; |
|
180 | - unset($item['_vid']); |
|
181 | - $delta = !empty($item['_delta']) ? $item['_delta'] : 0; |
|
182 | - $item['#delta'] = $item['_delta']; |
|
183 | - unset($item['_delta']); |
|
184 | - $this->field_values[$vid][$delta] = $item; |
|
178 | + // Clean up the $item from vid and delta. We keep nid for now. |
|
179 | + $vid = $item['_vid']; |
|
180 | + unset($item['_vid']); |
|
181 | + $delta = !empty($item['_delta']) ? $item['_delta'] : 0; |
|
182 | + $item['#delta'] = $item['_delta']; |
|
183 | + unset($item['_delta']); |
|
184 | + $this->field_values[$vid][$delta] = $item; |
|
185 | 185 | } |
186 | - } |
|
187 | - |
|
188 | - /** |
|
189 | - * Return DIV or SPAN based upon the field's element type. |
|
190 | - * |
|
191 | - * Fields rendered with the 'group multiple' option use <div> markers, |
|
192 | - * and thus shouldn't be wrapped in a <span>. |
|
193 | - */ |
|
194 | - function element_type($none_supported = FALSE, $default_empty = FALSE) { |
|
186 | + } |
|
187 | + |
|
188 | + /** |
|
189 | + * Return DIV or SPAN based upon the field's element type. |
|
190 | + * |
|
191 | + * Fields rendered with the 'group multiple' option use <div> markers, |
|
192 | + * and thus shouldn't be wrapped in a <span>. |
|
193 | + */ |
|
194 | + function element_type($none_supported = FALSE, $default_empty = FALSE) { |
|
195 | 195 | // If this is not a grouped field, use the parent method. |
196 | 196 | if (!$this->defer_query) { |
197 | - return parent::element_type($none_supported, $default_empty); |
|
197 | + return parent::element_type($none_supported, $default_empty); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | // The 'element_type' property denotes Views 3.x ('semantic views' |
201 | 201 | // functionnality). If the property is set, and not set to '' ("default"), |
202 | 202 | // let the generic method handle the output. |
203 | 203 | if (isset($this->options['element_type']) && $this->options['element_type'] !== '') { |
204 | - return parent::element_type($none_supported, $default_empty); |
|
204 | + return parent::element_type($none_supported, $default_empty); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | if ($default_empty) { |
208 | - return ''; |
|
208 | + return ''; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | if (isset($this->definition['element type'])) { |
212 | - return $this->definition['element type']; |
|
212 | + return $this->definition['element type']; |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | return 'div'; |
216 | - } |
|
216 | + } |
|
217 | 217 | |
218 | - function render($values) { |
|
218 | + function render($values) { |
|
219 | 219 | // If this is not a grouped field, use content_handler_field::render(). |
220 | 220 | if (!$this->defer_query) { |
221 | - return parent::render($values); |
|
221 | + return parent::render($values); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | // We're down to a single node here, so we can retrieve the actual field |
@@ -228,95 +228,95 @@ discard block |
||
228 | 228 | // If the field does not appear in the node type, then we have no value |
229 | 229 | // to display, and can just return. |
230 | 230 | if (empty($field)) { |
231 | - return ''; |
|
231 | + return ''; |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | $options = $this->options; |
235 | 235 | |
236 | 236 | $vid = $values->{$this->field_alias}; |
237 | 237 | if (isset($this->field_values[$vid])) { |
238 | - // Gather items, respecting the 'Display n values starting from m' settings. |
|
239 | - $count_skipped = 0; |
|
240 | - $items = array(); |
|
241 | - foreach ($this->field_values[$vid] as $item) { |
|
238 | + // Gather items, respecting the 'Display n values starting from m' settings. |
|
239 | + $count_skipped = 0; |
|
240 | + $items = array(); |
|
241 | + foreach ($this->field_values[$vid] as $item) { |
|
242 | 242 | if (empty($options['multiple']['multiple_from']) || ($count_skipped >= $options['multiple']['multiple_from'])) { |
243 | - if (empty($options['multiple']['multiple_number']) || (count($items) < $options['multiple']['multiple_number'])) { |
|
243 | + if (empty($options['multiple']['multiple_number']) || (count($items) < $options['multiple']['multiple_number'])) { |
|
244 | 244 | // Grab the nid - needed for render_link(). |
245 | 245 | $nid = $item['_nid']; |
246 | 246 | unset($item['_nid']); |
247 | 247 | $items[] = $item; |
248 | - } |
|
249 | - else { |
|
248 | + } |
|
249 | + else { |
|
250 | 250 | break; |
251 | - } |
|
251 | + } |
|
252 | 252 | } |
253 | 253 | $count_skipped++; |
254 | - } |
|
255 | - |
|
256 | - // Build a pseudo-node from the retrieved values. |
|
257 | - $node = drupal_clone($values); |
|
258 | - // content_format and formatters will need a 'type'. |
|
259 | - $node->type = $values->{$this->aliases['type']}; |
|
260 | - $node->nid = $values->{$this->aliases['nid']}; |
|
261 | - $node->vid = $values->{$this->aliases['vid']}; |
|
262 | - |
|
263 | - // Some formatters need to behave differently depending on the build_mode |
|
264 | - // (for instance: preview), so we provide one. |
|
265 | - $node->build_mode = NODE_BUILD_NORMAL; |
|
266 | - |
|
267 | - // Render items. |
|
268 | - $formatter_name = $options['format']; |
|
269 | - if ($items && ($formatter = _content_get_formatter($formatter_name, $field['type']))) { |
|
254 | + } |
|
255 | + |
|
256 | + // Build a pseudo-node from the retrieved values. |
|
257 | + $node = drupal_clone($values); |
|
258 | + // content_format and formatters will need a 'type'. |
|
259 | + $node->type = $values->{$this->aliases['type']}; |
|
260 | + $node->nid = $values->{$this->aliases['nid']}; |
|
261 | + $node->vid = $values->{$this->aliases['vid']}; |
|
262 | + |
|
263 | + // Some formatters need to behave differently depending on the build_mode |
|
264 | + // (for instance: preview), so we provide one. |
|
265 | + $node->build_mode = NODE_BUILD_NORMAL; |
|
266 | + |
|
267 | + // Render items. |
|
268 | + $formatter_name = $options['format']; |
|
269 | + if ($items && ($formatter = _content_get_formatter($formatter_name, $field['type']))) { |
|
270 | 270 | $rendered = array(); |
271 | 271 | if (content_handle('formatter', 'multiple values', $formatter) == CONTENT_HANDLE_CORE) { |
272 | - // Single-value formatter. |
|
273 | - foreach ($items as $item) { |
|
272 | + // Single-value formatter. |
|
273 | + foreach ($items as $item) { |
|
274 | 274 | $output = content_format($field, $item, $formatter_name, $node); |
275 | 275 | if (!empty($output)) { |
276 | - $rendered[] = $this->render_link($output, (object) array('nid' => $nid)); |
|
276 | + $rendered[] = $this->render_link($output, (object) array('nid' => $nid)); |
|
277 | + } |
|
277 | 278 | } |
278 | - } |
|
279 | 279 | } |
280 | 280 | else { |
281 | - // Multiple values formatter. |
|
282 | - $output = content_format($field, $items, $formatter_name, $values); |
|
283 | - if (!empty($output)) { |
|
281 | + // Multiple values formatter. |
|
282 | + $output = content_format($field, $items, $formatter_name, $values); |
|
283 | + if (!empty($output)) { |
|
284 | 284 | $rendered[] = $this->render_link($output, (object) array('nid' => $nid)); |
285 | - } |
|
285 | + } |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | if (count($rendered) > 1) { |
289 | - // TODO: could we use generic field display ? |
|
290 | - return theme('content_view_multiple_field', $rendered, $field, $values); |
|
289 | + // TODO: could we use generic field display ? |
|
290 | + return theme('content_view_multiple_field', $rendered, $field, $values); |
|
291 | 291 | } |
292 | 292 | elseif ($rendered) { |
293 | - return $rendered[0]; |
|
293 | + return $rendered[0]; |
|
294 | + } |
|
294 | 295 | } |
295 | - } |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | return ''; |
299 | - } |
|
299 | + } |
|
300 | 300 | |
301 | - function render_link($data, $values) { |
|
301 | + function render_link($data, $values) { |
|
302 | 302 | if (!$this->defer_query) { |
303 | - return parent::render_link($data, $values); |
|
303 | + return parent::render_link($data, $values); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | if (!empty($this->options['link_to_node']) && $data !== NULL && $data !== '') { |
307 | - if (method_exists('render_as_link', 'views_handler_field')) { |
|
307 | + if (method_exists('render_as_link', 'views_handler_field')) { |
|
308 | 308 | // Views 2.3+ |
309 | 309 | $this->options['alter']['make_link'] = TRUE; |
310 | 310 | $this->options['alter']['path'] = "node/" . $values->{$this->aliases['nid']}; |
311 | - } |
|
312 | - else { |
|
311 | + } |
|
312 | + else { |
|
313 | 313 | // Views up to 2.2 |
314 | 314 | return l($data, "node/" . $values->nid, array('html' => TRUE)); |
315 | - } |
|
315 | + } |
|
316 | 316 | } |
317 | 317 | else { |
318 | - return $data; |
|
318 | + return $data; |
|
319 | + } |
|
319 | 320 | } |
320 | - } |
|
321 | 321 | |
322 | 322 | } |
@@ -168,10 +168,10 @@ discard block |
||
168 | 168 | foreach ($db_info['columns'] as $column => $attributes) { |
169 | 169 | $query_columns[] = "$attributes[column] AS $column"; |
170 | 170 | } |
171 | - $query = 'SELECT '. implode(', ', $query_columns) . |
|
172 | - ' FROM {'. $db_info['table'] ."}". |
|
173 | - " WHERE vid IN (". implode(',', $vids) .')'. |
|
174 | - " ORDER BY _nid ASC, _delta ". ($options['multiple']['multiple_reversed'] ? 'DESC' : 'ASC'); |
|
171 | + $query = 'SELECT '.implode(', ', $query_columns). |
|
172 | + ' FROM {'.$db_info['table']."}". |
|
173 | + " WHERE vid IN (".implode(',', $vids).')'. |
|
174 | + " ORDER BY _nid ASC, _delta ".($options['multiple']['multiple_reversed'] ? 'DESC' : 'ASC'); |
|
175 | 175 | $result = db_query($query); |
176 | 176 | |
177 | 177 | while ($item = db_fetch_array($result)) { |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | foreach ($items as $item) { |
274 | 274 | $output = content_format($field, $item, $formatter_name, $node); |
275 | 275 | if (!empty($output)) { |
276 | - $rendered[] = $this->render_link($output, (object) array('nid' => $nid)); |
|
276 | + $rendered[] = $this->render_link($output, (object)array('nid' => $nid)); |
|
277 | 277 | } |
278 | 278 | } |
279 | 279 | } |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | // Multiple values formatter. |
282 | 282 | $output = content_format($field, $items, $formatter_name, $values); |
283 | 283 | if (!empty($output)) { |
284 | - $rendered[] = $this->render_link($output, (object) array('nid' => $nid)); |
|
284 | + $rendered[] = $this->render_link($output, (object)array('nid' => $nid)); |
|
285 | 285 | } |
286 | 286 | } |
287 | 287 | |
@@ -307,11 +307,11 @@ discard block |
||
307 | 307 | if (method_exists('render_as_link', 'views_handler_field')) { |
308 | 308 | // Views 2.3+ |
309 | 309 | $this->options['alter']['make_link'] = TRUE; |
310 | - $this->options['alter']['path'] = "node/" . $values->{$this->aliases['nid']}; |
|
310 | + $this->options['alter']['path'] = "node/".$values->{$this->aliases['nid']}; |
|
311 | 311 | } |
312 | 312 | else { |
313 | 313 | // Views up to 2.2 |
314 | - return l($data, "node/" . $values->nid, array('html' => TRUE)); |
|
314 | + return l($data, "node/".$values->nid, array('html' => TRUE)); |
|
315 | 315 | } |
316 | 316 | } |
317 | 317 | else { |
@@ -29,8 +29,7 @@ discard block |
||
29 | 29 | ); |
30 | 30 | if ($view->base_table == 'node_revisions') { |
31 | 31 | $this->additional_fields['vid'] = array('table' => 'node_revisions', 'field' => 'vid'); |
32 | - } |
|
33 | - else { |
|
32 | + } else { |
|
34 | 33 | $this->additional_fields['vid'] = array('table' => 'node', 'field' => 'vid'); |
35 | 34 | } |
36 | 35 | } |
@@ -245,8 +244,7 @@ discard block |
||
245 | 244 | $nid = $item['_nid']; |
246 | 245 | unset($item['_nid']); |
247 | 246 | $items[] = $item; |
248 | - } |
|
249 | - else { |
|
247 | + } else { |
|
250 | 248 | break; |
251 | 249 | } |
252 | 250 | } |
@@ -276,8 +274,7 @@ discard block |
||
276 | 274 | $rendered[] = $this->render_link($output, (object) array('nid' => $nid)); |
277 | 275 | } |
278 | 276 | } |
279 | - } |
|
280 | - else { |
|
277 | + } else { |
|
281 | 278 | // Multiple values formatter. |
282 | 279 | $output = content_format($field, $items, $formatter_name, $values); |
283 | 280 | if (!empty($output)) { |
@@ -288,8 +285,7 @@ discard block |
||
288 | 285 | if (count($rendered) > 1) { |
289 | 286 | // TODO: could we use generic field display ? |
290 | 287 | return theme('content_view_multiple_field', $rendered, $field, $values); |
291 | - } |
|
292 | - elseif ($rendered) { |
|
288 | + } elseif ($rendered) { |
|
293 | 289 | return $rendered[0]; |
294 | 290 | } |
295 | 291 | } |
@@ -308,13 +304,11 @@ discard block |
||
308 | 304 | // Views 2.3+ |
309 | 305 | $this->options['alter']['make_link'] = TRUE; |
310 | 306 | $this->options['alter']['path'] = "node/" . $values->{$this->aliases['nid']}; |
311 | - } |
|
312 | - else { |
|
307 | + } else { |
|
313 | 308 | // Views up to 2.2 |
314 | 309 | return l($data, "node/" . $values->nid, array('html' => TRUE)); |
315 | 310 | } |
316 | - } |
|
317 | - else { |
|
311 | + } else { |
|
318 | 312 | return $data; |
319 | 313 | } |
320 | 314 | } |
@@ -41,10 +41,10 @@ discard block |
||
41 | 41 | |
42 | 42 | $options['multiple'] = array( |
43 | 43 | 'contains' => array( |
44 | - 'group' => array('default' => TRUE), |
|
44 | + 'group' => array('default' => true), |
|
45 | 45 | 'multiple_number' => array('default' => ''), |
46 | 46 | 'multiple_from' => array('default' => ''), |
47 | - 'multiple_reversed' => array('default' => FALSE), |
|
47 | + 'multiple_reversed' => array('default' => false), |
|
48 | 48 | ), |
49 | 49 | ); |
50 | 50 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | '#default_value' => $options['multiple']['multiple_number'], |
82 | 82 | '#prefix' => '<div class="container-inline">', |
83 | 83 | '#process' => array('views_process_dependency'), |
84 | - '#dependency' => array('edit-options-multiple-group' => array(TRUE)), |
|
84 | + '#dependency' => array('edit-options-multiple-group' => array(true)), |
|
85 | 85 | ); |
86 | 86 | list($prefix, $suffix) = explode('@count', t('starting from @count')); |
87 | 87 | $form['multiple']['multiple_from'] = array( |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | '#field_suffix' => $suffix, |
92 | 92 | '#default_value' => $options['multiple']['multiple_from'], |
93 | 93 | '#process' => array('views_process_dependency'), |
94 | - '#dependency' => array('edit-options-multiple-group' => array(TRUE)), |
|
94 | + '#dependency' => array('edit-options-multiple-group' => array(true)), |
|
95 | 95 | '#description' => t('(first item is 0)'), |
96 | 96 | ); |
97 | 97 | $form['multiple']['multiple_reversed'] = array( |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | '#default_value' => $options['multiple']['multiple_reversed'], |
101 | 101 | '#suffix' => '</div>', |
102 | 102 | '#process' => array('views_process_dependency'), |
103 | - '#dependency' => array('edit-options-multiple-group' => array(TRUE)), |
|
103 | + '#dependency' => array('edit-options-multiple-group' => array(true)), |
|
104 | 104 | '#description' => t('(start from last values)'), |
105 | 105 | ); |
106 | 106 | } |
@@ -191,7 +191,7 @@ discard block |
||
191 | 191 | * Fields rendered with the 'group multiple' option use <div> markers, |
192 | 192 | * and thus shouldn't be wrapped in a <span>. |
193 | 193 | */ |
194 | - function element_type($none_supported = FALSE, $default_empty = FALSE) { |
|
194 | + function element_type($none_supported = false, $default_empty = false) { |
|
195 | 195 | // If this is not a grouped field, use the parent method. |
196 | 196 | if (!$this->defer_query) { |
197 | 197 | return parent::element_type($none_supported, $default_empty); |
@@ -303,15 +303,15 @@ discard block |
||
303 | 303 | return parent::render_link($data, $values); |
304 | 304 | } |
305 | 305 | |
306 | - if (!empty($this->options['link_to_node']) && $data !== NULL && $data !== '') { |
|
306 | + if (!empty($this->options['link_to_node']) && $data !== null && $data !== '') { |
|
307 | 307 | if (method_exists('render_as_link', 'views_handler_field')) { |
308 | 308 | // Views 2.3+ |
309 | - $this->options['alter']['make_link'] = TRUE; |
|
309 | + $this->options['alter']['make_link'] = true; |
|
310 | 310 | $this->options['alter']['path'] = "node/" . $values->{$this->aliases['nid']}; |
311 | 311 | } |
312 | 312 | else { |
313 | 313 | // Views up to 2.2 |
314 | - return l($data, "node/" . $values->nid, array('html' => TRUE)); |
|
314 | + return l($data, "node/" . $values->nid, array('html' => true)); |
|
315 | 315 | } |
316 | 316 | } |
317 | 317 | else { |
@@ -6,38 +6,38 @@ |
||
6 | 6 | * Handler for 'content_simple' display. |
7 | 7 | */ |
8 | 8 | class content_plugin_display_simple extends views_plugin_display { |
9 | - function execute() { |
|
9 | + function execute() { |
|
10 | 10 | return $this->view->render($this->display->id); |
11 | - } |
|
11 | + } |
|
12 | 12 | |
13 | - function render() { |
|
13 | + function render() { |
|
14 | 14 | return !empty($this->view->result) || !empty($this->view->style_plugin->definition['even empty']) ? $this->view->style_plugin->render($this->view->result) : ''; |
15 | - } |
|
15 | + } |
|
16 | 16 | |
17 | - function uses_exposed() { |
|
17 | + function uses_exposed() { |
|
18 | 18 | return FALSE; |
19 | - } |
|
19 | + } |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | class content_plugin_display_references extends content_plugin_display_simple { |
23 | - function query() { |
|
23 | + function query() { |
|
24 | 24 | $options = $this->get_option('content_options'); |
25 | 25 | |
26 | 26 | if ($options['string'] !== '') { |
27 | - $like = $GLOBALS["db_type"] == 'pgsql' ? "ILIKE" : "LIKE"; |
|
28 | - $match_clauses = array( |
|
27 | + $like = $GLOBALS["db_type"] == 'pgsql' ? "ILIKE" : "LIKE"; |
|
28 | + $match_clauses = array( |
|
29 | 29 | 'contains' => "$like '%%%s%%'", |
30 | 30 | 'equals' => "= '%s'", |
31 | 31 | 'starts_with' => "$like '%s%%'", |
32 | - ); |
|
33 | - $clause = isset($match_clauses[$options['match']]) ? $match_clauses[$options['match']] : $match_clauses['contains']; |
|
34 | - $alias = $this->view->query->ensure_table($options['table']); |
|
35 | - $this->view->query->add_where(NULL, "$alias.$options[field_string] $clause", $options['string']); |
|
32 | + ); |
|
33 | + $clause = isset($match_clauses[$options['match']]) ? $match_clauses[$options['match']] : $match_clauses['contains']; |
|
34 | + $alias = $this->view->query->ensure_table($options['table']); |
|
35 | + $this->view->query->add_where(NULL, "$alias.$options[field_string] $clause", $options['string']); |
|
36 | 36 | } |
37 | 37 | elseif ($options['ids']) { |
38 | - $alias = $this->view->query->ensure_table($options['table']); |
|
39 | - $this->view->query->add_where(NULL, "$alias.$options[field_id] IN (" . db_placeholders($options['ids']) . ')', $options['ids']); |
|
38 | + $alias = $this->view->query->ensure_table($options['table']); |
|
39 | + $this->view->query->add_where(NULL, "$alias.$options[field_id] IN (" . db_placeholders($options['ids']) . ')', $options['ids']); |
|
40 | + } |
|
40 | 41 | } |
41 | - } |
|
42 | 42 | } |
43 | 43 |
@@ -36,7 +36,7 @@ |
||
36 | 36 | } |
37 | 37 | elseif ($options['ids']) { |
38 | 38 | $alias = $this->view->query->ensure_table($options['table']); |
39 | - $this->view->query->add_where(NULL, "$alias.$options[field_id] IN (" . db_placeholders($options['ids']) . ')', $options['ids']); |
|
39 | + $this->view->query->add_where(NULL, "$alias.$options[field_id] IN (".db_placeholders($options['ids']).')', $options['ids']); |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | } |
@@ -33,8 +33,7 @@ |
||
33 | 33 | $clause = isset($match_clauses[$options['match']]) ? $match_clauses[$options['match']] : $match_clauses['contains']; |
34 | 34 | $alias = $this->view->query->ensure_table($options['table']); |
35 | 35 | $this->view->query->add_where(NULL, "$alias.$options[field_string] $clause", $options['string']); |
36 | - } |
|
37 | - elseif ($options['ids']) { |
|
36 | + } elseif ($options['ids']) { |
|
38 | 37 | $alias = $this->view->query->ensure_table($options['table']); |
39 | 38 | $this->view->query->add_where(NULL, "$alias.$options[field_id] IN (" . db_placeholders($options['ids']) . ')', $options['ids']); |
40 | 39 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | } |
16 | 16 | |
17 | 17 | function uses_exposed() { |
18 | - return FALSE; |
|
18 | + return false; |
|
19 | 19 | } |
20 | 20 | } |
21 | 21 | |
@@ -32,11 +32,11 @@ discard block |
||
32 | 32 | ); |
33 | 33 | $clause = isset($match_clauses[$options['match']]) ? $match_clauses[$options['match']] : $match_clauses['contains']; |
34 | 34 | $alias = $this->view->query->ensure_table($options['table']); |
35 | - $this->view->query->add_where(NULL, "$alias.$options[field_string] $clause", $options['string']); |
|
35 | + $this->view->query->add_where(null, "$alias.$options[field_string] $clause", $options['string']); |
|
36 | 36 | } |
37 | 37 | elseif ($options['ids']) { |
38 | 38 | $alias = $this->view->query->ensure_table($options['table']); |
39 | - $this->view->query->add_where(NULL, "$alias.$options[field_id] IN (" . db_placeholders($options['ids']) . ')', $options['ids']); |
|
39 | + $this->view->query->add_where(null, "$alias.$options[field_id] IN (" . db_placeholders($options['ids']) . ')', $options['ids']); |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | } |
@@ -11,27 +11,27 @@ discard block |
||
11 | 11 | * content_handler_field_multiple. |
12 | 12 | */ |
13 | 13 | class content_handler_field extends views_handler_field_node { |
14 | - var $content_field; |
|
14 | + var $content_field; |
|
15 | 15 | |
16 | - function construct() { |
|
16 | + function construct() { |
|
17 | 17 | parent::construct(); |
18 | 18 | $this->content_field = content_fields($this->definition['content_field_name']); |
19 | - } |
|
19 | + } |
|
20 | 20 | |
21 | - function init(&$view, $options) { |
|
21 | + function init(&$view, $options) { |
|
22 | 22 | $field = $this->content_field; |
23 | 23 | parent::init($view, $options); |
24 | 24 | if ($field['multiple']) { |
25 | - $this->additional_fields['delta'] = 'delta'; |
|
25 | + $this->additional_fields['delta'] = 'delta'; |
|
26 | 26 | } |
27 | 27 | // Make sure we grab enough information to build a pseudo-node with enough |
28 | 28 | // credentials at render-time. |
29 | 29 | $this->additional_fields['type'] = array('table' => 'node', 'field' => 'type'); |
30 | 30 | $this->additional_fields['nid'] = array('table' => 'node', 'field' => 'nid'); |
31 | 31 | $this->additional_fields['vid'] = array('table' => 'node', 'field' => 'vid'); |
32 | - } |
|
32 | + } |
|
33 | 33 | |
34 | - function option_definition() { |
|
34 | + function option_definition() { |
|
35 | 35 | $options = parent::option_definition(); |
36 | 36 | $field = $this->content_field; |
37 | 37 | |
@@ -41,12 +41,12 @@ discard block |
||
41 | 41 | $options['format'] = array('default' => 'default'); |
42 | 42 | |
43 | 43 | return $options; |
44 | - } |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Provide formatter option. |
|
48 | - */ |
|
49 | - function options_form(&$form, &$form_state) { |
|
46 | + /** |
|
47 | + * Provide formatter option. |
|
48 | + */ |
|
49 | + function options_form(&$form, &$form_state) { |
|
50 | 50 | parent::options_form($form, $form_state); |
51 | 51 | // TODO: do we want the 'link to node' checkbox ? |
52 | 52 | // That's usually formatters business... |
@@ -55,102 +55,102 @@ discard block |
||
55 | 55 | $options = $this->options; |
56 | 56 | |
57 | 57 | $form['label_type'] = array( |
58 | - '#title' => t('Label'), |
|
59 | - '#type' => 'radios', |
|
60 | - '#options' => array( |
|
58 | + '#title' => t('Label'), |
|
59 | + '#type' => 'radios', |
|
60 | + '#options' => array( |
|
61 | 61 | 'none' => t('None'), |
62 | 62 | 'widget' => t('Widget label (@label)', array('@label' => $field['widget']['label'])), |
63 | 63 | 'custom' => t('Custom'), |
64 | - ), |
|
65 | - '#default_value' => $options['label_type'], |
|
66 | - '#weight' => 2, |
|
64 | + ), |
|
65 | + '#default_value' => $options['label_type'], |
|
66 | + '#weight' => 2, |
|
67 | 67 | ); |
68 | 68 | $form['label'] = array( |
69 | - '#title' => t('Custom label'), |
|
70 | - '#type' => 'textfield', |
|
71 | - '#default_value' => $options['label'], |
|
72 | - '#process' => array('views_process_dependency'), |
|
73 | - '#dependency' => array('radio:options[label_type]' => array('custom')), |
|
74 | - '#weight' => 3, |
|
75 | - ); |
|
69 | + '#title' => t('Custom label'), |
|
70 | + '#type' => 'textfield', |
|
71 | + '#default_value' => $options['label'], |
|
72 | + '#process' => array('views_process_dependency'), |
|
73 | + '#dependency' => array('radio:options[label_type]' => array('custom')), |
|
74 | + '#weight' => 3, |
|
75 | + ); |
|
76 | 76 | |
77 | 77 | $field_types = _content_field_types(); |
78 | 78 | $formatters = array(); |
79 | 79 | if (is_array($field_types[$field['type']]['formatters'])) { |
80 | - foreach ($field_types[$field['type']]['formatters'] as $name => $info) { |
|
80 | + foreach ($field_types[$field['type']]['formatters'] as $name => $info) { |
|
81 | 81 | $formatters[$name] = $info['label']; |
82 | - } |
|
82 | + } |
|
83 | 83 | } |
84 | 84 | $form['format'] = array( |
85 | - '#title' => t('Format'), |
|
86 | - '#type' => 'select', |
|
87 | - '#options' => $formatters, |
|
88 | - '#required' => TRUE, |
|
89 | - '#default_value' => $options['format'], |
|
90 | - '#weight' => 4, |
|
85 | + '#title' => t('Format'), |
|
86 | + '#type' => 'select', |
|
87 | + '#options' => $formatters, |
|
88 | + '#required' => TRUE, |
|
89 | + '#default_value' => $options['format'], |
|
90 | + '#weight' => 4, |
|
91 | 91 | ); |
92 | - } |
|
93 | - |
|
94 | - |
|
95 | - /** |
|
96 | - * Make sure some value is stored as a label. |
|
97 | - * |
|
98 | - * Don't use t(), since Views' views_handler_field already has |
|
99 | - * $this->options['label'] marked as a translatable field. |
|
100 | - * |
|
101 | - * @see http://drupal.org/node/285470 |
|
102 | - */ |
|
103 | - function options_submit($form, &$form_state) { |
|
92 | + } |
|
93 | + |
|
94 | + |
|
95 | + /** |
|
96 | + * Make sure some value is stored as a label. |
|
97 | + * |
|
98 | + * Don't use t(), since Views' views_handler_field already has |
|
99 | + * $this->options['label'] marked as a translatable field. |
|
100 | + * |
|
101 | + * @see http://drupal.org/node/285470 |
|
102 | + */ |
|
103 | + function options_submit($form, &$form_state) { |
|
104 | 104 | switch ($form_state['values']['options']['label_type']) { |
105 | - case 'none': |
|
105 | + case 'none': |
|
106 | 106 | $form_state['values']['options']['label'] = ''; |
107 | 107 | break; |
108 | - case 'widget': |
|
108 | + case 'widget': |
|
109 | 109 | $form_state['values']['options']['label'] = $this->content_field['widget']['label']; |
110 | 110 | break; |
111 | 111 | } |
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * @TODO |
|
116 | - * Now that we save the label in the submit process above we could |
|
117 | - * get rid of this function. Leave it here for now to be sure the |
|
118 | - * label works for fields that haven't been updated since this |
|
119 | - * change was made, since $this->options['label'] will be missing a |
|
120 | - * value until it is updated in the view. |
|
121 | - * |
|
122 | - * Don't use t(), since Views' views_handler_field already has |
|
123 | - * $this->options['label'] marked as a translatable field. |
|
124 | - */ |
|
125 | - function label() { |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * @TODO |
|
116 | + * Now that we save the label in the submit process above we could |
|
117 | + * get rid of this function. Leave it here for now to be sure the |
|
118 | + * label works for fields that haven't been updated since this |
|
119 | + * change was made, since $this->options['label'] will be missing a |
|
120 | + * value until it is updated in the view. |
|
121 | + * |
|
122 | + * Don't use t(), since Views' views_handler_field already has |
|
123 | + * $this->options['label'] marked as a translatable field. |
|
124 | + */ |
|
125 | + function label() { |
|
126 | 126 | $field = $this->content_field; |
127 | 127 | switch ($this->options['label_type']) { |
128 | - case 'none': |
|
128 | + case 'none': |
|
129 | 129 | return ''; |
130 | - case 'widget': |
|
130 | + case 'widget': |
|
131 | 131 | return $field['widget']['label']; |
132 | - default: |
|
132 | + default: |
|
133 | 133 | return $this->options['label']; |
134 | 134 | } |
135 | - } |
|
135 | + } |
|
136 | 136 | |
137 | - /** |
|
138 | - * Return DIV or SPAN based upon the field's element type. |
|
139 | - */ |
|
140 | - function element_type($none_supported = FALSE, $default_empty = FALSE) { |
|
137 | + /** |
|
138 | + * Return DIV or SPAN based upon the field's element type. |
|
139 | + */ |
|
140 | + function element_type($none_supported = FALSE, $default_empty = FALSE) { |
|
141 | 141 | // The 'element_type' property denotes Views 3.x ('semantic views' |
142 | 142 | // functionnality). If the property is set, and not set to '' ("default"), |
143 | 143 | // let the generic method handle the output. |
144 | 144 | if (isset($this->options['element_type']) && $this->options['element_type'] !== '') { |
145 | - return parent::element_type($none_supported, $default_empty); |
|
145 | + return parent::element_type($none_supported, $default_empty); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | if ($default_empty) { |
149 | - return ''; |
|
149 | + return ''; |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | if (isset($this->definition['element type'])) { |
153 | - return $this->definition['element type']; |
|
153 | + return $this->definition['element type']; |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | // TODO Figure out exactly when to return a div or a <span>. Any field |
@@ -159,28 +159,28 @@ discard block |
||
159 | 159 | // Earl says we need to be sure that other fields we don't know |
160 | 160 | // about won't end up wrapping a span around a block-level element. |
161 | 161 | if ($this->content_field['widget']['type'] == 'text_textarea') { |
162 | - return 'div'; |
|
162 | + return 'div'; |
|
163 | 163 | } |
164 | 164 | else { |
165 | - return 'span'; |
|
165 | + return 'span'; |
|
166 | + } |
|
166 | 167 | } |
167 | - } |
|
168 | 168 | |
169 | - function options_validate($form, &$form_state) { } |
|
169 | + function options_validate($form, &$form_state) { } |
|
170 | 170 | |
171 | - /** |
|
172 | - * Provide text for the administrative summary |
|
173 | - */ |
|
174 | - function admin_summary() { |
|
171 | + /** |
|
172 | + * Provide text for the administrative summary |
|
173 | + */ |
|
174 | + function admin_summary() { |
|
175 | 175 | // Display the formatter name. |
176 | 176 | $field = $this->content_field; |
177 | 177 | $field_types = _content_field_types(); |
178 | 178 | if (isset($field_types[$field['type']]['formatters'][$this->options['format']])) { |
179 | - return t($field_types[$field['type']]['formatters'][$this->options['format']]['label']); |
|
179 | + return t($field_types[$field['type']]['formatters'][$this->options['format']]['label']); |
|
180 | + } |
|
180 | 181 | } |
181 | - } |
|
182 | 182 | |
183 | - function render($values) { |
|
183 | + function render($values) { |
|
184 | 184 | // We're down to a single node here, so we can retrieve the actual field |
185 | 185 | // definition for the node type being considered. |
186 | 186 | $field = content_fields($this->content_field['field_name'], $values->{$this->aliases['type']}); |
@@ -188,7 +188,7 @@ discard block |
||
188 | 188 | // If the field does not appear in the node type, then we have no value |
189 | 189 | // to display, and can just return. |
190 | 190 | if (empty($field)) { |
191 | - return ''; |
|
191 | + return ''; |
|
192 | 192 | } |
193 | 193 | |
194 | 194 | $options = $this->options; |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | |
206 | 206 | $item = array(); |
207 | 207 | foreach ($db_info['columns'] as $column => $attributes) { |
208 | - $item[$column] = $values->{$this->aliases[$attributes['column']]}; |
|
208 | + $item[$column] = $values->{$this->aliases[$attributes['column']]}; |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | $item['#delta'] = $field['multiple'] ? $values->{$this->aliases['delta']} : 0; |
@@ -213,17 +213,17 @@ discard block |
||
213 | 213 | // Render items. |
214 | 214 | $formatter_name = $options['format']; |
215 | 215 | if ($formatter = _content_get_formatter($formatter_name, $field['type'])) { |
216 | - if (content_handle('formatter', 'multiple values', $formatter) == CONTENT_HANDLE_CORE) { |
|
216 | + if (content_handle('formatter', 'multiple values', $formatter) == CONTENT_HANDLE_CORE) { |
|
217 | 217 | // Single-value formatter. |
218 | 218 | $output = content_format($field, $item, $formatter_name, $node); |
219 | - } |
|
220 | - else { |
|
219 | + } |
|
220 | + else { |
|
221 | 221 | // Multiple values formatter - we actually have only one value to display. |
222 | 222 | $output = content_format($field, array($item), $formatter_name, $node); |
223 | - } |
|
224 | - return $this->render_link($output, $values); |
|
223 | + } |
|
224 | + return $this->render_link($output, $values); |
|
225 | 225 | } |
226 | 226 | return ''; |
227 | - } |
|
227 | + } |
|
228 | 228 | |
229 | 229 | } |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | */ |
103 | 103 | function options_submit($form, &$form_state) { |
104 | 104 | switch ($form_state['values']['options']['label_type']) { |
105 | - case 'none': |
|
106 | - $form_state['values']['options']['label'] = ''; |
|
107 | - break; |
|
108 | - case 'widget': |
|
109 | - $form_state['values']['options']['label'] = $this->content_field['widget']['label']; |
|
110 | - break; |
|
105 | + case 'none': |
|
106 | + $form_state['values']['options']['label'] = ''; |
|
107 | + break; |
|
108 | + case 'widget': |
|
109 | + $form_state['values']['options']['label'] = $this->content_field['widget']['label']; |
|
110 | + break; |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | |
@@ -125,12 +125,12 @@ discard block |
||
125 | 125 | function label() { |
126 | 126 | $field = $this->content_field; |
127 | 127 | switch ($this->options['label_type']) { |
128 | - case 'none': |
|
129 | - return ''; |
|
130 | - case 'widget': |
|
131 | - return $field['widget']['label']; |
|
132 | - default: |
|
133 | - return $this->options['label']; |
|
128 | + case 'none': |
|
129 | + return ''; |
|
130 | + case 'widget': |
|
131 | + return $field['widget']['label']; |
|
132 | + default: |
|
133 | + return $this->options['label']; |
|
134 | 134 | } |
135 | 135 | } |
136 | 136 |
@@ -208,7 +208,7 @@ |
||
208 | 208 | $item[$column] = $values->{$this->aliases[$attributes['column']]}; |
209 | 209 | } |
210 | 210 | |
211 | - $item['#delta'] = $field['multiple'] ? $values->{$this->aliases['delta']} : 0; |
|
211 | + $item['#delta'] = $field['multiple'] ? $values->{$this->aliases['delta']} : 0; |
|
212 | 212 | |
213 | 213 | // Render items. |
214 | 214 | $formatter_name = $options['format']; |
@@ -160,8 +160,7 @@ discard block |
||
160 | 160 | // about won't end up wrapping a span around a block-level element. |
161 | 161 | if ($this->content_field['widget']['type'] == 'text_textarea') { |
162 | 162 | return 'div'; |
163 | - } |
|
164 | - else { |
|
163 | + } else { |
|
165 | 164 | return 'span'; |
166 | 165 | } |
167 | 166 | } |
@@ -216,8 +215,7 @@ discard block |
||
216 | 215 | if (content_handle('formatter', 'multiple values', $formatter) == CONTENT_HANDLE_CORE) { |
217 | 216 | // Single-value formatter. |
218 | 217 | $output = content_format($field, $item, $formatter_name, $node); |
219 | - } |
|
220 | - else { |
|
218 | + } else { |
|
221 | 219 | // Multiple values formatter - we actually have only one value to display. |
222 | 220 | $output = content_format($field, array($item), $formatter_name, $node); |
223 | 221 | } |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | $field = $this->content_field; |
37 | 37 | |
38 | 38 | // Override views_handler_field_node's default label |
39 | - $options['label'] = array('default' => '', 'translatable' => TRUE); |
|
39 | + $options['label'] = array('default' => '', 'translatable' => true); |
|
40 | 40 | $options['label_type'] = array('default' => 'widget'); |
41 | 41 | $options['format'] = array('default' => 'default'); |
42 | 42 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | '#title' => t('Format'), |
86 | 86 | '#type' => 'select', |
87 | 87 | '#options' => $formatters, |
88 | - '#required' => TRUE, |
|
88 | + '#required' => true, |
|
89 | 89 | '#default_value' => $options['format'], |
90 | 90 | '#weight' => 4, |
91 | 91 | ); |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | /** |
138 | 138 | * Return DIV or SPAN based upon the field's element type. |
139 | 139 | */ |
140 | - function element_type($none_supported = FALSE, $default_empty = FALSE) { |
|
140 | + function element_type($none_supported = false, $default_empty = false) { |
|
141 | 141 | // The 'element_type' property denotes Views 3.x ('semantic views' |
142 | 142 | // functionnality). If the property is set, and not set to '' ("default"), |
143 | 143 | // let the generic method handle the output. |