views_handler_field_locale_link_edit.inc

  1. 3.x modules/locale/views_handler_field_locale_link_edit.inc
  2. 2.x modules/locale/views_handler_field_locale_link_edit.inc

Definition of views_handler_field_locale_link_edit.

File

modules/locale/views_handler_field_locale_link_edit.inc
View source
  1. <?php
  2. /**
  3. * @file
  4. * Definition of views_handler_field_locale_link_edit.
  5. */
  6. /**
  7. * Field handler to present a link to edit a translation.
  8. *
  9. * @ingroup views_field_handlers
  10. */
  11. class views_handler_field_locale_link_edit extends views_handler_field {
  12. function construct() {
  13. parent::construct();
  14. $this->additional_fields['lid'] = 'lid';
  15. }
  16. function option_definition() {
  17. $options = parent::option_definition();
  18. $options['text'] = array('default' => '', 'translatable' => TRUE);
  19. return $options;
  20. }
  21. function options_form(&$form, &$form_state) {
  22. $form['text'] = array(
  23. '#type' => 'textfield',
  24. '#title' => t('Text to display'),
  25. '#default_value' => $this->options['text'],
  26. );
  27. parent::options_form($form, $form_state);
  28. }
  29. function query() {
  30. $this->ensure_my_table();
  31. $this->add_additional_fields();
  32. }
  33. function access() {
  34. // Ensure user has access to edit translations.
  35. return user_access('translate interface');
  36. }
  37. function render($values) {
  38. $value = $this->get_value($values, 'lid');
  39. return $this->render_link($this->sanitize_value($value), $values);
  40. }
  41. function render_link($data, $values) {
  42. $text = !empty($this->options['text']) ? $this->options['text'] : t('edit');
  43. $this->options['alter']['make_link'] = TRUE;
  44. $this->options['alter']['path'] = 'admin/build/translate/edit/' . $data;
  45. $this->options['alter']['query'] = drupal_get_destination();
  46. return $text;
  47. }
  48. }