views_handler_field_node_link_translate.inc 918 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_handler_field_node_link_translate.
  5. */
  6. /**
  7. * Field handler to present a link node translate.
  8. *
  9. * @ingroup views_field_handlers
  10. */
  11. class views_handler_field_node_link_translate extends views_handler_field_node_link {
  12. function render_link($data, $values) {
  13. // ensure user has access to edit this node.
  14. $node = $this->get_value($values);
  15. $node->status = 1; // unpublished nodes ignore access control
  16. if (empty($node->language) || !translation_supported_type($node->type) || !node_access('view', $node) || !user_access('translate content')) {
  17. return;
  18. }
  19. $this->options['alter']['make_link'] = TRUE;
  20. $this->options['alter']['path'] = "node/$node->nid/translate";
  21. $this->options['alter']['query'] = drupal_get_destination();
  22. $text = !empty($this->options['text']) ? $this->options['text'] : t('translate');
  23. return $text;
  24. }
  25. }