Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3443488
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-3443488
Commits
36135952
Commit
36135952
authored
15 years ago
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#603702
by Xano: remove _taxonomy_term_select().
parent
a243e821
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
modules/taxonomy/taxonomy.admin.inc
+15
-1
15 additions, 1 deletion
modules/taxonomy/taxonomy.admin.inc
modules/taxonomy/taxonomy.module
+0
-94
0 additions, 94 deletions
modules/taxonomy/taxonomy.module
modules/taxonomy/taxonomy.test
+2
-2
2 additions, 2 deletions
modules/taxonomy/taxonomy.test
with
17 additions
and
97 deletions
modules/taxonomy/taxonomy.admin.inc
+
15
−
1
View file @
36135952
...
...
@@ -670,7 +670,21 @@ function taxonomy_form_term($form, &$form_state, $vocabulary, $edit = array()) {
}
$exclude
[]
=
$edit
[
'tid'
];
$form
[
'advanced'
][
'parent'
]
=
_taxonomy_term_select
(
t
(
'Parents'
),
$parent
,
$vocabulary
->
vid
,
t
(
'Parent terms'
)
.
'.'
,
'<'
.
t
(
'root'
)
.
'>'
,
$exclude
);
$tree
=
taxonomy_get_tree
(
$vocabulary
->
vid
);
$options
=
array
(
'<'
.
t
(
'root'
)
.
'>'
);
foreach
(
$tree
as
$term
)
{
if
(
!
in_array
(
$term
->
tid
,
$exclude
))
{
$options
[
$term
->
tid
]
=
str_repeat
(
'-'
,
$term
->
depth
)
.
$term
->
name
;
}
}
$form
[
'advanced'
][
'parent'
]
=
array
(
'#type'
=>
'select'
,
'#title'
=>
t
(
'Parent terms'
),
'#options'
=>
$options
,
'#default_value'
=>
$parent
,
'#multiple'
=>
TRUE
,
);
}
$form
[
'advanced'
][
'synonyms'
]
=
array
(
'#type'
=>
'textarea'
,
...
...
This diff is collapsed.
Click to expand it.
modules/taxonomy/taxonomy.module
+
0
−
94
View file @
36135952
...
...
@@ -146,9 +146,6 @@ function taxonomy_field_build_modes($obj_type) {
*/
function
taxonomy_theme
()
{
return
array
(
'taxonomy_term_select'
=>
array
(
'arguments'
=>
array
(
'element'
=>
NULL
),
),
'taxonomy_overview_vocabularies'
=>
array
(
'arguments'
=>
array
(
'form'
=>
array
()),
),
...
...
@@ -575,33 +572,6 @@ function taxonomy_terms_static_reset() {
entity_get_controller
(
'taxonomy_term'
)
->
resetCache
();
}
/**
* Generate a form element for selecting terms from a vocabulary.
*
* @param $vid
* The vocabulary ID to generate a form element for
* @param $value
* The existing value of the term(s) in this vocabulary to use by default.
* @param $help
* Optional help text to use for the form element. If specified, this value
* MUST be properly sanitized and filtered (e.g. with filter_xss_admin() or
* check_plain() if it is user-supplied) to prevent XSS vulnerabilities. If
* omitted, the help text stored with the vocaulary (if any) will be used.
* @return
* An array describing a form element to select terms for a vocabulary.
*
* @see _taxonomy_term_select()
* @see filter_xss_admin()
*/
function
taxonomy_form
(
$vid
,
$value
=
0
,
$help
=
NULL
)
{
$vocabulary
=
taxonomy_vocabulary_load
(
$vid
);
$help
=
(
$help
)
?
$help
:
filter_xss_admin
(
$vocabulary
->
help
);
$blank
=
t
(
'- Please choose -'
);
return
_taxonomy_term_select
(
check_plain
(
$vocabulary
->
name
),
$value
,
$vid
,
$help
,
$blank
);
}
/**
* Generate a set of options for selecting a term from all vocabularies.
*/
...
...
@@ -966,70 +936,6 @@ function taxonomy_term_load($tid) {
return
$term
?
$term
[
$tid
]
:
FALSE
;
}
/**
* Create a select form element for a given taxonomy vocabulary.
*
* NOTE: This function expects input that has already been sanitized and is
* safe for display. Callers must properly sanitize the $title and
* $description arguments to prevent XSS vulnerabilities.
*
* @param $title
* The title of the vocabulary. This MUST be sanitized by the caller.
* @param $value
* The currently selected terms from this vocabulary, if any.
* @param $vocabulary_id
* The vocabulary ID to build the form element for.
* @param $description
* Help text for the form element. This MUST be sanitized by the caller.
* @param $multiple
* Boolean to control if the form should use a single or multiple select.
* @param $blank
* Optional form choice to use when no value has been selected.
* @param $exclude
* Optional array of term ids to exclude in the selector.
* @return
* A FAPI form array to select terms from the given vocabulary.
*
* @see taxonomy_form()
* @see taxonomy_form_term()
*/
function
_taxonomy_term_select
(
$title
,
$value
,
$vocabulary_id
,
$description
,
$blank
,
$exclude
=
array
())
{
$tree
=
taxonomy_get_tree
(
$vocabulary_id
);
$options
=
array
();
if
(
$blank
)
{
$options
[
0
]
=
$blank
;
}
if
(
$tree
)
{
foreach
(
$tree
as
$term
)
{
if
(
!
in_array
(
$term
->
tid
,
$exclude
))
{
$choice
=
new
stdClass
();
$choice
->
option
=
array
(
$term
->
tid
=>
str_repeat
(
'-'
,
$term
->
depth
)
.
$term
->
name
);
$options
[]
=
$choice
;
}
}
}
return
array
(
'#type'
=>
'select'
,
'#title'
=>
$title
,
'#default_value'
=>
$value
,
'#options'
=>
$options
,
'#description'
=>
$description
,
'#weight'
=>
-
15
,
'#theme'
=>
'taxonomy_term_select'
,
);
}
/**
* Format the selection field for choosing terms
* (by default the default selection field is used).
*
* @ingroup themeable
*/
function
theme_taxonomy_term_select
(
$variables
)
{
return
theme
(
'select'
,
$variables
[
'element'
]);
}
/**
* Implement hook_help().
*/
...
...
This diff is collapsed.
Click to expand it.
modules/taxonomy/taxonomy.test
+
2
−
2
View file @
36135952
...
...
@@ -367,7 +367,7 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
// Edit $term2, setting $term1 as parent.
$edit
=
array
();
$edit
[
'parent'
]
=
$term1
->
tid
;
$edit
[
'parent
[]
'
]
=
array
(
$term1
->
tid
)
;
$this
->
drupalPost
(
'taxonomy/term/'
.
$term2
->
tid
.
'/edit'
,
$edit
,
t
(
'Save'
));
// Check the hierarchy.
...
...
@@ -454,7 +454,7 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
);
// Explicitly set the parents field to 'root', to ensure that
// taxonomy_form_term_submit() handles the invalid term ID correctly.
$edit
[
'parent'
]
=
0
;
$edit
[
'parent
[]
'
]
=
array
(
0
)
;
// Create the term to edit.
$this
->
drupalPost
(
'admin/structure/taxonomy/'
.
$this
->
vocabulary
->
vid
.
'/list/add'
,
$edit
,
t
(
'Save'
));
...
...
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