function views_bulk_operations_content_taxonomy_action_form in Views Bulk Operations (VBO) 6
File
- actions/
content_taxonomy.action.inc, line 59
Code
function views_bulk_operations_content_taxonomy_action_form($context) {
module_load_include('inc', 'content', 'includes/content.node_form');
if (isset($context['selection']) && isset($context['view'])) {
$fields = array();
$nids = array_map('_views_bulk_operations_get_oid', $context['selection'], array_fill(0, count($context['selection']), $context['view']->base_field));
$placeholders = db_placeholders($nids);
$result = db_query("SELECT field_name, label, type FROM {node} n LEFT JOIN {content_node_field_instance} ci ON n.type=ci.type_name WHERE nid IN ({$placeholders}) AND widget_module LIKE 'content_taxonomy_%' GROUP BY field_name", $nids);
while ($f = db_fetch_object($result)) {
$fields[$f->field_name] = array(
'label' => $f->label,
'type' => $f->type,
);
}
}
if (empty($fields)) {
drupal_set_message(t('The selected nodes do not have any Content Taxonomy fields. Please select other nodes and try again.'), 'error');
return array();
}
$form['fields'] = array(
'#type' => 'fieldset',
'#title' => t('Content Taxonomy fields'),
'#tree' => TRUE,
);
$form_state = array();
foreach ($fields as $field => $details) {
$info = content_types($details['type']);
$form['#node'] = new stdClass();
$form['#node']->type = $details['type'];
$form['#node']->{$field} = NULL;
$form['#field_info'][$field] = $info['fields'][$field];
$form['fields'] += (array) content_field_form($form, $form_state, $info['fields'][$field]);
$form['fields'][$field]['#required'] = FALSE;
}
$form['do'] = array(
'#type' => 'radios',
'#title' => t('Action to take'),
'#default_value' => isset($context['do']) ? $context['do'] : TAXONOMY_ACTION_ADD,
'#options' => array(
TAXONOMY_ACTION_ADD => t('Add the selected terms'),
TAXONOMY_ACTION_REPLACE => t('Replace existing terms with selected ones'),
TAXONOMY_ACTION_DELETE => t('Delete selected terms'),
),
'#required' => TRUE,
'#weight' => -2,
);
return $form;
}