function clone_form_node_admin_content_alter in Node clone 7
Implements hook_form_FORM_ID_alter().
File
- ./
clone.module, line 200 - Allow users to make a copy of an item of content (a node) and then edit that copy.
Code
function clone_form_node_admin_content_alter(&$form, $form_state, $form_id) {
if (variable_get('clone_method', 'prepopulate') == 'prepopulate') {
$destination = drupal_get_destination();
}
else {
$destination = array();
}
// The property attribute changes in the $form array depending on the user role.
$property = isset($form['admin']['nodes']['#options']) ? '#options' : '#rows';
if (empty($form['admin']['nodes'][$property])) {
return;
}
// Expose a Clone operation on each node.
foreach ($form['admin']['nodes'][$property] as $nid => &$row) {
$node = node_load($nid);
if (clone_access_cloning($node)) {
// The structure of this form is different if there is just 1 or more
// than one operation.
if (!isset($row['operations']['data']['#links'])) {
$row['operations']['data']['#links'] = array();
$row['operations']['data']['#attributes']['class'] = array(
'links',
'inline',
);
$row['operations']['data']['#theme'] = 'links__node_operations';
if (isset($row['operations']['data']['#title'])) {
$title = $row['operations']['data']['#title'];
$row['operations']['data']['#links'][$title] = array(
'title' => $title,
'href' => $row['operations']['data']['#href'],
'query' => $row['operations']['data']['#options']['query'],
);
unset($row['operations']['data']['#type']);
}
}
$row['operations']['data']['#links']['clone'] = array(
'title' => t('clone'),
'href' => 'node/' . $nid . '/clone/' . clone_get_token($nid),
'query' => $destination,
);
}
}
}