diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 92edc98fe565393817bee552943e92acff4866db..925eea13dca4fa4bc281cd1118f535007b0b5a62 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -410,6 +410,7 @@ Views 3.x-7.x-dev
o #941974 by dereine: Use contextual links in the views ui when possible.
o #761102 by dereine: test: user default argument.
o by dereine: Fix notice in views_ui_add_page.
+ o #667950 by damZ, dereine: Port #dependency form elements to #states.
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 4ce951eddb8cbded5d64c2b8ce924eb502217bc9..5bb11ed421b6250315935a0f9302d8532ad5b613 100644
--- a/handlers/views_handler_argument.inc
+++ b/handlers/views_handler_argument.inc
@@ -227,9 +227,10 @@ class views_handler_argument extends views_handler {
$form['argument_validate'][$id] = array(
'#type' => 'item',
'#input' => TRUE, // trick it into checking input to make #process run
- '#process' => array('views_process_dependency'),
- '#dependency' => array(
- 'edit-options-validate-type' => array($id)
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="options[validate_type]"]' => array('value' => $id),
+ ),
),
);
$plugin->options_form($form['argument_validate'][$id], $form_state);
@@ -385,8 +386,11 @@ class views_handler_argument extends views_handler {
'#type' => 'hidden',
'#id' => 'views-default-options',
'#prefix' => '
' . t('Provide default argument options') . ' ',
- '#process' => array('views_process_dependency'),
- '#dependency' => array('radio:options[default_action]' => array('default')),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="options[default_action]"]' => array('value' => 'default'),
+ ),
+ ),
);
$form['default_argument_type'] = array(
@@ -396,6 +400,11 @@ 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) {
@@ -408,12 +417,12 @@ class views_handler_argument extends views_handler {
$form['argument_default'][$id] = array(
'#type' => 'item',
'#input' => TRUE, // trick it into checking input to make #process run
- '#process' => array('views_process_dependency'),
- '#dependency' => array(
- 'radio:options[default_action]' => array('default'),
- 'radio:options[default_argument_type]' => array($id)
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="options[default_action]"]' => array('value' => 'default'),
+ ':input[name="options[default_argument_type]"]' => array('value' => $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 c2bd11d4b6e7233d573d6e60989793bcb89fb8cd..c89907c7938c0c2beae4b4ad4457a25a57cad6d6 100644
--- a/handlers/views_handler_argument_string.inc
+++ b/handlers/views_handler_argument_string.inc
@@ -51,8 +51,11 @@ 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'],
- '#process' => array('views_process_dependency'),
- '#dependency' => array('edit-options-glossary' => array(TRUE)),
+ '#states' => array(
+ 'invisible' => array(
+ 'input[name="options[glossary]"]' => array('checked' => FALSE),
+ ),
+ ),
);
$form['case'] = array(
diff --git a/handlers/views_handler_field.inc b/handlers/views_handler_field.inc
index 9d4b8978c615ced2456127705962a323383b7a20..cff1f70d958f5982e9a87a8757ae8054fed68c1d 100644
--- a/handlers/views_handler_field.inc
+++ b/handlers/views_handler_field.inc
@@ -216,9 +216,10 @@ 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.'),
- '#process' => array('views_process_dependency'),
- '#dependency' => array(
- 'edit-options-alter-alter-text' => array(1)
+ '#states' => array(
+ 'visible' => array(
+ 'input[name="options[alter][alter_text]"]' => array('checked' => TRUE),
+ )
),
);
@@ -233,9 +234,10 @@ 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.'),
- '#process' => array('views_process_dependency'),
- '#dependency' => array(
- 'edit-options-alter-make-link' => array(1)
+ '#states' => array(
+ 'visible' => array(
+ 'input[name="options[alter][make_link]"]' => array('checked' => TRUE),
+ ),
),
'#maxlength' => 255,
);
@@ -243,10 +245,11 @@ class views_handler_field extends views_handler {
'#type' => 'checkbox',
'#title' => t('Use absolute path'),
'#default_value' => $this->options['alter']['absolute'],
- '#process' => array('views_process_dependency'),
- '#dependency' => array(
- 'edit-options-alter-make-link' => array(1)
- ),
+ '#states' => array(
+ 'visible' => array(
+ 'input[name="options[alter][make_link]"]' => array('checked' => TRUE),
+ ),
+ ),
);
$form['alter']['link_class'] = array(
@@ -254,9 +257,10 @@ 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.'),
- '#process' => array('views_process_dependency'),
- '#dependency' => array(
- 'edit-options-alter-make-link' => array(1)
+ '#states' => array(
+ 'visible' => array(
+ 'input[name="options[alter][make_link]"]' => array('checked' => TRUE),
+ ),
),
);
$form['alter']['alt'] = array(
@@ -264,9 +268,10 @@ 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.'),
- '#process' => array('views_process_dependency'),
- '#dependency' => array(
- 'edit-options-alter-make-link' => array(1)
+ '#states' => array(
+ 'visible' => array(
+ 'input[name="options[alter][make_link]"]' => array('checked' => TRUE),
+ ),
),
);
$form['alter']['prefix'] = array(
@@ -274,9 +279,10 @@ 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.'),
- '#process' => array('views_process_dependency'),
- '#dependency' => array(
- 'edit-options-alter-make-link' => array(1)
+ '#states' => array(
+ 'visible' => array(
+ 'input[name="options[alter][make_link]"]' => array('checked' => TRUE),
+ ),
),
);
$form['alter']['suffix'] = array(
@@ -284,9 +290,10 @@ 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.'),
- '#process' => array('views_process_dependency'),
- '#dependency' => array(
- 'edit-options-alter-make-link' => array(1)
+ '#states' => array(
+ 'visible' => array(
+ 'input[name="options[alter][make_link]"]' => array('checked' => TRUE),
+ ),
),
);
$form['alter']['target'] = array(
@@ -294,9 +301,10 @@ 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."),
- '#process' => array('views_process_dependency'),
- '#dependency' => array(
- 'edit-options-alter-make-link' => array(1)
+ '#states' => array(
+ 'visible' => array(
+ 'input[name="options[alter][make_link]"]' => array('checked' => TRUE),
+ ),
),
);
@@ -337,18 +345,17 @@ class views_handler_field extends views_handler {
}
}
}
- // 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.
+ // This has an extra div because fieldsets do not have an ID by
+ // default in Drupal.
$form['alter']['help'] = array(
- '#type' => 'hidden',
+ '#type' => 'markup',
'#id' => 'views-tokens-help',
- '#prefix' => '
' . t('Replacement patterns') . ' ' . $output . ' ',
- '#process' => array('views_process_dependency'),
- '#dependency' => array(
- 'edit-options-alter-make-link' => array(1),
- 'edit-options-alter-alter-text' => array(1),
+ '#prefix' => '
' . t('Replacement patterns') . ' ' . $output . ' ',
+ '#states' => array(
+ 'invisible' => array(
+ 'input[name="options[alter][alter_text]"]' => array('checked' => FALSE),
+ 'input[name="options[alter][make_link]"]' => array('checked' => FALSE),
+ ),
),
);
@@ -364,9 +371,10 @@ 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.'),
- '#process' => array('views_process_dependency'),
- '#dependency' => array(
- 'edit-options-alter-trim' => array(1)
+ '#states' => array(
+ 'visible' => array(
+ 'input[name="options[alter][trim]"]' => array('checked' => TRUE),
+ ),
),
);
@@ -375,9 +383,10 @@ 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'],
- '#process' => array('views_process_dependency'),
- '#dependency' => array(
- 'edit-options-alter-trim' => array(1)
+ '#states' => array(
+ 'visible' => array(
+ 'input[name="options[alter][trim]"]' => array('checked' => TRUE),
+ ),
),
);
@@ -386,9 +395,10 @@ 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'],
- '#process' => array('views_process_dependency'),
- '#dependency' => array(
- 'edit-options-alter-trim' => array(1)
+ '#states' => array(
+ 'visible' => array(
+ 'input[name="options[alter][trim]"]' => array('checked' => TRUE),
+ ),
),
);
@@ -397,9 +407,10 @@ 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'],
- '#process' => array('views_process_dependency'),
- '#dependency' => array(
- 'edit-options-alter-trim' => array(1)
+ '#states' => array(
+ 'visible' => array(
+ 'input[name="options[alter][trim]"]' => array('checked' => TRUE),
+ ),
),
);
@@ -408,7 +419,11 @@ 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'],
- '#process' => array('views_process_dependency'),
+ '#states' => array(
+ 'visible' => array(
+ 'input[name="options[alter][trim]"]' => array('checked' => TRUE),
+ ),
+ ),
);
}
diff --git a/handlers/views_handler_field_counter.inc b/handlers/views_handler_field_counter.inc
index 54b5995f387391b7633e93f4759faf8d4242a4ee..aec6ec327ba6a37d3f80d93ca53dc2e785153a3a 100644
--- a/handlers/views_handler_field_counter.inc
+++ b/handlers/views_handler_field_counter.inc
@@ -16,7 +16,6 @@ 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('views_process_dependency'),
'#size' => 2,
);
}
diff --git a/handlers/views_handler_field_custom.inc b/handlers/views_handler_field_custom.inc
index 2347745ef57d8342171980be3ce1e5cf8d49800e..01f96bf945eb8ebbc2546b6d854ea745facc271f 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']['#dependency']);
+ unset($form['alter']['text']['#states']);
unset($form['alter']['text']['#process']);
}
diff --git a/handlers/views_handler_field_date.inc b/handlers/views_handler_field_date.inc
index 1c132bc2b1ac3354551379850c3b73fb247c45de..89a88c33696bfca898a93c0ab98c3c60f00956fb 100644
--- a/handlers/views_handler_field_date.inc
+++ b/handlers/views_handler_field_date.inc
@@ -38,8 +38,12 @@ class views_handler_field_date extends views_handler_field {
'#title' => t('Custom date format'),
'#description' => t('If "Custom", see the PHP docs 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('views_process_dependency'),
'#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 2d6f947b827319394e83971ea7eff617772da3e0..694e9670d4590fd8852ae29bb20daa7bfd25b5d2 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']['#dependency']);
+ unset($form['expression_help']['#states']);
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 293c24c5650f6dbd5c8d54e480ce1f9fe80b0bb2..f0f28eca5731108c385ad252c5beaf71e9dd13cd 100644
--- a/handlers/views_handler_field_numeric.inc
+++ b/handlers/views_handler_field_numeric.inc
@@ -41,8 +41,11 @@ 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.'),
- '#process' => array('views_process_dependency'),
- '#dependency' => array('edit-options-set-precision' => array(TRUE)),
+ '#states' => array(
+ 'invisible' => array(
+ 'input[name="options[set_precision]"]' => array('checked' => FALSE),
+ ),
+ ),
'#size' => 2,
);
$form['decimal'] = array(
@@ -71,16 +74,22 @@ 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.'),
- '#process' => array('views_process_dependency'),
- '#dependency' => array('edit-options-format-plural' => array(TRUE)),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="options[format_plural]"]' => array('checked' => 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.'),
- '#process' => array('views_process_dependency'),
- '#dependency' => array('edit-options-format-plural' => array(TRUE)),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="options[format_plural]"]' => array('checked' => 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 d852247d993430b508c2c55a85e896c7b07ca4b8..eef518bf9d165a9275247fbb672f0a538b9141ff 100644
--- a/handlers/views_handler_field_prerender_list.inc
+++ b/handlers/views_handler_field_prerender_list.inc
@@ -38,8 +38,11 @@ class views_handler_field_prerender_list extends views_handler_field {
'#type' => 'textfield',
'#title' => t('Separator'),
'#default_value' => $this->options['separator'],
- '#process' => array('views_process_dependency'),
- '#dependency' => array('radio:options[type]' => array('separator')),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="options[type]"]' => array('value' => 'separator'),
+ ),
+ ),
);
}
diff --git a/handlers/views_handler_filter.inc b/handlers/views_handler_filter.inc
index 0b79f706b885d7b10e931bdfbd05bd20faedf13b..a5ab3c72af9afe50c55ffc6e3d734d18901d2b5f 100644
--- a/handlers/views_handler_filter.inc
+++ b/handlers/views_handler_filter.inc
@@ -210,9 +210,10 @@ 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.'),
- '#process' => array('views_process_dependency'),
- '#dependency' => array(
- 'edit-options-expose-use-operator' => array(1)
+ '#states' => array(
+ 'invisible' => array(
+ 'input[name="options[expose][use_operator]"]' => array('checked' => FALSE),
+ ),
),
);
}
diff --git a/handlers/views_handler_filter_in_operator.inc b/handlers/views_handler_filter_in_operator.inc
index cb6d5aeafb5aecdbb158821b9805e4499507e7bf..fa6f4e70fed5066c16b4abd78e09690e4faf6816 100644
--- a/handlers/views_handler_filter_in_operator.inc
+++ b/handlers/views_handler_filter_in_operator.inc
@@ -203,7 +203,6 @@ class views_handler_filter_in_operator extends views_handler_filter {
$form['value']['#prefix'] = '';
$form['value']['#suffix'] = '
';
}
- $process[] = 'views_process_dependency';
$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 8b7352ef3ae754235db33d10fcda823427049434..34aac757ee9f0776011df4e59967d985564439f2 100644
--- a/handlers/views_handler_filter_numeric.inc
+++ b/handlers/views_handler_filter_numeric.inc
@@ -148,8 +148,12 @@ class views_handler_filter_numeric extends views_handler_filter {
'#title' => empty($form_state['exposed']) ? t('Value') : '',
'#size' => 30,
'#default_value' => $this->value['value'],
- '#process' => array('views_process_dependency'),
'#dependency' => array($source => $this->operator_values(1)),
+ '#states' => array(
+ 'visible' => array(
+ ':input:id="' . $source . '"' => array('value' => $this->operator_values(1)),
+ ),
+ ),
);
if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier]['value'])) {
$form_state['input'][$identifier]['value'] = $this->value['value'];
@@ -184,7 +188,6 @@ class views_handler_filter_numeric extends views_handler_filter {
);
if ($which == 'all') {
$dependency = array(
- '#process' => array('views_process_dependency'),
'#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 40d17cd30fc51e232f5e5a02f054267688badf62..3afd41847a8cc27d1e03cd060d11e742545879f2 100644
--- a/handlers/views_handler_filter_string.inc
+++ b/handlers/views_handler_filter_string.inc
@@ -201,7 +201,6 @@ class views_handler_filter_string extends views_handler_filter {
if ($which == 'all') {
$form['value'] += array(
- '#process' => array('views_process_dependency'),
'#dependency' => array($source => $this->operator_values(1)),
);
}
diff --git a/includes/admin.inc b/includes/admin.inc
index 1d8391d1dc6ade906b32438cb285281aea62a3b8..871df3d5e1f5786886089c76810fc601cb6b5937 100644
--- a/includes/admin.inc
+++ b/includes/admin.inc
@@ -1020,7 +1020,6 @@ function views_ui_edit_view_form_delete($form, &$form_state) {
*/
function template_preprocess_views_ui_edit_view(&$vars) {
$view = &$vars['view'];
- views_add_js('dependent');
// The form has to be saved as variable because of strict warnings.
$form = drupal_get_form('views_ui_edit_view_form', $view);
@@ -2432,7 +2431,6 @@ function views_ui_add_item_form($form, &$form_state) {
'#value' => '' . t('There are no @types available to add.', array('@types' => $types[$type]['ltitle'])) . '
',
);
}
- views_add_js('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 56b15a0c9a579fc68e652b505348ec6deb04be81..b3f5d30d341f40379e091397950f6fde8b487b5a 100644
--- a/includes/ajax.inc
+++ b/includes/ajax.inc
@@ -207,7 +207,8 @@ function views_ajax_form_wrapper($form_id, &$form_state) {
),
);
- $output = drupal_render(drupal_build_form($form_id, $form_state));
+ $form = drupal_build_form($form_id, $form_state);
+ $output = drupal_render($form);
// These forms have the title built in, so set the title here:
if (empty($form_state['ajax']) && !empty($form_state['title'])) {
@@ -291,6 +292,60 @@ function views_ajax_autocomplete_user($string = '') {
drupal_json_output($matches);
}
+/**
+ * Page callback for views taxonomy autocomplete.
+ *
+ * @param $vid
+ * The vocabulary id of the tags which should be returned.
+ *
+ * @param $tags_typed
+ * The typed string of the user.
+ *
+ * @see taxonomy_autocomplete()
+ */
+function views_ajax_autocomplete_taxonomy($vid, $tags_typed = '') {
+ // The user enters a comma-separated list of tags. We only autocomplete the last tag.
+ $tags_typed = drupal_explode_tags($tags_typed);
+ $tag_last = drupal_strtolower(array_pop($tags_typed));
+
+ $matches = array();
+ if ($tag_last != '') {
+
+ $query = db_select('taxonomy_term_data', 't');
+ $query->addTag('translatable');
+ $query->addTag('term_access');
+
+ // Do not select already entered terms.
+ if (!empty($tags_typed)) {
+ $query->condition('t.name', $tags_typed, 'NOT IN');
+ }
+ // Select rows that match by term name.
+ $tags_return = $query
+ ->fields('t', array('tid', 'name'))
+ ->condition('t.vid', $vid)
+ ->condition('t.name', '%' . db_like($tag_last) . '%', 'LIKE')
+ ->range(0, 10)
+ ->execute()
+ ->fetchAllKeyed();
+
+ $prefix = count($tags_typed) ? implode(', ', $tags_typed) . ', ' : '';
+
+ $term_matches = array();
+ foreach ($tags_return as $tid => $name) {
+ $n = $name;
+ // Term names containing commas or quotes must be wrapped in quotes.
+ if (strpos($name, ',') !== FALSE || strpos($name, '"') !== FALSE) {
+ $n = '"' . str_replace('"', '""', $name) . '"';
+ }
+ else {
+ $term_matches[$prefix . $n] = check_plain($name);
+ }
+ }
+ }
+
+ drupal_json_output($term_matches);
+}
+
/**
* @}
*/
diff --git a/includes/handlers.inc b/includes/handlers.inc
index 778601b3608b3df6569cd280550e88e3c3b62827..06ccdc732fb6d1c7970564c500eb84f68fd7772a 100644
--- a/includes/handlers.inc
+++ b/includes/handlers.inc
@@ -537,7 +537,7 @@ class views_many_to_one_helper {
$this->handler = &$handler;
}
- function option_definition(&$options) {
+ static function option_definition(&$options) {
$options['reduce_duplicates'] = array('default' => FALSE);
}
diff --git a/includes/plugins.inc b/includes/plugins.inc
index d2c77e7216881fa7492352d3b07c07169b68859c..b7469bf15763c4e01cde1a446a47ddab72146b92 100644
--- a/includes/plugins.inc
+++ b/includes/plugins.inc
@@ -10,7 +10,6 @@
* 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(
@@ -22,7 +21,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', "$js_path/dependent.js"),
+ 'js' => array('misc/collapse.js', 'misc/textarea.js', 'misc/tabledrag.js', 'misc/autocomplete.js', 'misc/states.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 aa6137576ee040e08048df67b5bdd216f31b3697..15e49fb0a60c4db20630d4968738d7498d57fda2 100644
--- a/modules/taxonomy/views_handler_argument_term_node_tid_depth.inc
+++ b/modules/taxonomy/views_handler_argument_term_node_tid_depth.inc
@@ -46,8 +46,11 @@ 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']),
- '#process' => array('views_process_dependency'),
- '#dependency' => array('edit-options-set-breadcrumb' => array(TRUE)),
+ '#states' => array(
+ 'invisible' => array(
+ 'input[name="options[set_breadcrumb]"]' => array('checked' => FALSE),
+ ),
+ ),
);
}
diff --git a/modules/taxonomy/views_handler_field_term_node_tid.inc b/modules/taxonomy/views_handler_field_term_node_tid.inc
index 286f773de47f4cc02ac86a144ee0f7d18aa9f613..06acd554cf0909c1767859c396ab70fbea9084a2 100644
--- a/modules/taxonomy/views_handler_field_term_node_tid.inc
+++ b/modules/taxonomy/views_handler_field_term_node_tid.inc
@@ -65,9 +65,13 @@ 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', 'views_process_dependency'),
- '#dependency' => array('edit-options-limit' => array(TRUE)),
- );
+ '#process' => array('form_process_checkboxes'),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="options[limit]"]' => array('checked' => TRUE),
+ ),
+ ),
+ );
}
/**
diff --git a/modules/taxonomy/views_handler_filter_term_node_tid.inc b/modules/taxonomy/views_handler_filter_term_node_tid.inc
index df23f53ebedf6c9f3942509638b856b51db86d50..09c3a7f7d6ba4fb388d80a1d70592aa4c6b17c52 100644
--- a/modules/taxonomy/views_handler_filter_term_node_tid.inc
+++ b/modules/taxonomy/views_handler_filter_term_node_tid.inc
@@ -73,8 +73,11 @@ 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']),
- '#process' => array('views_process_dependency'),
- '#dependency' => array('radio:options[type]' => array('select')),
+ '#states' => array(
+ 'visible' => array(
+ 'input[name="options[type]' => array('value' => 'select'),
+ ),
+ ),
);
$form['markup_end'] = array(
@@ -113,7 +116,7 @@ class views_handler_filter_term_node_tid extends views_handler_filter_many_to_on
);
if ($this->options['limit']) {
- $form['value']['#autocomplete_path'] = 'taxonomy/autocomplete/' . $vocabulary->vid;
+ $form['value']['#autocomplete_path'] = 'admin/views/ajax/autocomplete/taxonomy/' . $vocabulary->vid;
}
}
else {
diff --git a/modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc b/modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc
index eb341ce3bf59b51af2a6440694e029681e9831f9..64f6c0cbb7e9a133a6ca8c86332f831804cbf6f3 100644
--- a/modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc
+++ b/modules/taxonomy/views_plugin_argument_default_taxonomy_tid.inc
@@ -47,10 +47,7 @@ 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', 'views_process_dependency'),
- '#dependency' => array(
- 'edit-options-argument-default-taxonomy-tid-node' => array(1),
- ),
+ '#process' => array('form_process_checkboxes'),
);
$options = array();
@@ -66,10 +63,11 @@ 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', 'views_process_dependency'),
- '#dependency' => array(
- //'edit-options-argument-default-taxonomy-tid-limit' => array(1),
- 'edit-options-argument-default-taxonomy-tid-node' => array(1),
+ '#process' => array('form_process_checkboxes'),
+ '#states' => array(
+ 'visible' => array(
+ ':input[name="options[argument_default][taxonomy_tid][limit]"]' => array('checked' => TRUE),
+ ),
),
);
}
diff --git a/modules/user/views_handler_field_user_name.inc b/modules/user/views_handler_field_user_name.inc
index f029938e56cfa487ba56a03569e7b200e7431641..3d8023e4824db835cb58fe906f6a68ee8f96d5b2 100644
--- a/modules/user/views_handler_field_user_name.inc
+++ b/modules/user/views_handler_field_user_name.inc
@@ -36,9 +36,10 @@ 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'],
- '#process' => array('views_process_dependency'),
- '#dependency' => array(
- 'edit-options-overwrite-anonymous' => array(1),
+ '#states' => array(
+ 'invisible' => array(
+ 'input[name="options[overwrite_anonymous"]' => array('checked' => FALSE),
+ ),
),
);
}
diff --git a/modules/user/views_plugin_argument_validate_user.inc b/modules/user/views_plugin_argument_validate_user.inc
index 567946211ecefff98f0b78bc7cbdb1b47a4fbe8b..9446f5ef7090c562a98cbdc4bccf498f6557cd8a 100644
--- a/modules/user/views_plugin_argument_validate_user.inc
+++ b/modules/user/views_plugin_argument_validate_user.inc
@@ -44,9 +44,11 @@ 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', 'views_process_dependency'),
- '#dependency' => array(
- 'edit-options-argument-validate-user-restrict-roles' => array(1),
+ '#process' => array('form_process_checkboxes'),
+ '#states' => array(
+ 'invisible' => array(
+ 'input[name="options[argument_validate][user][restrict_roles]"]' => array('checked' => FALSE),
+ ),
),
);
}
diff --git a/plugins/views_plugin_argument_default_php.inc b/plugins/views_plugin_argument_default_php.inc
index 00c3b833ac22b573a0d90528be72e65bbf4a9bce..524f499e06581a15698f46067ce549af8d3eebfa 100644
--- a/plugins/views_plugin_argument_default_php.inc
+++ b/plugins/views_plugin_argument_default_php.inc
@@ -21,7 +21,6 @@ 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('views_process_dependency'),
'#description' => t('Enter PHP code that returns a value to use for this argument. Do not use <?php ?>. You must return only a single value for just this argument.'),
);
diff --git a/plugins/views_plugin_display_feed.inc b/plugins/views_plugin_display_feed.inc
index 5fdf6c87aa18bd45fdca87a66c36cca171db7e56..6be0768e235199d02fd33e490d277577ed2f86aa 100644
--- a/plugins/views_plugin_display_feed.inc
+++ b/plugins/views_plugin_display_feed.inc
@@ -136,8 +136,11 @@ class views_plugin_display_feed extends views_plugin_display_page {
'#default_value' => $this->get_option('sitename_title'),
);
$form['title'] = $title;
- $form['title']['#process'] = array('views_process_dependency');
- $form['title']['#dependency'] = array('edit-sitename-title' => array(FALSE));
+ $form['title']['#states'] = array(
+ 'invisible' => array(
+ 'input[name="sitename_title"]' => array('checked' => TRUE),
+ ),
+ );
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 3cdb8225e3ec2beb68a65229deeffbedc334e268..83483826bdb56a5dd27c5cc2ed6008471310f0ff 100644
--- a/plugins/views_plugin_display_page.inc
+++ b/plugins/views_plugin_display_page.inc
@@ -298,16 +298,24 @@ 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('views_process_dependency'),
'#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('views_process_dependency'),
'#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.
@@ -318,8 +326,12 @@ 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('views_process_dependency'),
'#dependency' => array('radio:menu[type]' => array('normal')),
+ '#states' => array(
+ 'visible' => array(
+ ':radio:menu[type]' => array('value' => array('normal')),
+ ),
+ ),
);
}
else {
@@ -337,8 +349,12 @@ 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('views_process_dependency'),
'#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':
@@ -371,16 +387,24 @@ 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('views_process_dependency'),
'#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('views_process_dependency'),
'#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')) {
@@ -390,8 +414,12 @@ 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('views_process_dependency'),
'#dependency' => array('radio:tab_options[type]' => array('normal')),
+ '#states' => array(
+ 'visible' => array(
+ ':radio:tab_options[type]' => array('value' => array('normal')),
+ ),
+ ),
);
}
else {
@@ -410,8 +438,12 @@ 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('views_process_dependency'),
'#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 76b0527e10befc09923973819180dd86d5197919..80acd6c3572867329c4d39037d853f04e81d885c 100644
--- a/plugins/views_plugin_exposed_form.inc
+++ b/plugins/views_plugin_exposed_form.inc
@@ -62,10 +62,11 @@ 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,
- '#dependency' => array(
- 'edit-exposed-form-options-reset-button' => array(1)
+ '#states' => array(
+ 'invisible' => array(
+ 'input[name="exposed_form_options[reset_button]"]' => array('checked' => FALSE),
+ ),
),
- '#process' => array('views_process_dependency'),
);
$form['exposed_sorts_label'] = array(
diff --git a/plugins/views_plugin_pager_full.inc b/plugins/views_plugin_pager_full.inc
index f75b459c2d289a59c8df12cb7b648d221266b9c9..fb49adbf96ca99b364130c38d651f3acf8873464 100644
--- a/plugins/views_plugin_pager_full.inc
+++ b/plugins/views_plugin_pager_full.inc
@@ -88,9 +88,10 @@ 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'],
- '#process' => array('views_process_dependency'),
- '#dependency' => array(
- 'edit-pager-options-expose-items-per-page' => array(1)
+ '#states' => array(
+ 'invisible' => array(
+ 'input[name="pager_options[expose][items_per_page]"]' => array('checked' => FALSE),
+ ),
),
);
@@ -100,9 +101,10 @@ 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'],
- '#process' => array('views_process_dependency'),
- '#dependency' => array(
- 'edit-pager-options-expose-items-per-page' => array(1)
+ '#states' => array(
+ 'invisible' => array(
+ 'input[name="pager_options[expose][items_per_page]"]' => array('checked' => FALSE),
+ ),
),
);
@@ -119,9 +121,10 @@ 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'],
- '#process' => array('views_process_dependency'),
- '#dependency' => array(
- 'edit-pager-options-expose-offset' => array(1)
+ '#states' => array(
+ 'invisible' => array(
+ 'input[name="pager_options[expose][offset]"]' => array('checked' => FALSE),
+ ),
),
);
}
diff --git a/plugins/views_plugin_style_rss.inc b/plugins/views_plugin_style_rss.inc
index dad3bb93cd49fadf908e27739b01a9d90884bf7b..87435bfd4bbef15eb1191c2322dee9bfc5104542 100644
--- a/plugins/views_plugin_style_rss.inc
+++ b/plugins/views_plugin_style_rss.inc
@@ -62,8 +62,11 @@ 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.'),
- '#process' => array('views_process_dependency'),
- '#dependency' => array('edit-style-options-override' => array(FALSE)),
+ '#states' => array(
+ 'invisible' => array(
+ 'input[name="style_options[override]"]' => array('checked' => FALSE),
+ ),
+ ),
);
}
diff --git a/plugins/views_plugin_style_summary.inc b/plugins/views_plugin_style_summary.inc
index 961dd30d9c5ff12e32a3a967f419ac1601f9c3fc..af94f7ab312e1a00624d0b587a7c88e8579467b4 100644
--- a/plugins/views_plugin_style_summary.inc
+++ b/plugins/views_plugin_style_summary.inc
@@ -53,8 +53,11 @@ class views_plugin_style_summary extends views_plugin_style {
'#type' => 'textfield',
'#title' => t('Items to display'),
'#default_value' => $this->options['items_per_page'],
- '#process' => array('views_process_dependency'),
- '#dependency' => array('edit-style-options-override' => array(TRUE)),
+ '#states' => array(
+ 'invisible' => array(
+ 'input[name="style_options[override]"]' => array('checked' => FALSE),
+ ),
+ ),
);
}
diff --git a/plugins/views_plugin_style_table.inc b/plugins/views_plugin_style_table.inc
index b52b821b6e63e3ba1e00d6df5414603d85de6d42..83c2d20eb2b3f7e068b50baa5f321aab50995627 100644
--- a/plugins/views_plugin_style_table.inc
+++ b/plugins/views_plugin_style_table.inc
@@ -196,8 +196,11 @@ class views_plugin_style_table extends views_plugin_style {
$form['info'][$field]['sortable'] = array(
'#type' => 'checkbox',
'#default_value' => !empty($this->options['info'][$field]['sortable']),
- '#process' => array('views_process_dependency'),
- '#dependency' => array($id => array($field)),
+ '#states' => array(
+ 'visible' => array(
+ ':input[id="' . $id . '"]' => array('value' => $field),
+ ),
+ ),
);
// Provide an ID so we can have such things.
$radio_id = drupal_html_id('edit-default-' . $field);
@@ -209,8 +212,11 @@ class views_plugin_style_table extends views_plugin_style {
// because 'radio' doesn't fully support '#id' =(
'#attributes' => array('id' => $radio_id),
'#default_value' => $default,
- '#process' => array('views_process_dependency'),
- '#dependency' => array($id => array($field)),
+ '#states' => array(
+ 'visible' => array(
+ ':input[id="' . $id . '"]' => array('value' => $field),
+ ),
+ ),
);
}
$form['info'][$field]['align'] = array(
@@ -222,14 +228,12 @@ class views_plugin_style_table extends views_plugin_style {
'views-align-center' => t('Center'),
'views-align-right' => t('Right'),
),
- '#process' => array('views_process_dependency'),
'#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('views_process_dependency'),
'#dependency' => array($id => array($field)),
);
diff --git a/views.module b/views.module
index cdd682d3aee98adb0eb64a4601a769d1871a3b59..b32be677341f1a90401c99a10e2800febed9dac4 100644
--- a/views.module
+++ b/views.module
@@ -193,6 +193,15 @@ function views_menu() {
'type' => MENU_CALLBACK,
'file' => 'includes/ajax.inc',
);
+ // Define another taxonomy autocomplete because the default one of drupal
+ // does not support a vid a argument anymore
+ $items['admin/views/ajax/autocomplete/taxonomy'] = array(
+ 'page callback' => 'views_ajax_autocomplete_taxonomy',
+ 'access callback' => 'user_access',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ 'file' => 'includes/ajax.inc',
+ );
return $items;
}
@@ -1065,7 +1074,6 @@ function views_exposed_form($form, &$form_state) {
if ($view->use_ajax) {
drupal_add_js('misc/jquery.form.js');
}
- views_add_js('dependent');
$exposed_form_plugin = $form_state['exposed_form_plugin'];
$exposed_form_plugin->exposed_form_alter($form, $form_state);
@@ -1376,28 +1384,6 @@ function views_views_exportables($op = 'list', $views = NULL, $name = 'foo') {
}
}
-/**
- * Process callback to add dependency to form items.
- *
- * Usage:
- *
- * On any form item, add
- * - @code '#process' => 'views_process_dependency' @endcode
- * - @code '#dependency' => array('id-of-form-without-the-#' => array(list, of, values, that, make, this, gadget, visible)); @endcode
- */
-function views_process_dependency($element) {
- if (isset($element['#dependency'])) {
- if (!isset($element['#dependency_count'])) {
- $element['#dependency_count'] = 1;
- }
- views_add_js('dependent');
- $options['viewsAjax']['formRelationships'][$element['#id']] = array('num' => $element['#dependency_count'], 'values' => $element['#dependency']);
- drupal_add_js($options, 'setting');
- }
-
- return $element;
-}
-
/**
* #process callback to see if we need to check_plain() the options.
*