views_handler_field_node_link_clone.inc 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. /**
  3. * @file
  4. * Views field handler for Node_Clone module.
  5. */
  6. /**
  7. * Field handler to present a clone node link.
  8. *
  9. * Closely modeled after views/modules/node/views_handler_field_node_link_edit.inc
  10. */
  11. class views_handler_field_node_link_clone extends views_handler_field_node_link {
  12. /**
  13. * Renders the link.
  14. */
  15. function render_link($node, $values) {
  16. if (!clone_access_cloning($node)) {
  17. return;
  18. }
  19. $this->options['alter']['make_link'] = TRUE;
  20. $this->options['alter']['path'] = "node/{$node->nid}/clone/" . clone_get_token($node->nid);
  21. $method = variable_get('clone_method', 'prepopulate');
  22. $destination = drupal_get_destination();
  23. if ($method == 'prepopulate') {
  24. $this->options['alter']['query'] = $destination;
  25. }
  26. elseif (!empty($destination['destination'])) {
  27. $this->options['alter']['query']['node-clone-destination'] = $destination['destination'];
  28. }
  29. $text = !empty($this->options['text']) ? $this->options['text'] : t('clone');
  30. return $text;
  31. }
  32. }