Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3485117
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-3485117
Commits
7e367707
Commit
7e367707
authored
12 years ago
by
Alasdair Cowie-Fraser
Committed by
Tim Plunkett
12 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#1757050
by ACF | damiankloip: Replace calls to term->tid with term->id().
parent
068f1468
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/Views/taxonomy/Plugin/views/argument_validator/Term.php
+22
-48
22 additions, 48 deletions
lib/Views/taxonomy/Plugin/views/argument_validator/Term.php
with
22 additions
and
48 deletions
lib/Views/taxonomy/Plugin/views/argument_validat
e
/Term.php
→
lib/Views/taxonomy/Plugin/views/argument_validat
or
/Term.php
+
22
−
48
View file @
7e367707
...
...
@@ -2,7 +2,7 @@
/**
* @file
* Defintion of Views\taxonomy\Plugin\views\argument_validat
e
\Term.
* Defin
i
tion of Views\taxonomy\Plugin\views\argument_validat
or
\Term.
*/
...
...
@@ -19,6 +19,7 @@
* id = "taxonomy_term",
* module = "taxonomy",
* title = @Translation("Taxonomy term")
* )
*/
class
Term
extends
ArgumentValidatorPluginBase
{
...
...
@@ -97,19 +98,14 @@ function validate_argument($argument) {
if
(
!
is_numeric
(
$argument
))
{
return
FALSE
;
}
$query
=
db_select
(
'taxonomy_term_data'
,
'td'
);
$query
->
leftJoin
(
'taxonomy_vocabulary'
,
'tv'
,
'td.vid = tv.vid'
);
$query
->
fields
(
'td'
);
$query
->
fields
(
'tv'
,
array
(
'machine_name'
));
$query
->
condition
(
'td.tid'
,
$argument
);
$query
->
addTag
(
'term_access'
);
$term
=
$query
->
execute
()
->
fetchObject
();
// @todo Deal with missing addTag('term access') that was removed when
// the db_select that was replaced by the entity_load.
$term
=
entity_load
(
'taxonomy_term'
,
$argument
);
if
(
!
$term
)
{
return
FALSE
;
}
$this
->
argument
->
validated_title
=
check_plain
(
$term
->
name
);
return
empty
(
$vocabularies
)
||
!
empty
(
$vocabularies
[
$term
->
machine_name
]);
return
empty
(
$vocabularies
)
||
!
empty
(
$vocabularies
[
$term
->
vocabulary_
machine_name
]);
case
'tids'
:
// An empty argument is not a term so doesn't pass.
...
...
@@ -143,22 +139,15 @@ function validate_argument($argument) {
// if unverified tids left - verify them and cache results
if
(
count
(
$test
))
{
$query
=
db_select
(
'taxonomy_term_data'
,
'td'
);
$query
->
leftJoin
(
'taxonomy_vocabulary'
,
'tv'
,
'td.vid = tv.vid'
);
$query
->
fields
(
'td'
);
$query
->
fields
(
'tv'
,
array
(
'machine_name'
));
$query
->
condition
(
'td.tid'
,
$test
);
$result
=
$query
->
execute
();
$result
=
entity_load_multiple
(
'taxonomy_term'
,
$test
);
foreach
(
$result
as
$term
)
{
if
(
$vocabularies
&&
empty
(
$vocabularies
[
$term
->
machine_name
]))
{
$validated_cache
[
$term
->
t
id
]
=
FALSE
;
if
(
$vocabularies
&&
empty
(
$vocabularies
[
$term
->
vocabulary_
machine_name
]))
{
$validated_cache
[
$term
->
id
()
]
=
FALSE
;
return
FALSE
;
}
$titles
[]
=
$validated_cache
[
$term
->
t
id
]
=
check_plain
(
$term
->
name
);
unset
(
$test
[
$term
->
t
id
]);
$titles
[]
=
$validated_cache
[
$term
->
id
()
]
=
check_plain
(
$term
->
name
);
unset
(
$test
[
$term
->
id
()
]);
}
}
...
...
@@ -171,24 +160,15 @@ function validate_argument($argument) {
case
'name'
:
case
'convert'
:
$query
=
db_select
(
'taxonomy_term_data'
,
'td'
);
$query
->
leftJoin
(
'taxonomy_vocabulary'
,
'tv'
,
'td.vid = tv.vid'
);
$query
->
fields
(
'td'
);
$query
->
fields
(
'tv'
,
array
(
'machine_name'
));
if
(
!
empty
(
$vocabularies
))
{
$query
->
condition
(
'tv.machine_name'
,
$vocabularies
);
}
$terms
=
entity_load_multiple_by_properties
(
'taxonomy_term'
,
array
(
'name'
=>
$argument
));
$term
=
reset
(
$terms
);
if
(
$transform
)
{
$query
->
where
(
"replace(td.name, ' ', '-') = :name"
,
array
(
':name'
=>
$argument
));
}
else
{
$query
->
condition
(
'td.name'
,
$argument
);
$term
->
name
=
str_replace
(
' '
,
'-'
,
$term
->
name
);
}
$term
=
$query
->
execute
()
->
fetchObject
();
if
(
$term
&&
(
empty
(
$vocabularies
)
||
!
empty
(
$vocabularies
[
$term
->
machine_name
])))
{
if
(
$term
&&
(
empty
(
$vocabularies
)
||
!
empty
(
$vocabularies
[
$term
->
vocabulary_
machine_name
])))
{
if
(
$type
==
'convert'
)
{
$this
->
argument
->
argument
=
$term
->
t
id
;
$this
->
argument
->
argument
=
$term
->
id
()
;
}
$this
->
argument
->
validated_title
=
check_plain
(
$term
->
name
);
return
TRUE
;
...
...
@@ -205,21 +185,15 @@ function process_summary_arguments(&$args) {
if
(
$type
==
'convert'
)
{
$arg_keys
=
array_flip
(
$args
);
$query
=
db_select
(
'taxonomy_term_data'
,
'td'
);
$query
->
condition
(
'tid'
,
$args
);
$query
->
addField
(
'td'
,
'tid'
,
'tid'
);
if
(
!
empty
(
$vocabularies
))
{
$query
->
leftJoin
(
'taxonomy_vocabulary'
,
'tv'
,
'td.vid = tv.vid'
);
$query
->
condition
(
'tv.machine_name'
,
$vocabularies
);
}
$result
=
entity_load_multiple
(
'taxonomy_term'
,
$args
);
if
(
$transform
)
{
$query
->
addExpression
(
"REPLACE(td.name, ' ', '-')"
,
'name'
);
}
else
{
$query
->
addField
(
'td'
,
'name'
,
'name'
);
foreach
(
$result
as
$term
)
{
$term
->
name
=
str_replace
(
' '
,
'-'
,
$term
->
name
);
}
}
foreach
(
$
query
->
execute
()
->
fetchAllKeyed
()
as
$tid
=>
$term
)
{
foreach
(
$
result
as
$tid
=>
$term
)
{
$args
[
$arg_keys
[
$tid
]]
=
$term
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment