function community_tags_node_rebuild_form in Community Tags 6.2
Confirmation form for tag rebuild.
1 string reference to 'community_tags_node_rebuild_form'
- community_tags_node_menu in community_tags_node/
community_tags_node.module - Implementation of hook_menu().
File
- community_tags_node/
community_tags_node.admin.inc, line 159
Code
function community_tags_node_rebuild_form(&$form_state, $vocabulary, $content_type) {
$form = array();
$type_obj = node_get_types('type', $content_type);
$settings = _community_tags_node_get_settings($vid, $content_type);
$missing_tag_counts = _community_tags_get_out_of_sync_missing_tag_counts($vocabulary->vid, $content_type);
$missing_nodeterm_counts = _community_tags_get_out_of_sync_missing_nodeterm_counts($vocabulary->vid, $content_type);
$form['#rebuild_ops'] = array();
$form['#ct_settings'] = $settings;
$form['#vocabulary'] = $vocabulary;
$form['#content_type_obj'] = $type_obj;
$description = '';
if ($settings) {
$question = t('Rebuild community tags for %vocabulary terms on %type nodes?', array(
'%vocabulary' => $vocabulary->name,
'%type' => $type_obj->name,
));
if ($settings['opmode'] & COMMUNITY_TAGS_NODE_OPMODE_SYNC_NT_TO_CT && $missing_tag_counts->missing_ctag_count > 0) {
$description .= '<p>' . t('This operation will rebuild %count missing community tags on %node_count nodes.', array(
'%count' => $missing_tag_counts->missing_ctag_count,
'%node_count' => $missing_tag_counts->node_count,
)) . '</p>';
$form['#rebuild_ops']['tags'] = $missing_tag_counts;
}
if ($settings['opmode'] & COMMUNITY_TAGS_NODE_OPMODE_SYNC_CT_TO_NT && $missing_nodeterm_counts->missing_nodeterm_count > 0) {
$description .= '<p>' . t('There are %count community tags that have no corresponding node terms. Select a syncronistion mode: ', array(
'%count' => $missing_nodeterm_counts->missing_nodeterm_count,
)) . '</p>';
// offer option to bring ct's into line with nt or vice versa
$form['sync_policy'] = array(
'#type' => 'radios',
'#title' => t('Synchronisation mode'),
'#options' => array(
t('<em>Delete community tags</em> that have no corresponding node term.'),
t('<em>Add node terms</em> for all community tags that have no corresponding node term.'),
),
'#weight' => 1,
'#default_value' => 0,
);
$form['#rebuild_ops']['nodeterms'] = $missing_nodeterm_counts;
}
// don't do orphaned term removal - needs work.
if (empty($form['#rebuild_ops'])) {
drupal_set_message(t('Community tags for @vocabulary terms on @type nodes are up to date. Nothing to rebuild. ', array(
'@vocabulary' => $vocabulary->name,
'@type' => $type_obj->name,
)));
return;
}
}
else {
drupal_set_message(t('Community tagging is not active for @vocabulary terms on @type nodes. Will not rebuild. ', array(
'@vocabulary' => $vocabulary->name,
'@type' => $type_obj->name,
)));
return;
}
$path = 'admin/settings/community-tags/' . $vocabulary->vid . '/' . $content_type;
$confirm_form = confirm_form($form, $question, $path, $description);
$confirm_form['actions']['#weight'] = 2;
return $confirm_form;
}