summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcatch2012-01-18 03:37:45 (GMT)
committercatch2012-01-18 03:37:45 (GMT)
commit2cc7d45de1c2545afd3804879ac6c692c14ed9d7 (patch)
tree1d41aec14181f1309eeeb441054a2dc62d71e1b8
parent2901333da228387e83d212230a1b791f26a0f12c (diff)
Issue #1377628 by chris.leversuch: taxonomy_get_term_by_name() should be taxonomy_term_load_multiple_by_name().
-rw-r--r--core/modules/forum/forum.admin.inc2
-rw-r--r--core/modules/forum/forum.module4
-rw-r--r--core/modules/taxonomy/taxonomy.admin.inc8
-rw-r--r--core/modules/taxonomy/taxonomy.module38
-rw-r--r--core/modules/taxonomy/taxonomy.pages.inc2
-rw-r--r--core/modules/taxonomy/taxonomy.test64
-rw-r--r--core/modules/taxonomy/taxonomy.tokens.inc4
7 files changed, 56 insertions, 66 deletions
diff --git a/core/modules/forum/forum.admin.inc b/core/modules/forum/forum.admin.inc
index 49c71d9..a9a2dd9 100644
--- a/core/modules/forum/forum.admin.inc
+++ b/core/modules/forum/forum.admin.inc
@@ -275,7 +275,7 @@ function forum_overview($form, &$form_state) {
*/
function _forum_parent_select($tid, $title, $child_type) {
- $parents = taxonomy_get_parents($tid);
+ $parents = taxonomy_term_load_parents($tid);
if ($parents) {
$parent = array_shift($parents);
$parent = $parent->tid;
diff --git a/core/modules/forum/forum.module b/core/modules/forum/forum.module
index 90b1f89..b334c42 100644
--- a/core/modules/forum/forum.module
+++ b/core/modules/forum/forum.module
@@ -268,7 +268,7 @@ function forum_node_view($node, $view_mode) {
// Breadcrumb navigation
$breadcrumb[] = l(t('Home'), NULL);
$breadcrumb[] = l($vocabulary->name, 'forum');
- if ($parents = taxonomy_get_parents_all($node->forum_tid)) {
+ if ($parents = taxonomy_term_load_parents_all($node->forum_tid)) {
$parents = array_reverse($parents);
foreach ($parents as $parent) {
$breadcrumb[] = l($parent->name, 'forum/' . $parent->tid);
@@ -765,7 +765,7 @@ function forum_forum_load($tid = NULL) {
}
// Load parent terms.
- $forum_term->parents = taxonomy_get_parents_all($forum_term->tid);
+ $forum_term->parents = taxonomy_term_load_parents_all($forum_term->tid);
// Load the tree below.
$forums = array();
diff --git a/core/modules/taxonomy/taxonomy.admin.inc b/core/modules/taxonomy/taxonomy.admin.inc
index 8541b78..bfb4c11 100644
--- a/core/modules/taxonomy/taxonomy.admin.inc
+++ b/core/modules/taxonomy/taxonomy.admin.inc
@@ -13,7 +13,7 @@
* @see theme_taxonomy_overview_vocabularies()
*/
function taxonomy_overview_vocabularies($form) {
- $vocabularies = taxonomy_get_vocabularies();
+ $vocabularies = taxonomy_vocabulary_load_multiple(FALSE);
$form['#tree'] = TRUE;
foreach ($vocabularies as $vocabulary) {
$form[$vocabulary->vid]['#vocabulary'] = $vocabulary;
@@ -666,7 +666,7 @@ function taxonomy_form_term($form, &$form_state, $edit = array(), $vocabulary =
}
}
- $parent = array_keys(taxonomy_get_parents($term->tid));
+ $parent = array_keys(taxonomy_term_load_parents($term->tid));
$form['#term'] = (array) $term;
$form['#term']['parent'] = $parent;
$form['#vocabulary'] = $vocabulary;
@@ -707,12 +707,12 @@ function taxonomy_form_term($form, &$form_state, $edit = array(), $vocabulary =
'#weight' => 10,
);
- // taxonomy_get_tree and taxonomy_get_parents may contain large numbers of
+ // taxonomy_get_tree and taxonomy_term_load_parents may contain large numbers of
// items so we check for taxonomy_override_selector before loading the
// full vocabulary. Contrib modules can then intercept before
// hook_form_alter to provide scalable alternatives.
if (!variable_get('taxonomy_override_selector', FALSE)) {
- $parent = array_keys(taxonomy_get_parents($term->tid));
+ $parent = array_keys(taxonomy_term_load_parents($term->tid));
$children = taxonomy_get_tree($vocabulary->vid, $term->tid);
// A term can't be the child of itself, nor of its children.
diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module
index 3f56e9e..338638f 100644
--- a/core/modules/taxonomy/taxonomy.module
+++ b/core/modules/taxonomy/taxonomy.module
@@ -85,7 +85,7 @@ function taxonomy_permission() {
'title' => t('Administer vocabularies and terms'),
),
);
- foreach (taxonomy_get_vocabularies() as $vocabulary) {
+ foreach (taxonomy_vocabulary_load_multiple(FALSE) as $vocabulary) {
$permissions += array(
'edit terms in ' . $vocabulary->vid => array(
'title' => t('Edit terms in %vocabulary', array('%vocabulary' => $vocabulary->name)),
@@ -705,10 +705,10 @@ function taxonomy_term_delete($tid) {
}
// See if any of the term's children are about to be become orphans:
- if ($children = taxonomy_get_children($tid)) {
+ if ($children = taxonomy_term_load_children($tid)) {
foreach ($children as $child) {
// If the term has multiple parents, we don't delete it.
- $parents = taxonomy_get_parents($child->tid);
+ $parents = taxonomy_term_load_parents($child->tid);
if (count($parents) == 1) {
$orphans[] = $child->tid;
}
@@ -848,9 +848,9 @@ function taxonomy_terms_static_reset() {
drupal_static_reset('taxonomy_get_tree');
drupal_static_reset('taxonomy_get_tree:parents');
drupal_static_reset('taxonomy_get_tree:terms');
- drupal_static_reset('taxonomy_get_parents');
- drupal_static_reset('taxonomy_get_parents_all');
- drupal_static_reset('taxonomy_get_children');
+ drupal_static_reset('taxonomy_term_load_parents');
+ drupal_static_reset('taxonomy_term_load_parents_all');
+ drupal_static_reset('taxonomy_term_load_children');
entity_get_controller('taxonomy_term')->resetCache();
}
@@ -866,16 +866,6 @@ function taxonomy_vocabulary_static_reset($ids = NULL) {
}
/**
- * Return an array of all vocabulary objects.
- *
- * @return
- * An array of all vocabulary objects, indexed by vid.
- */
-function taxonomy_get_vocabularies() {
- return taxonomy_vocabulary_load_multiple(FALSE, array());
-}
-
-/**
* Get names for all taxonomy vocabularies.
*
* @return
@@ -901,7 +891,7 @@ function taxonomy_vocabulary_get_names() {
* An array of term objects which are the parents of the term $tid, or an
* empty array if parents are not found.
*/
-function taxonomy_get_parents($tid) {
+function taxonomy_term_load_parents($tid) {
$parents = &drupal_static(__FUNCTION__, array());
if ($tid && !isset($parents[$tid])) {
@@ -922,7 +912,7 @@ function taxonomy_get_parents($tid) {
/**
* Find all ancestors of a given term ID.
*/
-function taxonomy_get_parents_all($tid) {
+function taxonomy_term_load_parents_all($tid) {
$cache = &drupal_static(__FUNCTION__, array());
if (isset($cache[$tid])) {
@@ -933,7 +923,7 @@ function taxonomy_get_parents_all($tid) {
if ($term = taxonomy_term_load($tid)) {
$parents[] = $term;
$n = 0;
- while ($parent = taxonomy_get_parents($parents[$n]->tid)) {
+ while ($parent = taxonomy_term_load_parents($parents[$n]->tid)) {
$parents = array_merge($parents, $parent);
$n++;
}
@@ -956,7 +946,7 @@ function taxonomy_get_parents_all($tid) {
* An array of term objects that are the children of the term $tid, or an
* empty array when no children exist.
*/
-function taxonomy_get_children($tid, $vid = 0) {
+function taxonomy_term_load_children($tid, $vid = 0) {
$children = &drupal_static(__FUNCTION__, array());
if ($tid && !isset($children[$tid])) {
@@ -1109,7 +1099,7 @@ function taxonomy_get_tree($vid, $parent = 0, $max_depth = NULL, $load_entities
* @return
* An array of matching term objects.
*/
-function taxonomy_get_term_by_name($name, $vocabulary = NULL) {
+function taxonomy_term_load_multiple_by_name($name, $vocabulary = NULL) {
$conditions = array('name' => trim($name));
if (isset($vocabulary)) {
$vocabularies = taxonomy_vocabulary_get_names();
@@ -1418,9 +1408,9 @@ function taxonomy_field_validate($entity_type, $entity, $field, $instance, $lang
}
}
// If a parent is specified, then to validate it must appear in the
- // array returned by taxonomy_get_parents_all().
+ // array returned by taxonomy_term_load_parents_all().
elseif (!empty($settings['parent'])) {
- $ancestors = taxonomy_get_parents_all($item['tid']);
+ $ancestors = taxonomy_term_load_parents_all($item['tid']);
foreach ($ancestors as $ancestor) {
if ($ancestor->tid == $settings['parent']) {
$validate = TRUE;
@@ -1668,7 +1658,7 @@ function taxonomy_field_widget_error($element, $error, $form, &$form_state) {
*/
function taxonomy_field_settings_form($field, $instance, $has_data) {
// Get proper values for 'allowed_values_function', which is a core setting.
- $vocabularies = taxonomy_get_vocabularies();
+ $vocabularies = taxonomy_vocabulary_load_multiple(FALSE);
$options = array();
foreach ($vocabularies as $vocabulary) {
$options[$vocabulary->machine_name] = $vocabulary->name;
diff --git a/core/modules/taxonomy/taxonomy.pages.inc b/core/modules/taxonomy/taxonomy.pages.inc
index 2630413..aeb12d7 100644
--- a/core/modules/taxonomy/taxonomy.pages.inc
+++ b/core/modules/taxonomy/taxonomy.pages.inc
@@ -24,7 +24,7 @@ function taxonomy_term_page($term) {
// @todo This overrides any other possible breadcrumb and is a pure hard-coded
// presumption. Make this behavior configurable per vocabulary or term.
$breadcrumb = array();
- while ($parents = taxonomy_get_parents($current->tid)) {
+ while ($parents = taxonomy_term_load_parents($current->tid)) {
$current = array_shift($parents);
$breadcrumb[] = l($current->name, 'taxonomy/term/' . $current->tid);
}
diff --git a/core/modules/taxonomy/taxonomy.test b/core/modules/taxonomy/taxonomy.test
index b992903..a7f7bd9 100644
--- a/core/modules/taxonomy/taxonomy.test
+++ b/core/modules/taxonomy/taxonomy.test
@@ -108,7 +108,7 @@ class TaxonomyVocabularyFunctionalTest extends TaxonomyWebTestCase {
$this->createVocabulary();
}
// Get all vocabularies and change their weights.
- $vocabularies = taxonomy_get_vocabularies();
+ $vocabularies = taxonomy_vocabulary_load_multiple(FALSE);
$edit = array();
foreach ($vocabularies as $key => $vocabulary) {
$vocabulary->weight = -$vocabulary->weight;
@@ -119,7 +119,7 @@ class TaxonomyVocabularyFunctionalTest extends TaxonomyWebTestCase {
$this->drupalPost('admin/structure/taxonomy', $edit, t('Save'));
// Load the vocabularies from the database.
- $new_vocabularies = taxonomy_get_vocabularies();
+ $new_vocabularies = taxonomy_vocabulary_load_multiple(FALSE);
// Check that the weights are saved in the database correctly.
foreach ($vocabularies as $key => $vocabulary) {
@@ -132,12 +132,12 @@ class TaxonomyVocabularyFunctionalTest extends TaxonomyWebTestCase {
*/
function testTaxonomyAdminNoVocabularies() {
// Delete all vocabularies.
- $vocabularies = taxonomy_get_vocabularies();
+ $vocabularies = taxonomy_vocabulary_load_multiple(FALSE);
foreach ($vocabularies as $key => $vocabulary) {
taxonomy_vocabulary_delete($key);
}
// Confirm that no vocabularies are found in the database.
- $this->assertFalse(taxonomy_get_vocabularies(), t('No vocabularies found in the database'));
+ $this->assertFalse(taxonomy_vocabulary_load_multiple(FALSE), t('No vocabularies found in the database'));
$this->drupalGet('admin/structure/taxonomy');
// Check the default message for no vocabularies.
$this->assertText(t('No vocabularies available.'), t('No vocabularies were found.'));
@@ -156,7 +156,7 @@ class TaxonomyVocabularyFunctionalTest extends TaxonomyWebTestCase {
$this->assertText(t('Created new vocabulary'), t('New vocabulary was created.'));
// Check the created vocabulary.
- $vocabularies = taxonomy_get_vocabularies();
+ $vocabularies = taxonomy_vocabulary_load_multiple(FALSE);
$vid = $vocabularies[count($vocabularies)-1]->vid;
entity_get_controller('taxonomy_vocabulary')->resetCache();
$vocabulary = taxonomy_vocabulary_load($vid);
@@ -203,7 +203,7 @@ class TaxonomyVocabularyUnitTest extends TaxonomyWebTestCase {
*/
function testTaxonomyVocabularyLoadReturnFalse() {
// Load a vocabulary that doesn't exist.
- $vocabularies = taxonomy_get_vocabularies();
+ $vocabularies = taxonomy_vocabulary_load_multiple(FALSE);
$vid = count($vocabularies) + 1;
$vocabulary = taxonomy_vocabulary_load($vid);
// This should not return an object because no such vocabulary exists.
@@ -223,7 +223,7 @@ class TaxonomyVocabularyUnitTest extends TaxonomyWebTestCase {
*/
function testTaxonomyVocabularyDeleteWithTerms() {
// Delete any existing vocabularies.
- foreach (taxonomy_get_vocabularies() as $vocabulary) {
+ foreach (taxonomy_vocabulary_load_multiple(FALSE) as $vocabulary) {
taxonomy_vocabulary_delete($vocabulary->vid);
}
@@ -273,7 +273,7 @@ class TaxonomyVocabularyUnitTest extends TaxonomyWebTestCase {
// Delete the vocabulary.
taxonomy_vocabulary_delete($this->vocabulary->vid);
- $vocabularies = taxonomy_get_vocabularies();
+ $vocabularies = taxonomy_vocabulary_load_multiple(FALSE);
$this->assertTrue(!isset($vocabularies[$this->vocabulary->vid]), t('The vocabulary was deleted'));
}
@@ -283,7 +283,7 @@ class TaxonomyVocabularyUnitTest extends TaxonomyWebTestCase {
function testTaxonomyVocabularyLoadMultiple() {
// Delete any existing vocabularies.
- foreach (taxonomy_get_vocabularies() as $vocabulary) {
+ foreach (taxonomy_vocabulary_load_multiple(FALSE) as $vocabulary) {
taxonomy_vocabulary_delete($vocabulary->vid);
}
@@ -303,9 +303,9 @@ class TaxonomyVocabularyUnitTest extends TaxonomyWebTestCase {
$names = taxonomy_vocabulary_get_names();
$this->assertEqual($names[$vocabulary1->machine_name]->name, $vocabulary1->name, t('Vocabulary 1 name found.'));
- // Fetch all of the vocabularies using taxonomy_get_vocabularies().
+ // Fetch all of the vocabularies using taxonomy_vocabulary_load_multiple(FALSE).
// Confirm that the vocabularies are ordered by weight.
- $vocabularies = taxonomy_get_vocabularies();
+ $vocabularies = taxonomy_vocabulary_load_multiple(FALSE);
$this->assertEqual(array_shift($vocabularies)->vid, $vocabulary1->vid, t('Vocabulary was found in the vocabularies array.'));
$this->assertEqual(array_shift($vocabularies)->vid, $vocabulary2->vid, t('Vocabulary was found in the vocabularies array.'));
$this->assertEqual(array_shift($vocabularies)->vid, $vocabulary3->vid, t('Vocabulary was found in the vocabularies array.'));
@@ -519,22 +519,22 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
$this->drupalPost('taxonomy/term/' . $term2->tid . '/edit', $edit, t('Save'));
// Check the hierarchy.
- $children = taxonomy_get_children($term1->tid);
- $parents = taxonomy_get_parents($term2->tid);
+ $children = taxonomy_term_load_children($term1->tid);
+ $parents = taxonomy_term_load_parents($term2->tid);
$this->assertTrue(isset($children[$term2->tid]), t('Child found correctly.'));
$this->assertTrue(isset($parents[$term1->tid]), t('Parent found correctly.'));
// Load and save a term, confirming that parents are still set.
$term = taxonomy_term_load($term2->tid);
taxonomy_term_save($term);
- $parents = taxonomy_get_parents($term2->tid);
+ $parents = taxonomy_term_load_parents($term2->tid);
$this->assertTrue(isset($parents[$term1->tid]), t('Parent found correctly.'));
// Create a third term and save this as a parent of term2.
$term3 = $this->createTerm($this->vocabulary);
$term2->parent = array($term1->tid, $term3->tid);
taxonomy_term_save($term2);
- $parents = taxonomy_get_parents($term2->tid);
+ $parents = taxonomy_term_load_parents($term2->tid);
$this->assertTrue(isset($parents[$term1->tid]) && isset($parents[$term3->tid]), t('Both parents found successfully.'));
}
@@ -619,7 +619,7 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
// Get the created terms.
$term_objects = array();
foreach ($terms as $key => $term) {
- $term_objects[$key] = taxonomy_get_term_by_name($term);
+ $term_objects[$key] = taxonomy_term_load_multiple_by_name($term);
$term_objects[$key] = reset($term_objects[$key]);
}
@@ -665,7 +665,7 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
// Create the term to edit.
$this->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->machine_name . '/add', $edit, t('Save'));
- $terms = taxonomy_get_term_by_name($edit['name']);
+ $terms = taxonomy_term_load_multiple_by_name($edit['name']);
$term = reset($terms);
$this->assertNotNull($term, t('Term found in database'));
@@ -798,46 +798,46 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
$this->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->machine_name . '/add', $edit, t('Save'));
// Check that the term was successfully created.
- $terms = taxonomy_get_term_by_name($edit['name']);
+ $terms = taxonomy_term_load_multiple_by_name($edit['name']);
$term = reset($terms);
$this->assertNotNull($term, t('Term found in database'));
$this->assertEqual($edit['name'], $term->name, t('Term name was successfully saved.'));
$this->assertEqual($edit['description[value]'], $term->description, t('Term description was successfully saved.'));
// Check that the parent tid is still there. The other parent (<root>) is
- // not added by taxonomy_get_parents().
- $parents = taxonomy_get_parents($term->tid);
+ // not added by taxonomy_term_load_parents().
+ $parents = taxonomy_term_load_parents($term->tid);
$parent = reset($parents);
$this->assertEqual($edit['parent[]'][1], $parent->tid, t('Term parents were successfully saved.'));
}
/**
- * Test taxonomy_get_term_by_name().
+ * Test taxonomy_term_load_multiple_by_name().
*/
function testTaxonomyGetTermByName() {
$term = $this->createTerm($this->vocabulary);
// Load the term with the exact name.
- $terms = taxonomy_get_term_by_name($term->name);
+ $terms = taxonomy_term_load_multiple_by_name($term->name);
$this->assertTrue(isset($terms[$term->tid]), t('Term loaded using exact name.'));
// Load the term with space concatenated.
- $terms = taxonomy_get_term_by_name(' ' . $term->name . ' ');
+ $terms = taxonomy_term_load_multiple_by_name(' ' . $term->name . ' ');
$this->assertTrue(isset($terms[$term->tid]), t('Term loaded with extra whitespace.'));
// Load the term with name uppercased.
- $terms = taxonomy_get_term_by_name(strtoupper($term->name));
+ $terms = taxonomy_term_load_multiple_by_name(strtoupper($term->name));
$this->assertTrue(isset($terms[$term->tid]), t('Term loaded with uppercased name.'));
// Load the term with name lowercased.
- $terms = taxonomy_get_term_by_name(strtolower($term->name));
+ $terms = taxonomy_term_load_multiple_by_name(strtolower($term->name));
$this->assertTrue(isset($terms[$term->tid]), t('Term loaded with lowercased name.'));
// Try to load an invalid term name.
- $terms = taxonomy_get_term_by_name('Banana');
+ $terms = taxonomy_term_load_multiple_by_name('Banana');
$this->assertFalse($terms);
// Try to load the term using a substring of the name.
- $terms = taxonomy_get_term_by_name(drupal_substr($term->name, 2));
+ $terms = taxonomy_term_load_multiple_by_name(drupal_substr($term->name, 2));
$this->assertFalse($terms);
// Create a new term in a different vocabulary with the same name.
@@ -848,11 +848,11 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
taxonomy_term_save($new_term);
// Load multiple terms with the same name.
- $terms = taxonomy_get_term_by_name($term->name);
+ $terms = taxonomy_term_load_multiple_by_name($term->name);
$this->assertEqual(count($terms), 2, t('Two terms loaded with the same name.'));
// Load single term when restricted to one vocabulary.
- $terms = taxonomy_get_term_by_name($term->name, $this->vocabulary->machine_name);
+ $terms = taxonomy_term_load_multiple_by_name($term->name, $this->vocabulary->machine_name);
$this->assertEqual(count($terms), 1, t('One term loaded when restricted by vocabulary.'));
$this->assertTrue(isset($terms[$term->tid]), t('Term loaded using exact name and vocabulary machine name.'));
@@ -861,11 +861,11 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase {
// Try to load a term by name that doesn't exist in this vocabulary but
// exists in another vocabulary.
- $terms = taxonomy_get_term_by_name($term2->name, $new_vocabulary->machine_name);
+ $terms = taxonomy_term_load_multiple_by_name($term2->name, $new_vocabulary->machine_name);
$this->assertFalse($terms, t('Invalid term name restricted by vocabulary machine name not loaded.'));
// Try to load terms filtering by a non-existing vocabulary.
- $terms = taxonomy_get_term_by_name($term2->name, 'non_existing_vocabulary');
+ $terms = taxonomy_term_load_multiple_by_name($term2->name, 'non_existing_vocabulary');
$this->assertEqual(count($terms), 0, t('No terms loaded when restricted by a non-existing vocabulary.'));
}
}
@@ -1169,7 +1169,7 @@ class TaxonomyHooksTestCase extends TaxonomyWebTestCase {
'antonym' => 'Long',
);
$this->drupalPost('admin/structure/taxonomy/' . $vocabulary->machine_name . '/add', $edit, t('Save'));
- $terms = taxonomy_get_term_by_name($edit['name']);
+ $terms = taxonomy_term_load_multiple_by_name($edit['name']);
$term = reset($terms);
$this->assertEqual($term->antonym, $edit['antonym'], t('Antonym was loaded into the term object'));
diff --git a/core/modules/taxonomy/taxonomy.tokens.inc b/core/modules/taxonomy/taxonomy.tokens.inc
index f8ae457..24d7bc8 100644
--- a/core/modules/taxonomy/taxonomy.tokens.inc
+++ b/core/modules/taxonomy/taxonomy.tokens.inc
@@ -128,7 +128,7 @@ function taxonomy_tokens($type, $tokens, array $data = array(), array $options =
break;
case 'parent':
- if ($parents = taxonomy_get_parents($term->tid)) {
+ if ($parents = taxonomy_term_load_parents($term->tid)) {
$parent = array_pop($parents);
$replacements[$original] = check_plain($parent->name);
}
@@ -141,7 +141,7 @@ function taxonomy_tokens($type, $tokens, array $data = array(), array $options =
$replacements += token_generate('vocabulary', $vocabulary_tokens, array('vocabulary' => $vocabulary), $options);
}
- if (($vocabulary_tokens = token_find_with_prefix($tokens, 'parent')) && $parents = taxonomy_get_parents($term->tid)) {
+ if (($vocabulary_tokens = token_find_with_prefix($tokens, 'parent')) && $parents = taxonomy_term_load_parents($term->tid)) {
$parent = array_pop($parents);
$replacements += token_generate('term', $vocabulary_tokens, array('term' => $parent), $options);
}