views_handler_field_node_link_export.inc 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. /**
  3. * @file
  4. * The Node export views field handler.
  5. */
  6. /**
  7. * Field handler to present a export 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_export extends views_handler_field_node_link {
  12. function construct() {
  13. parent::construct();
  14. $this->additional_fields['uid'] = 'uid';
  15. $this->additional_fields['type'] = 'type';
  16. $this->additional_fields['format'] = array('table' => 'node_revisions', 'field' => 'format');
  17. }
  18. function render($values) {
  19. // Insure that user has access to export this node.
  20. $node = new stdClass();
  21. $node->nid = $values->{$this->aliases['nid']};
  22. $node->uid = $values->{$this->aliases['uid']};
  23. $node->type = $values->{$this->aliases['type']};
  24. $node->format = $values->{$this->aliases['format']};
  25. if (!node_export_access_check($node)) {
  26. return;
  27. }
  28. $text = !empty($this->options['text']) ? $this->options['text'] : t('Node export');
  29. return l($text, "node/$node->nid/node_export", array('query' => drupal_get_destination()));
  30. }
  31. }