View source
<?php
define('TERM_MERGE_NO_REDIRECT', -1);
function term_merge_menu() {
$items = array();
$items['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name/merge'] = array(
'title' => 'Merge terms',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'term_merge_form',
3,
),
'access callback' => 'term_merge_access',
'access arguments' => array(
3,
),
'file' => 'term_merge.pages.inc',
'type' => MENU_LOCAL_TASK,
);
$items['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name/merge/default'] = array(
'title' => 'Default',
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name/merge/duplicates'] = array(
'title' => 'Merge Duplicate Terms',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'term_merge_duplicates_form',
3,
),
'access callback' => 'term_merge_access',
'access arguments' => array(
3,
),
'file' => 'term_merge.pages.inc',
'type' => MENU_LOCAL_TASK,
);
$items['taxonomy/term/%taxonomy_term/merge'] = array(
'title' => 'Merge Terms',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'term_merge_form',
NULL,
2,
),
'access callback' => 'term_merge_access',
'access arguments' => array(
NULL,
2,
),
'file' => 'term_merge.pages.inc',
'type' => MENU_LOCAL_TASK,
'weight' => 10,
);
$items['taxonomy/term/%taxonomy_term/merge/default'] = array(
'title' => 'Default',
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['taxonomy/term/%taxonomy_term/merge/duplicates'] = array(
'title' => 'Merge Duplicate Terms',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'term_merge_duplicates_form',
NULL,
2,
),
'access callback' => 'term_merge_access',
'access arguments' => array(
NULL,
2,
),
'file' => 'term_merge.pages.inc',
'type' => MENU_LOCAL_TASK,
);
$items['term-merge/autocomplete/term-trunk/%taxonomy_vocabulary_machine_name'] = array(
'title' => 'Autocomplete Term Merge form term trunk',
'page callback' => 'term_merge_form_term_trunk_widget_autocomplete_autocomplete',
'page arguments' => array(
3,
),
'access callback' => 'term_merge_access',
'access arguments' => array(
3,
),
'file' => 'term_merge.pages.inc',
'type' => MENU_CALLBACK,
);
$items['admin/config/user-interface/term-merge'] = array(
'title' => 'Term Merge settings',
'description' => 'Configure Term Merge module.',
'page callback' => 'drupal_get_form',
'page arguments' => array(
'term_merge_admin_settings_form',
),
'access arguments' => array(
'administer term merge',
),
'file' => 'term_merge.admin.inc',
);
return $items;
}
function term_merge_admin_paths() {
return array(
'taxonomy/term/*/merge' => TRUE,
'taxonomy/term/*/merge/*' => TRUE,
);
}
function term_merge_permission() {
$permissions = array();
$permissions['administer term merge'] = array(
'title' => t('Administer Term merge'),
'description' => t('Administer settings of the Term merge module.'),
);
$permissions['merge terms'] = array(
'title' => t('Merge any terms'),
'description' => t('Gives the ability to merge any taxonomy terms.'),
);
$vocabularies = taxonomy_get_vocabularies();
foreach ($vocabularies as $vocabulary) {
$permissions['merge ' . $vocabulary->machine_name . ' terms'] = array(
'title' => t('Merge %name vocabulary terms', array(
'%name' => $vocabulary->name,
)),
'description' => t('Gives the ability to merge taxonomy terms that belong to vocabulary %name.', array(
'%name' => $vocabulary->name,
)),
);
}
return $permissions;
}
function term_merge_action_info() {
return array(
'term_merge_action' => array(
'type' => 'taxonomy_term',
'label' => t('Merge term'),
'configurable' => TRUE,
'behavior' => array(
'view_property',
),
'pass rows' => TRUE,
),
);
}
function term_merge_help($path, $arg) {
switch ($path) {
case 'admin/help#term_merge':
return '<p>' . t('Allows you to merge multiple terms into one and and at the same time update all fields referencing the old ones.') . '</p>';
break;
}
}
function term_merge_ctools_plugin_type() {
$plugins = array();
$plugins['duplicate_suggestion'] = array(
'defaults' => array(
'title' => NULL,
'description' => NULL,
'hash callback' => NULL,
'weight' => 0,
),
);
return $plugins;
}
function term_merge_ctools_plugin_directory($owner, $plugin_type) {
switch ($owner) {
case 'term_merge':
switch ($plugin_type) {
case 'duplicate_suggestion':
return 'plugins/' . $plugin_type;
}
break;
case 'synonyms':
switch ($plugin_type) {
case 'behavior':
return 'plugins/' . $plugin_type;
}
break;
}
}
function term_merge_synonyms_provider_field_behavior_implementation_info($behavior) {
switch ($behavior) {
case 'term_merge':
return array(
'number_integer' => 'TextTermMergeSynonymsBehavior',
'number_decimal' => 'TextTermMergeSynonymsBehavior',
'number_float' => 'TextTermMergeSynonymsBehavior',
'text' => 'TextTermMergeSynonymsBehavior',
'taxonomy_term_reference' => 'TaxonomyTermMergeSynonymsBehavior',
'entityreference' => 'EntityReferenceTermMergeSynonymsBehavior',
);
break;
}
return array();
}
function term_merge_access($vocabulary = NULL, $term = NULL, $account = NULL) {
if (is_null($vocabulary) && is_null($term)) {
return FALSE;
}
if (is_null($account)) {
$account = $GLOBALS['user'];
}
if (is_null($vocabulary)) {
$vocabulary = taxonomy_vocabulary_load($term->vid);
}
return user_access('merge terms', $account) || user_access('merge ' . $vocabulary->machine_name . ' terms', $account);
}
function term_merge_action_form($context, &$form_state) {
$term_branch_value = isset($form_state['selection']) && is_array($form_state['selection']) ? $form_state['selection'] : array();
$vocabulary = FALSE;
if (!empty($term_branch_value)) {
$vocabulary = db_select('taxonomy_term_data', 't')
->fields('t', array(
'vid',
))
->condition('tid', reset($term_branch_value))
->execute()
->fetchField();
$vocabulary = taxonomy_vocabulary_load($vocabulary);
}
if ($vocabulary) {
$form = array();
module_load_include('inc', 'term_merge', 'term_merge.pages');
term_merge_form_base($form, $form_state, $vocabulary, $term_branch_value);
$form['step']['#access'] = FALSE;
}
else {
$form['vocabulary_missing'] = array(
'#markup' => '<b>' . t('Oops, something did not seem to go right. Term merge module cannot determine within which vocabulary merge is about to happen. You might want to report it to the <a href="@url">Term Merge issue queue</a>.', array(
'@url' => 'https://www.drupal.org/project/issues/term_merge',
)) . '</b>',
);
}
return $form;
}
function term_merge_action_submit($form, &$form_state) {
return array(
'term_trunk' => $form_state['values']['term_trunk']['tid'],
) + term_merge_merge_options_submit($form, $form_state, $form);
}
function term_merge_action($object, $context) {
$term_branch = $object;
$term_trunk = taxonomy_term_load($context['term_trunk']);
$vocabulary = taxonomy_vocabulary_load($term_branch->vid);
$term_branch_children = array();
foreach (taxonomy_get_tree($term_branch->vid, $term_branch->tid) as $term) {
$term_branch_children[] = $term->tid;
}
if ($term_branch->vid != $term_trunk->vid) {
watchdog('term_merge', 'Trying to merge 2 terms (%term_branch, %term_trunk) from different vocabularies', array(
'%term_branch' => $term_branch->name,
'%term_trunk' => $term_trunk->name,
), WATCHDOG_WARNING);
return;
}
if ($term_branch->tid == $term_trunk->tid) {
watchdog('term_merge', 'Trying to merge a term %term into itself.', array(
'%term' => $term_branch->name,
), WATCHDOG_WARNING);
return;
}
if (in_array($term_trunk->tid, $term_branch_children)) {
watchdog('term_merge', 'Trying to merge a term %term_branch into its child %term_trunk.', array(
'%term_branch' => $term_branch->name,
'%term_trunk' => $term_trunk->name,
), WATCHDOG_WARNING);
return;
}
if (!isset($context['term_branch_keep'])) {
$context['term_branch_keep'] = TRUE;
}
if (!isset($context['merge_fields'])) {
$context['merge_fields'] = array();
}
if (!isset($context['keep_only_unique'])) {
$context['keep_only_unique'] = TRUE;
}
if (!isset($context['redirect']) || !module_exists('redirect')) {
$context['redirect'] = TERM_MERGE_NO_REDIRECT;
}
if (!isset($context['synonyms']) || !module_exists('synonyms')) {
$context['synonyms'] = NULL;
}
module_invoke_all('term_merge', $term_trunk, $term_branch, $context);
if (!empty($context['merge_fields'])) {
foreach ($context['merge_fields'] as $field_name) {
$languages = array();
if (isset($term_trunk->{$field_name}) && is_array($term_trunk->{$field_name})) {
$languages = array_merge($languages, array_keys($term_trunk->{$field_name}));
}
if (isset($term_branch->{$field_name}) && is_array($term_branch->{$field_name})) {
$languages = array_merge($languages, array_keys($term_branch->{$field_name}));
}
$languages = array_unique($languages);
foreach ($languages as $language) {
if (!isset($term_trunk->{$field_name}[$language])) {
$term_trunk->{$field_name}[$language] = array();
}
if (!isset($term_branch->{$field_name}[$language])) {
$term_branch->{$field_name}[$language] = array();
}
$items = array_merge($term_trunk->{$field_name}[$language], $term_branch->{$field_name}[$language]);
$unique_items = array();
foreach ($items as $item) {
$unique_items[serialize($item)] = $item;
}
$items = array_values($unique_items);
$term_trunk->{$field_name}[$language] = $items;
}
}
taxonomy_term_save($term_trunk);
}
$result = array();
foreach (term_merge_fields_with_foreign_key('taxonomy_term_data', 'tid') as $field) {
$result[$field['field_name']] = array();
$query = new EntityFieldQuery();
$query
->addMetaData('account', user_load(1));
$query
->fieldCondition($field['field_name'], $field['term_merge_field_column'], $term_branch->tid);
$_result = $query
->execute();
$result[$field['field_name']]['entities'] = $_result;
$result[$field['field_name']]['column'] = $field['term_merge_field_column'];
}
foreach ($result as $field_name => $field_data) {
$column = $field_data['column'];
foreach ($field_data['entities'] as $entity_type => $v) {
$ids = array_keys($v);
$entities = entity_load($entity_type, $ids);
foreach ($entities as $entity) {
foreach ($entity->{$field_name} as $language => $items) {
$is_trunk_added = FALSE;
foreach ($entity->{$field_name}[$language] as $delta => $item) {
if ($context['keep_only_unique'] && $is_trunk_added && in_array($item[$column], array(
$term_trunk->tid,
$term_branch->tid,
))) {
unset($entity->{$field_name}[$language][$delta]);
}
else {
switch ($item[$column]) {
case $term_trunk->tid:
$is_trunk_added = TRUE;
break;
case $term_branch->tid:
$is_trunk_added = TRUE;
$entity->{$field_name}[$language][$delta][$column] = $term_trunk->tid;
break;
}
}
}
$entity->{$field_name}[$language] = array_values($entity->{$field_name}[$language]);
}
if (module_exists('workbench_moderation') && $entity_type == 'node') {
$entity->workbench_moderation['updating_live_revision'] = TRUE;
}
entity_save($entity_type, $entity);
}
}
}
if ($context['synonyms']) {
term_merge_add_entity_as_synonym($term_trunk, 'taxonomy_term', $context['synonyms'], $term_branch, 'taxonomy_term');
}
$redirect_paths = array();
if ($context['redirect'] != TERM_MERGE_NO_REDIRECT) {
$redirect_paths['taxonomy/term/' . $term_trunk->tid] = array(
'taxonomy/term/' . $term_branch->tid,
);
$redirect_paths['taxonomy/term/' . $term_trunk->tid . '/feed'] = array(
'taxonomy/term/' . $term_branch->tid . '/feed',
);
foreach ($redirect_paths as $redirect_destination => $redirect_sources) {
$alias = drupal_get_path_alias($redirect_sources[0]);
if ($alias != $redirect_sources[0]) {
$redirect_sources[] = $alias;
}
$existing_redirects = array();
foreach ($redirect_sources as $redirect_source) {
foreach (redirect_load_multiple(array(), array(
'redirect' => $redirect_source,
)) as $v) {
$existing_redirects[] = $v->source;
}
}
$redirect_paths[$redirect_destination] = array_unique(array_merge($redirect_sources, $existing_redirects));
}
}
if (!$context['term_branch_keep']) {
foreach (taxonomy_get_children($term_branch->tid, $vocabulary->vid) as $child) {
$parents = taxonomy_get_parents($child->tid);
unset($parents[$term_branch->tid]);
$parents[$term_trunk->tid] = $term_trunk;
$parents = array_unique(array_keys($parents));
$child->parent = $parents;
taxonomy_term_save($child);
}
if (module_exists('views')) {
$views = views_get_all_views();
foreach ($views as $view) {
$needs_saving = FALSE;
foreach ($view->display as $display_id => $display) {
$view
->set_display($display_id);
$filters = $view->display_handler
->get_handlers('filter');
foreach ($filters as $filter_id => $filter_handler) {
if (get_class($filter_handler) == 'views_handler_filter_term_node_tid') {
$filter = $view
->get_item($display_id, 'filter', $filter_id);
if (isset($filter['value'][$term_branch->tid])) {
unset($filter['value'][$term_branch->tid]);
$filter['value'][$term_trunk->tid] = $term_trunk->tid;
$view
->set_item($display_id, 'filter', $filter_id, $filter);
$needs_saving = TRUE;
}
}
}
}
if ($needs_saving) {
$view
->save();
}
}
}
taxonomy_term_delete($term_branch->tid);
}
foreach ($redirect_paths as $redirect_destination => $redirect_sources) {
foreach ($redirect_sources as $redirect_source) {
$redirect = redirect_load_by_source($redirect_source);
if (!$redirect) {
$redirect = new stdClass();
redirect_object_prepare($redirect, array(
'source' => $redirect_source,
));
}
$redirect->redirect = $redirect_destination;
$redirect->status_code = $context['redirect'];
redirect_save($redirect);
}
}
watchdog('term_merge', 'Successfully merged term %term_branch into term %term_trunk in vocabulary %vocabulary. Context: @context', array(
'%term_branch' => $term_branch->name,
'%term_trunk' => $term_trunk->name,
'%vocabulary' => $vocabulary->name,
'@context' => var_export($context, 1),
));
}
function term_merge($term_branch, $term_trunk, $merge_settings = array()) {
if (!is_array($merge_settings)) {
$merge_settings = array(
'term_branch_keep' => $merge_settings,
);
}
if (!is_array($term_branch)) {
$term_branch = array(
$term_branch,
);
}
$batch = array(
'title' => t('Merging terms'),
'operations' => array(
array(
'_term_merge_batch_process',
array(
$term_branch,
$term_trunk,
$merge_settings,
),
),
),
'finished' => 'term_merge_batch_finished',
'file' => drupal_get_path('module', 'term_merge') . '/term_merge.batch.inc',
);
batch_set($batch);
}
function term_merge_duplicate_suggestion($id = NULL) {
ctools_include('plugins');
$plugins = ctools_get_plugins('term_merge', 'duplicate_suggestion', $id);
if (!$id) {
uasort($plugins, 'drupal_sort_weight');
}
return $plugins;
}
function term_merge_merge_options_elements($vocabulary) {
$form = array();
$bundle = field_extract_bundle('taxonomy_term', $vocabulary);
$instances = field_info_instances('taxonomy_term', $bundle);
$form['term_branch_keep'] = array(
'#type' => 'checkbox',
'#title' => t('Only merge occurrences'),
'#description' => t('Check this if you want to only merge the occurrences of the specified terms, i.e. the terms will not be deleted from your vocabulary.'),
);
if (!empty($instances)) {
$options = array();
foreach ($instances as $instance) {
$options[$instance['field_name']] = $instance['label'];
}
$form['merge_fields'] = array(
'#type' => 'checkboxes',
'#title' => t('Merge Term Fields'),
'#description' => t('Check the fields whose values from branch terms you want to add to the values of corresponding fields of the trunk term. <b>Important note:</b> the values will be added until the cardinality limit for the selected fields is reached and only unique values for each field will be saved.'),
'#options' => $options,
);
}
$form['keep_only_unique'] = array(
'#type' => 'checkbox',
'#title' => t('Keep only unique terms after merging'),
'#description' => t('Sometimes after merging you may end up having a node (or any other entity) pointing twice to the same taxonomy term, tick this checkbox if want to keep only unique terms in other entities after merging.'),
'#default_value' => TRUE,
);
if (module_exists('redirect')) {
$form['redirect'] = array(
'#access' => user_access('administer redirects'),
'#type' => 'select',
'#title' => t('Create Redirect'),
'#description' => t('If you want to create an HTTP redirect from your branch terms to the trunk term, please, choose the HTTP redirect code here.'),
'#required' => TRUE,
'#options' => term_merge_redirect_options(),
'#default_value' => variable_get('term_merge_default_redirect', TERM_MERGE_NO_REDIRECT),
);
}
else {
$form['redirect'] = array(
'#markup' => t('Enable the module ' . l('Redirect', 'http://drupal.org/project/redirect') . ' if you want to do an HTTP redirect from your term branch to the term trunk.'),
);
}
if (module_exists('synonyms')) {
$options = array(
'' => t('None'),
);
if (function_exists('synonyms_behavior_get')) {
foreach (synonyms_behavior_get('term_merge', 'taxonomy_term', $vocabulary->machine_name, TRUE) as $behavior_implementation) {
$options[$behavior_implementation['provider']] = $behavior_implementation['label'];
}
}
else {
foreach (synonyms_synonyms_fields($vocabulary) as $field_name) {
$options[$field_name] = $instances[$field_name]['label'];
}
}
$form['synonyms'] = array(
'#type' => 'radios',
'#title' => t('Add as Synonyms'),
'#description' => t('Synonyms module allows you to add branch terms as synonyms into any of fields, enabled as sources of synonyms in vocabulary. Check the field into which you would like to add branch terms as synonym. <b>Important note:</b> the values will be added until the cardinality limit for the selected field is reached.'),
'#options' => $options,
'#default_value' => '',
);
}
else {
$form['synonyms'] = array(
'#markup' => t('Enable the module ' . l('Synonyms', 'http://drupal.org/project/synonyms') . ' if you want to be able to add branch terms as synonyms into a field of your trunk term.'),
);
}
$form['step'] = array(
'#type' => 'textfield',
'#title' => t('Step'),
'#description' => t('Please, specify how many terms to process per script run in batch. If you are hitting time or memory limits in your PHP, decrease this number.'),
'#default_value' => 40,
'#required' => TRUE,
'#element_validate' => array(
'element_validate_integer_positive',
),
);
return $form;
}
function term_merge_merge_options_submit($merge_settings_element, &$form_state, $form) {
$merge_settings = array(
'term_branch_keep' => (bool) $merge_settings_element['term_branch_keep']['#value'],
'merge_fields' => isset($merge_settings_element['merge_fields']['#value']) ? array_values(array_filter($merge_settings_element['merge_fields']['#value'])) : array(),
'keep_only_unique' => (bool) $merge_settings_element['keep_only_unique']['#value'],
'redirect' => isset($merge_settings_element['redirect']['#value']) ? $merge_settings_element['redirect']['#value'] : TERM_MERGE_NO_REDIRECT,
'synonyms' => isset($merge_settings_element['synonyms']['#value']) ? $merge_settings_element['synonyms']['#value'] : NULL,
'step' => (int) $merge_settings_element['step']['#value'],
);
return $merge_settings;
}
function term_merge_fields_with_foreign_key($foreign_table, $foreign_column) {
$fields = field_info_fields();
$result = array();
foreach ($fields as $field_name => $field_info) {
foreach ($field_info['foreign keys'] as $foreign_key) {
if ($foreign_key['table'] == $foreign_table) {
$column = array_search($foreign_column, $foreign_key['columns']);
if ($column) {
$field_info['term_merge_field_column'] = $column;
$result[] = $field_info;
}
}
}
}
return $result;
}
function term_merge_add_entity_as_synonym($trunk_entity, $trunk_entity_type, $behavior_provider, $synonym_entity, $synonym_entity_type) {
if ($trunk_entity_type != 'taxonomy_term') {
return FALSE;
}
$bundle = entity_extract_ids($trunk_entity_type, $trunk_entity);
$bundle = $bundle[2];
$behavior_implementations = synonyms_behavior_get_all_enabled($trunk_entity_type, $bundle, $behavior_provider);
foreach ($behavior_implementations as $behavior_implementation) {
if ($behavior_implementation['behavior'] == 'term_merge') {
$behavior_implementation['object']
->mergeTerm($trunk_entity, $synonym_entity, $synonym_entity_type);
taxonomy_term_save($trunk_entity);
return TRUE;
}
}
return FALSE;
}
function term_merge_form_base_term_trunk_validate($element, &$form_state, $form) {
$prohibited_trunks = array();
foreach ($form['#term_merge_term_branch'] as $term_branch) {
$children = taxonomy_get_tree($form['#vocabulary']->vid, $term_branch);
$prohibited_trunks[] = $term_branch;
foreach ($children as $child) {
$prohibited_trunks[] = $child->tid;
}
}
$value = drupal_array_get_nested_value($form_state['values'], $element['#parents']);
if (in_array($value['tid'], $prohibited_trunks)) {
form_error($element['tid'], t('Trunk term cannot be one of the selected branch terms or their children.'));
}
}
function term_merge_form_term_trunk_widget_select(&$form, &$form_state, $vocabulary, $term_branch_value) {
$tree = taxonomy_get_tree($vocabulary->vid);
$options = array();
foreach ($tree as $v) {
$options[$v->tid] = str_repeat('-', $v->depth) . $v->name . ' [tid: ' . $v->tid . ']';
}
if (!empty($term_branch_value)) {
foreach ($term_branch_value as $v) {
unset($options[$v]);
foreach (taxonomy_get_tree($vocabulary->vid, $v) as $child) {
unset($options[$child->tid]);
}
}
}
else {
$options = array();
}
$form['term_trunk']['tid'] = array(
'#type' => 'select',
'#required' => TRUE,
'#description' => t('Choose into what term you want to merge.'),
'#options' => $options,
);
}
function term_merge_form_term_trunk_widget_hs_taxonomy(&$form, &$form_state, $vocabulary, $term_branch_value) {
$form['term_trunk']['tid'] = array(
'#type' => 'hierarchical_select',
'#description' => t('Please select a term to merge into.'),
'#required' => TRUE,
'#element_validate' => array(
'term_merge_form_trunk_term_widget_hs_taxonomy_validate',
),
'#config' => array(
'module' => 'hs_taxonomy',
'params' => array(
'vid' => $vocabulary->vid,
'exclude_tid' => NULL,
'root_term' => FALSE,
),
'enforce_deepest' => 0,
'entity_count' => 0,
'require_entity' => 0,
'save_lineage' => 0,
'level_labels' => array(
'status' => 0,
),
'dropbox' => array(
'status' => 0,
),
'editability' => array(
'status' => 0,
),
'resizable' => TRUE,
'render_flat_select' => 0,
),
);
}
function term_merge_form_term_trunk_widget_autocomplete(&$form, &$form_state, $vocabulary, $term_branch_value) {
$form['term_trunk']['tid'] = array(
'#type' => 'textfield',
'#description' => t("Start typing in a term's name in order to get some suggestions."),
'#required' => TRUE,
'#autocomplete_path' => 'term-merge/autocomplete/term-trunk/' . $vocabulary->machine_name,
'#element_validate' => array(
'term_merge_form_trunk_term_widget_autocomplete_validate',
),
);
}
function term_merge_form_trunk_term_widget_autocomplete_validate($element, &$form_state, $form) {
if (preg_match("/.+\\((\\d+)\\)\$/", $element['#value'], $matches)) {
$term = taxonomy_term_load($matches[1]);
}
else {
$term = taxonomy_get_term_by_name($element['#value'], $form['#vocabulary']->machine_name);
$term = reset($term);
}
if (empty($term)) {
form_error($element, t('There are no terms matching %value in the %vocabulary vocabulary.', array(
'%value' => $element['#value'],
'%vocabulary' => $form['#vocabulary']->name,
)));
}
else {
form_set_value($element, $term->tid, $form_state);
}
}
function term_merge_form_trunk_term_widget_hs_taxonomy_validate($element, &$form_state, $form) {
$tid = 0;
if (is_array($element['#value']) && !empty($element['#value'])) {
$tid = (int) array_pop($element['#value']);
}
form_set_value($element, $tid, $form_state);
}
function term_merge_redirect_options() {
return array(
TERM_MERGE_NO_REDIRECT => t('No redirect'),
0 => t('Default (@default)', array(
'@default' => variable_get('redirect_default_status_code', 301),
)),
) + redirect_status_code_options();
}