summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Wehner2010-11-05 07:20:54 (GMT)
committerDaniel Wehner2010-11-05 07:20:54 (GMT)
commit3981ce08ee3188ba3c49976b0cc4326a38bfe083 (patch)
tree4bd9b92d581cfff0bfabe437b78f19e9d50ac17c
parent0e5b4f822e754fc004f2d2ad6fc37302733a8257 (diff)
#667950 by merlinofchaos, bojanz and dereine: Revert the states patch and use ctools dependency instead.
-rw-r--r--CHANGELOG.txt1
-rw-r--r--handlers/views_handler_argument.inc37
-rw-r--r--handlers/views_handler_argument_string.inc7
-rw-r--r--handlers/views_handler_field.inc111
-rw-r--r--handlers/views_handler_field_counter.inc1
-rw-r--r--handlers/views_handler_field_custom.inc2
-rw-r--r--handlers/views_handler_field_date.inc6
-rw-r--r--handlers/views_handler_field_math.inc2
-rw-r--r--handlers/views_handler_field_numeric.inc21
-rw-r--r--handlers/views_handler_field_prerender_list.inc7
-rw-r--r--handlers/views_handler_filter.inc7
-rw-r--r--handlers/views_handler_filter_in_operator.inc1
-rw-r--r--handlers/views_handler_filter_numeric.inc9
-rw-r--r--handlers/views_handler_filter_string.inc1
-rw-r--r--help/api-upgrading.html11
-rw-r--r--includes/admin.inc8
-rw-r--r--includes/ajax.inc5
-rw-r--r--includes/handlers.inc2
-rw-r--r--includes/plugins.inc3
-rw-r--r--modules/taxonomy/views_handler_argument_term_node_tid_depth.inc7
-rw-r--r--modules/taxonomy/views_handler_field_term_node_tid.inc10
-rw-r--r--modules/taxonomy/views_handler_filter_term_node_tid.inc7
-rw-r--r--modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc14
-rw-r--r--modules/user/views_handler_field_user_name.inc7
-rw-r--r--modules/user/views_plugin_argument_validate_user.inc8
-rw-r--r--plugins/views_plugin_argument_default_php.inc1
-rw-r--r--plugins/views_plugin_display.inc2
-rw-r--r--plugins/views_plugin_display_feed.inc7
-rw-r--r--plugins/views_plugin_display_page.inc48
-rw-r--r--plugins/views_plugin_exposed_form.inc7
-rw-r--r--plugins/views_plugin_pager_full.inc21
-rw-r--r--plugins/views_plugin_style_rss.inc7
-rw-r--r--plugins/views_plugin_style_summary.inc7
-rw-r--r--plugins/views_plugin_style_table.inc16
-rw-r--r--views.module1
35 files changed, 167 insertions, 245 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 44b5d7c..c104854 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -422,6 +422,7 @@ Views 3.x-7.x-dev
o #954030 by alweb: Fix title query in views_handler_argument_term_node_tid.
o #954784 by tekante: views_join class produces a SQL error when an array is in definition['extra']['value'].
o #962756 by bojanz: Field delta shows the placeholder instead of the field name.
+ o #667950 by merlinofchaos, bojanz and dereine: Revert the states patch and use ctools dependency instead.
Views 6.x-3.x-dev
o #396380 by merlinofchaos, dereine and dagmar: Initial support for GROUP BY queries!!!!!!!!!!!!
diff --git a/handlers/views_handler_argument.inc b/handlers/views_handler_argument.inc
index 5bb11ed..40a3761 100644
--- a/handlers/views_handler_argument.inc
+++ b/handlers/views_handler_argument.inc
@@ -225,13 +225,15 @@ class views_handler_argument extends views_handler {
if ($plugin) {
if ($plugin->access() || $this->options['validate_type'] == $id) {
$form['argument_validate'][$id] = array(
+ '#prefix' => '<div id="edit-options-validate-options-' . $id . '-wrapper">',
+ '#suffix' => '</div>',
'#type' => 'item',
'#input' => TRUE, // trick it into checking input to make #process run
- '#states' => array(
- 'visible' => array(
- ':input[name="options[validate_type]"]' => array('value' => $id),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array(
+ 'edit-options-validate-type' => array($id)
),
+ '#id' => 'edit-options-validate-options-' . $id,
);
$plugin->options_form($form['argument_validate'][$id], $form_state);
$validate_types[$id] = $info['title'];
@@ -385,12 +387,9 @@ class views_handler_argument extends views_handler {
$form['default_options_div_prefix'] = array(
'#type' => 'hidden',
'#id' => 'views-default-options',
- '#prefix' => '<div><fieldset id="views-default-options"><legend>' . t('Provide default argument options') . '</legend>',
- '#states' => array(
- 'visible' => array(
- ':input[name="options[default_action]"]' => array('value' => 'default'),
- ),
- ),
+ '#prefix' => '<div id="views-default-options-wrapper"><fieldset id="views-default-options"><legend>' . t('Provide default argument options') . '</legend>',
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array('radio:options[default_action]' => array('default')),
);
$form['default_argument_type'] = array(
@@ -400,11 +399,6 @@ class views_handler_argument extends views_handler {
'#id' => 'edit-options-default-argument-type',
'#title' => t('Default argument type'),
'#default_value' => $this->options['default_argument_type'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[default_action]"]' => array('value' => 'default'),
- ),
- ),
);
foreach ($plugins as $id => $info) {
@@ -415,14 +409,17 @@ class views_handler_argument extends views_handler {
if ($plugin) {
if ($plugin->access() || $this->options['default_argument_type'] == $id) {
$form['argument_default'][$id] = array(
+ '#prefix' => '<div id="edit-options-argument-default-options-' . $id . '-wrapper">',
+ '#suffix' => '</div>',
+ '#id' => 'edit-options-argument-default-options-' . $id,
'#type' => 'item',
'#input' => TRUE, // trick it into checking input to make #process run
- '#states' => array(
- 'visible' => array(
- ':input[name="options[default_action]"]' => array('value' => 'default'),
- ':input[name="options[default_argument_type]"]' => array('value' => $id),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array(
+ 'radio:options[default_action]' => array('default'),
+ 'radio:options[default_argument_type]' => array($id)
),
+ '#dependency_count' => 2,
);
$options[$id] = $info['title'];
$plugin->options_form($form['argument_default'][$id], $form_state);
diff --git a/handlers/views_handler_argument_string.inc b/handlers/views_handler_argument_string.inc
index c89907c..07ac721 100644
--- a/handlers/views_handler_argument_string.inc
+++ b/handlers/views_handler_argument_string.inc
@@ -51,11 +51,8 @@ class views_handler_argument_string extends views_handler_argument {
'#title' => t('Character limit'),
'#description' => t('How many characters of the argument to filter against. If set to 1, all fields starting with the letter in the argument would be matched.'),
'#default_value' => $this->options['limit'],
- '#states' => array(
- 'invisible' => array(
- 'input[name="options[glossary]"]' => array('checked' => FALSE),
- ),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array('edit-options-glossary' => array(TRUE)),
);
$form['case'] = array(
diff --git a/handlers/views_handler_field.inc b/handlers/views_handler_field.inc
index cff1f70..25a4cfc 100644
--- a/handlers/views_handler_field.inc
+++ b/handlers/views_handler_field.inc
@@ -216,10 +216,9 @@ class views_handler_field extends views_handler {
'#type' => 'textarea',
'#default_value' => $this->options['alter']['text'],
'#description' => t('The text to display for this field. You may include HTML. You may enter data from this view as per the "Replacement patterns" below.'),
- '#states' => array(
- 'visible' => array(
- 'input[name="options[alter][alter_text]"]' => array('checked' => TRUE),
- )
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array(
+ 'edit-options-alter-alter-text' => array(1)
),
);
@@ -234,10 +233,9 @@ class views_handler_field extends views_handler {
'#type' => 'textfield',
'#default_value' => $this->options['alter']['path'],
'#description' => t('The Drupal path or absolute URL for this link. You may enter data from this view as per the "Replacement patterns" below.'),
- '#states' => array(
- 'visible' => array(
- 'input[name="options[alter][make_link]"]' => array('checked' => TRUE),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array(
+ 'edit-options-alter-make-link' => array(1)
),
'#maxlength' => 255,
);
@@ -245,11 +243,10 @@ class views_handler_field extends views_handler {
'#type' => 'checkbox',
'#title' => t('Use absolute path'),
'#default_value' => $this->options['alter']['absolute'],
- '#states' => array(
- 'visible' => array(
- 'input[name="options[alter][make_link]"]' => array('checked' => TRUE),
- ),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array(
+ 'edit-options-alter-make-link' => array(1)
+ ),
);
$form['alter']['link_class'] = array(
@@ -257,10 +254,9 @@ class views_handler_field extends views_handler {
'#type' => 'textfield',
'#default_value' => $this->options['alter']['link_class'],
'#description' => t('The CSS class to apply to the link.'),
- '#states' => array(
- 'visible' => array(
- 'input[name="options[alter][make_link]"]' => array('checked' => TRUE),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array(
+ 'edit-options-alter-make-link' => array(1)
),
);
$form['alter']['alt'] = array(
@@ -268,10 +264,9 @@ class views_handler_field extends views_handler {
'#type' => 'textfield',
'#default_value' => $this->options['alter']['alt'],
'#description' => t('Text to place as "alt" text which most browsers display as a tooltip when hovering over the link.'),
- '#states' => array(
- 'visible' => array(
- 'input[name="options[alter][make_link]"]' => array('checked' => TRUE),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array(
+ 'edit-options-alter-make-link' => array(1)
),
);
$form['alter']['prefix'] = array(
@@ -279,10 +274,9 @@ class views_handler_field extends views_handler {
'#type' => 'textfield',
'#default_value' => $this->options['alter']['prefix'],
'#description' => t('Any text to display before this link. You may include HTML.'),
- '#states' => array(
- 'visible' => array(
- 'input[name="options[alter][make_link]"]' => array('checked' => TRUE),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array(
+ 'edit-options-alter-make-link' => array(1)
),
);
$form['alter']['suffix'] = array(
@@ -290,10 +284,9 @@ class views_handler_field extends views_handler {
'#type' => 'textfield',
'#default_value' => $this->options['alter']['suffix'],
'#description' => t('Any text to display after this link. You may include HTML.'),
- '#states' => array(
- 'visible' => array(
- 'input[name="options[alter][make_link]"]' => array('checked' => TRUE),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array(
+ 'edit-options-alter-make-link' => array(1)
),
);
$form['alter']['target'] = array(
@@ -301,10 +294,9 @@ class views_handler_field extends views_handler {
'#type' => 'textfield',
'#default_value' => $this->options['alter']['target'],
'#description' => t("Target of the link, such as _blank, _parent or an iframe's name. This field is rarely used."),
- '#states' => array(
- 'visible' => array(
- 'input[name="options[alter][make_link]"]' => array('checked' => TRUE),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array(
+ 'edit-options-alter-make-link' => array(1)
),
);
@@ -345,17 +337,18 @@ class views_handler_field extends views_handler {
}
}
}
- // This has an extra div because fieldsets do not have an ID by
- // default in Drupal.
+ // This construct uses 'hidden' and not markup because process doesn't
+ // run. It also has an extra div because the dependency wants to hide
+ // the parent in situations like this, so we need a second div to
+ // make this work.
$form['alter']['help'] = array(
- '#type' => 'markup',
+ '#type' => 'hidden',
'#id' => 'views-tokens-help',
- '#prefix' => '<div><fieldset id="views-tokens-help" class="form-item"><legend>' . t('Replacement patterns') . '</legend>' . $output . '</fieldset></div>',
- '#states' => array(
- 'invisible' => array(
- 'input[name="options[alter][alter_text]"]' => array('checked' => FALSE),
- 'input[name="options[alter][make_link]"]' => array('checked' => FALSE),
- ),
+ '#prefix' => '<div><fieldset id="views-tokens-help"><legend>' . t('Replacement patterns') . '</legend>' . $output . '</fieldset></div>',
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array(
+ 'edit-options-alter-make-link' => array(1),
+ 'edit-options-alter-alter-text' => array(1),
),
);
@@ -371,10 +364,9 @@ class views_handler_field extends views_handler {
'#type' => 'textfield',
'#default_value' => $this->options['alter']['max_length'],
'#description' => t('The maximum number of characters this field can be.'),
- '#states' => array(
- 'visible' => array(
- 'input[name="options[alter][trim]"]' => array('checked' => TRUE),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array(
+ 'edit-options-alter-trim' => array(1)
),
);
@@ -383,10 +375,9 @@ class views_handler_field extends views_handler {
'#title' => t('Trim only on a word boundary'),
'#description' => t('If checked, this field be trimmed only on a word boundary. This is guaranteed to be the maximum characters stated or less. If there are no word boundaries this could trim a field to nothing.'),
'#default_value' => $this->options['alter']['word_boundary'],
- '#states' => array(
- 'visible' => array(
- 'input[name="options[alter][trim]"]' => array('checked' => TRUE),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array(
+ 'edit-options-alter-trim' => array(1)
),
);
@@ -395,10 +386,9 @@ class views_handler_field extends views_handler {
'#title' => t('Add an ellipsis'),
'#description' => t('If checked, a "..." will be added if a field was trimmed.'),
'#default_value' => $this->options['alter']['ellipsis'],
- '#states' => array(
- 'visible' => array(
- 'input[name="options[alter][trim]"]' => array('checked' => TRUE),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array(
+ 'edit-options-alter-trim' => array(1)
),
);
@@ -407,10 +397,9 @@ class views_handler_field extends views_handler {
'#title' => t('Field can contain HTML'),
'#description' => t('If checked, HTML corrector will be run to ensure tags are properly closed after trimming.'),
'#default_value' => $this->options['alter']['html'],
- '#states' => array(
- 'visible' => array(
- 'input[name="options[alter][trim]"]' => array('checked' => TRUE),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array(
+ 'edit-options-alter-trim' => array(1)
),
);
@@ -419,11 +408,7 @@ class views_handler_field extends views_handler {
'#title' => t('Strip HTML tags'),
'#description' => t('If checked, all HTML tags will be stripped.'),
'#default_value' => $this->options['alter']['strip_tags'],
- '#states' => array(
- 'visible' => array(
- 'input[name="options[alter][trim]"]' => array('checked' => TRUE),
- ),
- ),
+ '#process' => array('ctools_dependent_process'),
);
}
diff --git a/handlers/views_handler_field_counter.inc b/handlers/views_handler_field_counter.inc
index aec6ec3..cc0f0c0 100644
--- a/handlers/views_handler_field_counter.inc
+++ b/handlers/views_handler_field_counter.inc
@@ -16,6 +16,7 @@ class views_handler_field_counter extends views_handler_field {
'#title' => t('Starting value'),
'#default_value' => $this->options['counter_start'],
'#description' => t('Specify the number the counter should start at.'),
+ //'#process' => array('ctools_dependent_process'),
'#size' => 2,
);
}
diff --git a/handlers/views_handler_field_custom.inc b/handlers/views_handler_field_custom.inc
index 01f96bf..2347745 100644
--- a/handlers/views_handler_field_custom.inc
+++ b/handlers/views_handler_field_custom.inc
@@ -24,7 +24,7 @@ class views_handler_field_custom extends views_handler_field {
// Remove the checkbox
unset($form['alter']['alter_text']);
- unset($form['alter']['text']['#states']);
+ unset($form['alter']['text']['#dependency']);
unset($form['alter']['text']['#process']);
}
diff --git a/handlers/views_handler_field_date.inc b/handlers/views_handler_field_date.inc
index 89a88c3..a7d4727 100644
--- a/handlers/views_handler_field_date.inc
+++ b/handlers/views_handler_field_date.inc
@@ -38,12 +38,8 @@ class views_handler_field_date extends views_handler_field {
'#title' => t('Custom date format'),
'#description' => t('If "Custom", see <a href="http://us.php.net/manual/en/function.date.php" target="_blank">the PHP docs</a> for date formats. If "Time ago" this is the the number of different units to display, which defaults to two.'),
'#default_value' => isset($this->options['custom_date_format']) ? $this->options['custom_date_format'] : '',
+ '#process' => array('ctools_dependent_process'),
'#dependency' => array('edit-options-date-format' => array('custom', 'raw time ago', 'time ago', 'raw time span', 'time span')),
- '#states' => array(
- 'visible' => array(
- ':input[name=options[date_format]]' => array('value' => array('custom', 'raw time ago', 'time ago', 'raw time span', 'time span')),
- ),
- ),
);
}
diff --git a/handlers/views_handler_field_math.inc b/handlers/views_handler_field_math.inc
index 694e967..2d6f947 100644
--- a/handlers/views_handler_field_math.inc
+++ b/handlers/views_handler_field_math.inc
@@ -31,7 +31,7 @@ class views_handler_field_math extends views_handler_field_numeric {
// Then move the existing help:
$form['expression_help'] = $form['alter']['help'];
- unset($form['expression_help']['#states']);
+ unset($form['expression_help']['#dependency']);
unset($form['expression_help']['#process']);
unset($form['alter']['help']);
}
diff --git a/handlers/views_handler_field_numeric.inc b/handlers/views_handler_field_numeric.inc
index f0f28ec..c57076e 100644
--- a/handlers/views_handler_field_numeric.inc
+++ b/handlers/views_handler_field_numeric.inc
@@ -41,11 +41,8 @@ class views_handler_field_numeric extends views_handler_field {
'#title' => t('Precision'),
'#default_value' => $this->options['precision'],
'#description' => t('Specify how many digits to print after the decimal point.'),
- '#states' => array(
- 'invisible' => array(
- 'input[name="options[set_precision]"]' => array('checked' => FALSE),
- ),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array('edit-options-set-precision' => array(TRUE)),
'#size' => 2,
);
$form['decimal'] = array(
@@ -74,22 +71,16 @@ class views_handler_field_numeric extends views_handler_field {
'#title' => t('Singular form'),
'#default_value' => $this->options['format_plural_singular'],
'#description' => t('Text to use for the singular form.'),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[format_plural]"]' => array('checked' => TRUE),
- ),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array('edit-options-format-plural' => array(TRUE)),
);
$form['format_plural_plural'] = array(
'#type' => 'textfield',
'#title' => t('Plural form'),
'#default_value' => $this->options['format_plural_plural'],
'#description' => t('Text to use for the plural form, @count will be replaced with the value.'),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[format_plural]"]' => array('checked' => TRUE),
- ),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array('edit-options-format-plural' => array(TRUE)),
);
$form['prefix'] = array(
'#type' => 'textfield',
diff --git a/handlers/views_handler_field_prerender_list.inc b/handlers/views_handler_field_prerender_list.inc
index eef518b..08487bf 100644
--- a/handlers/views_handler_field_prerender_list.inc
+++ b/handlers/views_handler_field_prerender_list.inc
@@ -38,11 +38,8 @@ class views_handler_field_prerender_list extends views_handler_field {
'#type' => 'textfield',
'#title' => t('Separator'),
'#default_value' => $this->options['separator'],
- '#states' => array(
- 'visible' => array(
- ':input[name="options[type]"]' => array('value' => 'separator'),
- ),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array('radio:options[type]' => array('separator')),
);
}
diff --git a/handlers/views_handler_filter.inc b/handlers/views_handler_filter.inc
index a5ab3c7..8dfcee1 100644
--- a/handlers/views_handler_filter.inc
+++ b/handlers/views_handler_filter.inc
@@ -210,10 +210,9 @@ class views_handler_filter extends views_handler {
'#title' => t('Operator identifier'),
'#size' => 40,
'#description' => t('This will appear in the URL after the ? to identify this operator.'),
- '#states' => array(
- 'invisible' => array(
- 'input[name="options[expose][use_operator]"]' => array('checked' => FALSE),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array(
+ 'edit-options-expose-use-operator' => array(1)
),
);
}
diff --git a/handlers/views_handler_filter_in_operator.inc b/handlers/views_handler_filter_in_operator.inc
index fa6f4e7..2d8ee3b 100644
--- a/handlers/views_handler_filter_in_operator.inc
+++ b/handlers/views_handler_filter_in_operator.inc
@@ -203,6 +203,7 @@ class views_handler_filter_in_operator extends views_handler_filter {
$form['value']['#prefix'] = '<div id="edit-options-value-wrapper">';
$form['value']['#suffix'] = '</div>';
}
+ $process[] = 'ctools_dependent_process';
$form['value']['#dependency'] = array($source => $this->operator_values(1));
}
if (!empty($process)) {
diff --git a/handlers/views_handler_filter_numeric.inc b/handlers/views_handler_filter_numeric.inc
index 34aac75..28c87a2 100644
--- a/handlers/views_handler_filter_numeric.inc
+++ b/handlers/views_handler_filter_numeric.inc
@@ -148,12 +148,8 @@ class views_handler_filter_numeric extends views_handler_filter {
'#title' => empty($form_state['exposed']) ? t('Value') : '',
'#size' => 30,
'#default_value' => $this->value['value'],
- '#dependency' => array($source => $this->operator_values(1)),
- '#states' => array(
- 'visible' => array(
- ':input:id="' . $source . '"' => array('value' => $this->operator_values(1)),
- ),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array($source => array_map('htmlentities', $this->operator_values(1))),
);
if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier]['value'])) {
$form_state['input'][$identifier]['value'] = $this->value['value'];
@@ -188,6 +184,7 @@ class views_handler_filter_numeric extends views_handler_filter {
);
if ($which == 'all') {
$dependency = array(
+ '#process' => array('ctools_dependent_process'),
'#dependency' => array($source => $this->operator_values(2)),
);
$form['value']['min'] += $dependency;
diff --git a/handlers/views_handler_filter_string.inc b/handlers/views_handler_filter_string.inc
index 3afd418..1454560 100644
--- a/handlers/views_handler_filter_string.inc
+++ b/handlers/views_handler_filter_string.inc
@@ -201,6 +201,7 @@ class views_handler_filter_string extends views_handler_filter {
if ($which == 'all') {
$form['value'] += array(
+ '#process' => array('ctools_dependent_process'),
'#dependency' => array($source => $this->operator_values(1)),
);
}
diff --git a/help/api-upgrading.html b/help/api-upgrading.html
index 817260e..87f6a37 100644
--- a/help/api-upgrading.html
+++ b/help/api-upgrading.html
@@ -24,3 +24,14 @@ files[] = includes/views/handlers/example_handler_argument_string.inc
Note that views_handler_filter_float has been removed.
This functionality is now handled by views_handler_filter_numeric.
There's no need for having a special handler any more, thanks to the new DB layer in Drupal 7.
+
+<h3>Ctools dependency</h3>
+Views requires ctools now, so it can use the dependency system of ctools.
+The only thing you have to do is to replace
+<pre>
+'#process' => array('views_process_dependeny')
+</pre>
+with
+<pre>
+'#process' => array('ctools_dependent_process'),
+</pre> \ No newline at end of file
diff --git a/includes/admin.inc b/includes/admin.inc
index c5575ba..be0361b 100644
--- a/includes/admin.inc
+++ b/includes/admin.inc
@@ -1017,6 +1017,7 @@ function views_ui_edit_view_form_delete($form, &$form_state) {
*/
function template_preprocess_views_ui_edit_view(&$vars) {
$view = &$vars['view'];
+ ctools_include('dependent');
// The form has to be saved as variable because of strict warnings.
$form = drupal_get_form('views_ui_edit_view_form', $view);
@@ -2364,6 +2365,8 @@ function views_ui_add_item_form($form, &$form_state) {
$display_id = $form_state['display_id'];
$type = $form_state['type'];
+ ctools_add_js('dependent');
+
if (!$view->set_display($display_id)) {
views_ajax_error(t('Invalid display id @display', array('@display' => $display_id)));
}
@@ -2389,7 +2392,7 @@ function views_ui_add_item_form($form, &$form_state) {
'#type' => 'select',
'#title' => t('Groups'),
'#options' => array(),
- '#attributes' => array('class' => array('views-master-dependent')),
+ '#attributes' => array('class' => array('ctools-master-dependent')),
);
$form['name'] = array(
@@ -2409,7 +2412,7 @@ function views_ui_add_item_form($form, &$form_state) {
}
foreach ($grouped_options as $group => $group_options) {
- $form['name'][$group . '_start']['#markup'] = '<div class="views-dependent-all views-dependent-' . $group . '">';
+ $form['name'][$group . '_start']['#markup'] = '<div class="ctools-dependent-all ctools-dependent-' . $group . '">';
foreach ($group_options as $key => $option) {
$form['name'][$key] = array(
'#type' => 'checkbox',
@@ -2428,6 +2431,7 @@ function views_ui_add_item_form($form, &$form_state) {
'#value' => '<div class="form-item">' . t('There are no @types available to add.', array('@types' => $types[$type]['ltitle'])) . '</div>',
);
}
+ ctools_include('dependent');
views_ui_standard_form_buttons($form, $form_state, 'views_ui_add_item_form', t('Add'));
return $form;
diff --git a/includes/ajax.inc b/includes/ajax.inc
index b3f5d30..d9b3910 100644
--- a/includes/ajax.inc
+++ b/includes/ajax.inc
@@ -197,6 +197,8 @@ function views_ajax_error($message) {
* This makes some assumptions about the client.
*/
function views_ajax_form_wrapper($form_id, &$form_state) {
+ ctools_include('dependent');
+
// This won't override settings already in.
$form_state += array(
'rerender' => FALSE,
@@ -207,8 +209,7 @@ function views_ajax_form_wrapper($form_id, &$form_state) {
),
);
- $form = drupal_build_form($form_id, $form_state);
- $output = drupal_render($form);
+ $output = drupal_render(drupal_build_form($form_id, $form_state));
// These forms have the title built in, so set the title here:
if (empty($form_state['ajax']) && !empty($form_state['title'])) {
diff --git a/includes/handlers.inc b/includes/handlers.inc
index 94d08de..b8ad503 100644
--- a/includes/handlers.inc
+++ b/includes/handlers.inc
@@ -537,7 +537,7 @@ class views_many_to_one_helper {
$this->handler = &$handler;
}
- static function option_definition(&$options) {
+ function option_definition(&$options) {
$options['reduce_duplicates'] = array('default' => FALSE);
}
diff --git a/includes/plugins.inc b/includes/plugins.inc
index b7469bf..6ab1a56 100644
--- a/includes/plugins.inc
+++ b/includes/plugins.inc
@@ -10,6 +10,7 @@
* Implements hook_views_plugins
*/
function views_views_plugins() {
+ $js_path = drupal_get_path('module', 'views') . '/js';
$plugins = array(
// display, style, row, argument default, argument validator and access.
'display' => array(
@@ -21,7 +22,7 @@ function views_views_plugins() {
'theme' => 'views_view',
'no ui' => TRUE,
'no remove' => TRUE,
- 'js' => array('misc/collapse.js', 'misc/textarea.js', 'misc/tabledrag.js', 'misc/autocomplete.js', 'misc/states.js'),
+ 'js' => array('misc/collapse.js', 'misc/textarea.js', 'misc/tabledrag.js', 'misc/autocomplete.js'),
'use ajax' => TRUE,
'use pager' => TRUE,
'use more' => TRUE,
diff --git a/modules/taxonomy/views_handler_argument_term_node_tid_depth.inc b/modules/taxonomy/views_handler_argument_term_node_tid_depth.inc
index 15e49fb..51b531e 100644
--- a/modules/taxonomy/views_handler_argument_term_node_tid_depth.inc
+++ b/modules/taxonomy/views_handler_argument_term_node_tid_depth.inc
@@ -46,11 +46,8 @@ class views_handler_argument_term_node_tid_depth extends views_handler_argument
'#title' => t("Use Drupal's taxonomy term path to create breadcrumb links"),
'#description' => t('If selected, the links in the breadcrumb trail will be created using the standard drupal method instead of the custom views method. This is useful if you are using modules like taxonomy redirect to modify your taxonomy term links.'),
'#default_value' => !empty($this->options['use_taxonomy_term_path']),
- '#states' => array(
- 'invisible' => array(
- 'input[name="options[set_breadcrumb]"]' => array('checked' => FALSE),
- ),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array('edit-options-set-breadcrumb' => array(TRUE)),
);
}
diff --git a/modules/taxonomy/views_handler_field_term_node_tid.inc b/modules/taxonomy/views_handler_field_term_node_tid.inc
index 06acd55..c1788af 100644
--- a/modules/taxonomy/views_handler_field_term_node_tid.inc
+++ b/modules/taxonomy/views_handler_field_term_node_tid.inc
@@ -65,13 +65,9 @@ class views_handler_field_term_node_tid extends views_handler_field_prerender_li
'#title' => t('Vocabularies'),
'#options' => $options,
'#default_value' => $this->options['vocabularies'],
- '#process' => array('form_process_checkboxes'),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[limit]"]' => array('checked' => TRUE),
- ),
- ),
- );
+ '#process' => array('form_process_checkboxes', 'ctools_dependent_process'),
+ '#dependency' => array('edit-options-limit' => array(TRUE)),
+ );
}
/**
diff --git a/modules/taxonomy/views_handler_filter_term_node_tid.inc b/modules/taxonomy/views_handler_filter_term_node_tid.inc
index 09c3a7f..e0a3c31 100644
--- a/modules/taxonomy/views_handler_filter_term_node_tid.inc
+++ b/modules/taxonomy/views_handler_filter_term_node_tid.inc
@@ -73,11 +73,8 @@ class views_handler_filter_term_node_tid extends views_handler_filter_many_to_on
'#type' => 'checkbox',
'#title' => t('Show hierarchy in dropdown'),
'#default_value' => !empty($this->options['hierarchy']),
- '#states' => array(
- 'visible' => array(
- 'input[name="options[type]' => array('value' => 'select'),
- ),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array('radio:options[type]' => array('select')),
);
$form['markup_end'] = array(
diff --git a/modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc b/modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc
index 64f6c0c..c4a5020 100644
--- a/modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc
+++ b/modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc
@@ -47,7 +47,10 @@ class views_plugin_argument_default_taxonomy_tid extends views_plugin_argument_d
'#type' => 'checkbox',
'#title' => t('Limit terms by vocabulary'),
'#default_value'=> $this->options['limit'],
- '#process' => array('form_process_checkboxes'),
+ '#process' => array('form_process_checkboxes', 'ctools_dependent_process'),
+ '#dependency' => array(
+ 'edit-options-argument-default-taxonomy-tid-node' => array(1),
+ ),
);
$options = array();
@@ -63,11 +66,10 @@ class views_plugin_argument_default_taxonomy_tid extends views_plugin_argument_d
'#title' => t('Vocabularies'),
'#options' => $options,
'#default_value' => $this->options['vocabularies'],
- '#process' => array('form_process_checkboxes'),
- '#states' => array(
- 'visible' => array(
- ':input[name="options[argument_default][taxonomy_tid][limit]"]' => array('checked' => TRUE),
- ),
+ '#process' => array('form_process_checkboxes', 'ctools_dependent_process'),
+ '#dependency' => array(
+ //'edit-options-argument-default-taxonomy-tid-limit' => array(1),
+ 'edit-options-argument-default-taxonomy-tid-node' => array(1),
),
);
}
diff --git a/modules/user/views_handler_field_user_name.inc b/modules/user/views_handler_field_user_name.inc
index 3d8023e..fa6b41e 100644
--- a/modules/user/views_handler_field_user_name.inc
+++ b/modules/user/views_handler_field_user_name.inc
@@ -36,10 +36,9 @@ class views_handler_field_user_name extends views_handler_field_user {
'#title' => t('Text to display for anonymous users'),
'#type' => 'textfield',
'#default_value' => $this->options['anonymous_text'],
- '#states' => array(
- 'invisible' => array(
- 'input[name="options[overwrite_anonymous"]' => array('checked' => FALSE),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array(
+ 'edit-options-overwrite-anonymous' => array(1),
),
);
}
diff --git a/modules/user/views_plugin_argument_validate_user.inc b/modules/user/views_plugin_argument_validate_user.inc
index 9446f5e..36e8027 100644
--- a/modules/user/views_plugin_argument_validate_user.inc
+++ b/modules/user/views_plugin_argument_validate_user.inc
@@ -44,11 +44,9 @@ class views_plugin_argument_validate_user extends views_plugin_argument_validate
'#options' => user_roles(TRUE),
'#default_value' => $this->options['roles'],
'#description' => t('If no roles are selected, users from any role will be allowed.'),
- '#process' => array('form_process_checkboxes'),
- '#states' => array(
- 'invisible' => array(
- 'input[name="options[argument_validate][user][restrict_roles]"]' => array('checked' => FALSE),
- ),
+ '#process' => array('form_process_checkboxes', 'ctools_dependent_process'),
+ '#dependency' => array(
+ 'edit-options-argument-validate-user-restrict-roles' => array(1),
),
);
}
diff --git a/plugins/views_plugin_argument_default_php.inc b/plugins/views_plugin_argument_default_php.inc
index 524f499..4686452 100644
--- a/plugins/views_plugin_argument_default_php.inc
+++ b/plugins/views_plugin_argument_default_php.inc
@@ -21,6 +21,7 @@ class views_plugin_argument_default_php extends views_plugin_argument_default {
'#type' => 'textarea',
'#title' => t('PHP argument code'),
'#default_value' => $this->options['code'],
+ '#process' => array('ctools_dependent_process'),
'#description' => t('Enter PHP code that returns a value to use for this argument. Do not use &lt;?php ?&gt;. You must return only a single value for just this argument.'),
);
diff --git a/plugins/views_plugin_display.inc b/plugins/views_plugin_display.inc
index c567245..f5af074 100644
--- a/plugins/views_plugin_display.inc
+++ b/plugins/views_plugin_display.inc
@@ -98,7 +98,7 @@ class views_plugin_display extends views_plugin {
'relationship' => 'none',
'group_type' => 'group',
'content' => $content,
- 'format' => !empty($format) ? $format : variable_get('filter_default_format', 1),
+ 'format' => !empty($format) ? $format : filter_default_format(),
);
if ($area != 'empty' && $empty = $this->get_option($area . '_empty')) {
diff --git a/plugins/views_plugin_display_feed.inc b/plugins/views_plugin_display_feed.inc
index 6be0768..62f9369 100644
--- a/plugins/views_plugin_display_feed.inc
+++ b/plugins/views_plugin_display_feed.inc
@@ -136,11 +136,8 @@ class views_plugin_display_feed extends views_plugin_display_page {
'#default_value' => $this->get_option('sitename_title'),
);
$form['title'] = $title;
- $form['title']['#states'] = array(
- 'invisible' => array(
- 'input[name="sitename_title"]' => array('checked' => TRUE),
- ),
- );
+ $form['title']['#process'] = array('ctools_dependent_process');
+ $form['title']['#dependency'] = array('edit-sitename-title' => array(FALSE));
break;
case 'displays':
$form['#title'] .= t('Attach to');
diff --git a/plugins/views_plugin_display_page.inc b/plugins/views_plugin_display_page.inc
index 8348382..bebd480 100644
--- a/plugins/views_plugin_display_page.inc
+++ b/plugins/views_plugin_display_page.inc
@@ -298,24 +298,16 @@ class views_plugin_display_page extends views_plugin_display {
'#type' => 'textfield',
'#default_value' => $menu['title'],
'#description' => t('If set to normal or tab, enter the text to use for the menu item.'),
+ '#process' => array('ctools_dependent_process'),
'#dependency' => array('radio:menu[type]' => array('normal', 'tab', 'default tab')),
- '#states' => array(
- 'visible' => array(
- ':radio:menu[type]' => array('value' => array('normal', 'tab', 'default tab')),
- ),
- ),
);
$form['menu']['description'] = array(
'#title' => t('Description'),
'#type' => 'textfield',
'#default_value' => $menu['description'],
'#description' => t("If set to normal or tab, enter the text to use for the menu item's description."),
+ '#process' => array('ctools_dependent_process'),
'#dependency' => array('radio:menu[type]' => array('normal', 'tab', 'default tab')),
- '#states' => array(
- 'visible' => array(
- ':radio:menu[type]' => array('value' => array('normal', 'tab', 'default tab')),
- ),
- ),
);
// Only display the menu selector if menu module is enabled.
@@ -326,12 +318,8 @@ class views_plugin_display_page extends views_plugin_display {
'#options' => menu_get_menus(),
'#default_value' => $menu['name'],
'#description' => t('Insert item into an available menu.'), //
+ '#process' => array('ctools_dependent_process'),
'#dependency' => array('radio:menu[type]' => array('normal')),
- '#states' => array(
- 'visible' => array(
- ':radio:menu[type]' => array('value' => array('normal')),
- ),
- ),
);
}
else {
@@ -349,12 +337,8 @@ class views_plugin_display_page extends views_plugin_display {
'#type' => 'textfield',
'#default_value' => isset($menu['weight']) ? $menu['weight'] : 0,
'#description' => t('The lower the weight the higher/further left it will appear.'),
+ '#process' => array('ctools_dependent_process'),
'#dependency' => array('radio:menu[type]' => array('normal', 'tab', 'default tab')),
- '#states' => array(
- 'visible' => array(
- ':radio:menu[type]' => array('value' => array('normal', 'tab', 'default tab')),
- ),
- ),
);
break;
case 'tab_options':
@@ -387,24 +371,16 @@ class views_plugin_display_page extends views_plugin_display {
'#type' => 'textfield',
'#default_value' => $tab_options['title'],
'#description' => t('If creating a parent menu item, enter the title of the item.'),
+ '#process' => array('ctools_dependent_process'),
'#dependency' => array('radio:tab_options[type]' => array('normal', 'tab')),
- '#states' => array(
- 'visible' => array(
- ':radio:tab_options[type]' => array('value' => array('normal', 'tab')),
- ),
- ),
);
$form['tab_options']['description'] = array(
'#title' => t('Description'),
'#type' => 'textfield',
'#default_value' => $tab_options['description'],
'#description' => t('If creating a parent menu item, enter the description of the item.'),
+ '#process' => array('ctools_dependent_process'),
'#dependency' => array('radio:tab_options[type]' => array('normal', 'tab')),
- '#states' => array(
- 'visible' => array(
- ':radio:tab_options[type]' => array('value' => array('normal', 'tab')),
- ),
- ),
);
// Only display the menu selector if menu module is enabled.
if (module_exists('menu')) {
@@ -414,12 +390,8 @@ class views_plugin_display_page extends views_plugin_display {
'#options' => menu_get_menus(),
'#default_value' => $tab_options['name'],
'#description' => t('Insert item into an available menu.'),
+ '#process' => array('ctools_dependent_process'),
'#dependency' => array('radio:tab_options[type]' => array('normal')),
- '#states' => array(
- 'visible' => array(
- ':radio:tab_options[type]' => array('value' => array('normal')),
- ),
- ),
);
}
else {
@@ -438,12 +410,8 @@ class views_plugin_display_page extends views_plugin_display {
'#default_value' => $tab_options['weight'],
'#size' => 5,
'#description' => t('If the parent menu item is a tab, enter the weight of the tab. The lower the number, the more to the left it will be.'),
+ '#process' => array('ctools_dependent_process'),
'#dependency' => array('radio:tab_options[type]' => array('tab')),
- '#states' => array(
- 'visible' => array(
- ':radio:tab_options[type]' => array('value' => array('tab')),
- ),
- ),
);
break;
}
diff --git a/plugins/views_plugin_exposed_form.inc b/plugins/views_plugin_exposed_form.inc
index 80acd6c..f1ff5fc 100644
--- a/plugins/views_plugin_exposed_form.inc
+++ b/plugins/views_plugin_exposed_form.inc
@@ -62,11 +62,10 @@ class views_plugin_exposed_form extends views_plugin {
'#description' => t('Text to display in the reset button of the exposed form.'),
'#default_value' => $this->options['reset_button_label'],
'#required' => TRUE,
- '#states' => array(
- 'invisible' => array(
- 'input[name="exposed_form_options[reset_button]"]' => array('checked' => FALSE),
- ),
+ '#dependency' => array(
+ 'edit-exposed-form-options-reset-button' => array(1)
),
+ '#process' => array('ctools_dependent_process'),
);
$form['exposed_sorts_label'] = array(
diff --git a/plugins/views_plugin_pager_full.inc b/plugins/views_plugin_pager_full.inc
index fb49adb..fa1183a 100644
--- a/plugins/views_plugin_pager_full.inc
+++ b/plugins/views_plugin_pager_full.inc
@@ -88,10 +88,9 @@ class views_plugin_pager_full extends views_plugin_pager {
'#required' => TRUE,
'#description' => t('Label to use in the exposed items per page form element.'),
'#default_value' => $this->options['expose']['items_per_page_label'],
- '#states' => array(
- 'invisible' => array(
- 'input[name="pager_options[expose][items_per_page]"]' => array('checked' => FALSE),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array(
+ 'edit-pager-options-expose-items-per-page' => array(1)
),
);
@@ -101,10 +100,9 @@ class views_plugin_pager_full extends views_plugin_pager {
'#required' => TRUE,
'#description' => t('Set between which values the user can choose when determining the items per page. Separated by comma.'),
'#default_value' => $this->options['expose']['items_per_page_options'],
- '#states' => array(
- 'invisible' => array(
- 'input[name="pager_options[expose][items_per_page]"]' => array('checked' => FALSE),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array(
+ 'edit-pager-options-expose-items-per-page' => array(1)
),
);
@@ -121,10 +119,9 @@ class views_plugin_pager_full extends views_plugin_pager {
'#required' => TRUE,
'#description' => t('Label to use in the exposed offset form element.'),
'#default_value' => $this->options['expose']['offset_label'],
- '#states' => array(
- 'invisible' => array(
- 'input[name="pager_options[expose][offset]"]' => array('checked' => FALSE),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array(
+ 'edit-pager-options-expose-offset' => array(1)
),
);
}
diff --git a/plugins/views_plugin_style_rss.inc b/plugins/views_plugin_style_rss.inc
index 87435bf..74db803 100644
--- a/plugins/views_plugin_style_rss.inc
+++ b/plugins/views_plugin_style_rss.inc
@@ -62,11 +62,8 @@ class views_plugin_style_rss extends views_plugin_style {
'#title' => t('RSS description'),
'#default_value' => $this->options['description'],
'#description' => t('This will appear in the RSS feed itself.'),
- '#states' => array(
- 'invisible' => array(
- 'input[name="style_options[override]"]' => array('checked' => FALSE),
- ),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array('edit-style-options-override' => array(FALSE)),
);
}
diff --git a/plugins/views_plugin_style_summary.inc b/plugins/views_plugin_style_summary.inc
index af94f7a..6ab8bf3 100644
--- a/plugins/views_plugin_style_summary.inc
+++ b/plugins/views_plugin_style_summary.inc
@@ -53,11 +53,8 @@ class views_plugin_style_summary extends views_plugin_style {
'#type' => 'textfield',
'#title' => t('Items to display'),
'#default_value' => $this->options['items_per_page'],
- '#states' => array(
- 'invisible' => array(
- 'input[name="style_options[override]"]' => array('checked' => FALSE),
- ),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array('edit-style-options-override' => array(TRUE)),
);
}
diff --git a/plugins/views_plugin_style_table.inc b/plugins/views_plugin_style_table.inc
index 83c2d20..d8e4f2e 100644
--- a/plugins/views_plugin_style_table.inc
+++ b/plugins/views_plugin_style_table.inc
@@ -196,11 +196,8 @@ class views_plugin_style_table extends views_plugin_style {
$form['info'][$field]['sortable'] = array(
'#type' => 'checkbox',
'#default_value' => !empty($this->options['info'][$field]['sortable']),
- '#states' => array(
- 'visible' => array(
- ':input[id="' . $id . '"]' => array('value' => $field),
- ),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array($id => array($field)),
);
// Provide an ID so we can have such things.
$radio_id = drupal_html_id('edit-default-' . $field);
@@ -212,11 +209,8 @@ class views_plugin_style_table extends views_plugin_style {
// because 'radio' doesn't fully support '#id' =(
'#attributes' => array('id' => $radio_id),
'#default_value' => $default,
- '#states' => array(
- 'visible' => array(
- ':input[id="' . $id . '"]' => array('value' => $field),
- ),
- ),
+ '#process' => array('ctools_dependent_process'),
+ '#dependency' => array($id => array($field)),
);
}
$form['info'][$field]['align'] = array(
@@ -228,12 +222,14 @@ class views_plugin_style_table extends views_plugin_style {
'views-align-center' => t('Center'),
'views-align-right' => t('Right'),
),
+ '#process' => array('ctools_dependent_process'),
'#dependency' => array($id => array($field)),
);
$form['info'][$field]['separator'] = array(
'#type' => 'textfield',
'#size' => 10,
'#default_value' => isset($this->options['info'][$field]['separator']) ? $this->options['info'][$field]['separator'] : '',
+ '#process' => array('ctools_dependent_process'),
'#dependency' => array($id => array($field)),
);
diff --git a/views.module b/views.module
index 381cff3..7f710c2 100644
--- a/views.module
+++ b/views.module
@@ -1074,6 +1074,7 @@ function views_exposed_form($form, &$form_state) {
if ($view->use_ajax) {
drupal_add_js('misc/jquery.form.js', array('group' => JS_LIBRARY));
}
+ ctools_include('dependent');
$exposed_form_plugin = $form_state['exposed_form_plugin'];
$exposed_form_plugin->exposed_form_alter($form, $form_state);