Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
36df8e87
Commit
36df8e87
authored
Jun 21, 2013
by
Dries Buytaert
Browse files
Issue
#2024111
by damiankloip: Fixed TaxonomyIndexTid filter handler autocomplete does not work.
parent
0a0942a0
Changes
4
Hide whitespace changes
Inline
Side-by-side
core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/views/filter/TaxonomyIndexTid.php
View file @
36df8e87
...
...
@@ -11,6 +11,7 @@
use
Drupal\views\Plugin\views\display\DisplayPluginBase
;
use
Drupal\Component\Annotation\PluginID
;
use
Drupal\views\Plugin\views\filter\ManyToOne
;
use
Drupal\Component\Utility\Tags
;
/**
* Filter by term id.
...
...
@@ -217,7 +218,7 @@ protected function valueValidate($form, &$form_state) {
return
;
}
$values
=
drupal_
explode
_tags
(
$form_state
[
'values'
][
'options'
][
'value'
]);
$values
=
Tags
::
explode
(
$form_state
[
'values'
][
'options'
][
'value'
]);
$tids
=
$this
->
validate_term_strings
(
$form
[
'value'
],
$values
);
if
(
$tids
)
{
...
...
@@ -271,7 +272,7 @@ public function validateExposed(&$form, &$form_state) {
return
;
}
$values
=
drupal_
explode
_tags
(
$form_state
[
'values'
][
$identifier
]);
$values
=
Tags
::
explode
(
$form_state
[
'values'
][
$identifier
]);
$tids
=
$this
->
validate_term_strings
(
$form
[
$identifier
],
$values
);
if
(
$tids
)
{
...
...
core/modules/views/includes/ajax.inc
View file @
36df8e87
...
...
@@ -12,6 +12,9 @@
use
Drupal\views\Ajax\ScrollTopCommand
;
use
Drupal\views\Ajax\ViewAjaxResponse
;
use
Drupal\Core\Ajax\AjaxResponse
;
use
Drupal\Component\Utility\Tags
;
use
Drupal\Component\Utility\Unicode
;
use
Drupal\Component\Utility\String
;
/**
* @defgroup views_ajax Views AJAX library
...
...
@@ -153,13 +156,13 @@ function views_ajax_form_wrapper($form_id, &$form_state) {
* @see taxonomy_autocomplete()
*/
function
views_ajax_autocomplete_taxonomy
(
$vid
)
{
// The user enters a comma-separated list of tags. We only autocomplete the last tag.
$tags_typed
=
drupal_explode_tags
(
drupal_container
()
->
get
(
'request'
)
->
query
->
get
(
'q'
));
$tag_last
=
drupal_strtolower
(
array_pop
(
$tags_typed
));
// The user enters a comma-separated list of tags. We only autocomplete the
// last tag.
$tags_typed
=
Tags
::
explode
(
Drupal
::
request
()
->
query
->
get
(
'q'
));
$tag_last
=
Unicode
::
strtolower
(
array_pop
(
$tags_typed
));
$term_matches
=
array
();
$matches
=
array
();
if
(
$tag_last
!=
''
)
{
$query
=
db_select
(
'taxonomy_term_data'
,
't'
);
$query
->
addTag
(
'term_access'
);
...
...
@@ -176,9 +179,8 @@ function views_ajax_autocomplete_taxonomy($vid) {
->
execute
()
->
fetchAllKeyed
();
$prefix
=
count
(
$tags_typed
)
?
drupal_
implode
_tags
(
$tags_typed
)
.
', '
:
''
;
$prefix
=
count
(
$tags_typed
)
?
Tags
::
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.
...
...
@@ -186,7 +188,7 @@ function views_ajax_autocomplete_taxonomy($vid) {
$n
=
'"'
.
str_replace
(
'"'
,
'""'
,
$name
)
.
'"'
;
}
// Add term name to list of matches.
$term_matches
[
$prefix
.
$n
]
=
check
_p
lain
(
$name
);
$term_matches
[
$prefix
.
$n
]
=
String
::
check
P
lain
(
$name
);
}
}
...
...
core/modules/views/lib/Drupal/views/Tests/ViewsTaxonomyAutocompleteTest.php
0 → 100644
View file @
36df8e87
<?php
/**
* @file
* Contains \Drupal\views\Tests\ViewsTaxonomyAutocompleteTest.
*/
namespace
Drupal\views\Tests
;
use
Drupal\taxonomy\Tests\Views\TaxonomyTestBase
;
use
Drupal\Component\Utility\MapArray
;
/**
* Tests the views taxonomy complete menu callback.
*
* @see views_ajax_autocomplete_taxonomy()
*/
class
ViewsTaxonomyAutocompleteTest
extends
TaxonomyTestBase
{
/**
* Modules to enable.
*
* @var array
*/
public
static
$modules
=
array
(
'views'
);
public
static
function
getInfo
()
{
return
array
(
'name'
=>
'View taxonomy autocomplete'
,
'description'
=>
'Tests the view taxonomy autocomplete AJAX callback.'
,
'group'
=>
'Views'
);
}
/**
* Tests the views_ajax_autocomplete_taxonomy() AJAX callback.
*/
public
function
testTaxonomyAutocomplete
()
{
$this
->
user
=
$this
->
drupalCreateUser
(
array
(
'access content'
));
$this
->
drupalLogin
(
$this
->
user
);
$base_autocomplete_path
=
'admin/views/ajax/autocomplete/taxonomy/'
.
$this
->
vocabulary
->
vid
;
// Test that no terms returns an empty array.
$this
->
assertIdentical
(
array
(),
$this
->
drupalGetJSON
(
$base_autocomplete_path
));
// Test a with whole name term.
$label
=
$this
->
term1
->
label
();
$expected
=
MapArray
::
copyValuesToKeys
((
array
)
$label
);
$this
->
assertIdentical
(
$expected
,
$this
->
drupalGetJSON
(
$base_autocomplete_path
,
array
(
'query'
=>
array
(
'q'
=>
$label
))));
// Test a term by partial name.
$partial
=
substr
(
$label
,
0
,
2
);
$this
->
assertIdentical
(
$expected
,
$this
->
drupalGetJSON
(
$base_autocomplete_path
,
array
(
'query'
=>
array
(
'q'
=>
$partial
))));
}
}
core/modules/views/views.module
View file @
36df8e87
...
...
@@ -308,6 +308,7 @@ function views_menu() {
// does not support a vid a argument anymore
$items
[
'admin/views/ajax/autocomplete/taxonomy/%'
]
=
array
(
'page callback'
=>
'views_ajax_autocomplete_taxonomy'
,
'page arguments'
=>
array
(
5
),
'theme callback'
=>
'ajax_base_page_theme'
,
'access callback'
=>
'user_access'
,
'access arguments'
=>
array
(
'access content'
),
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment