redirect_handler_field_redirect_link_edit.inc 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * @file
  4. * Redirect field handler for edit links.
  5. */
  6. class redirect_handler_field_redirect_link_edit extends views_handler_field {
  7. function construct() {
  8. parent::construct();
  9. $this->additional_fields['rid'] = 'rid';
  10. }
  11. function option_definition() {
  12. $options = parent::option_definition();
  13. $options['text'] = array('default' => '', 'translatable' => TRUE);
  14. return $options;
  15. }
  16. function options_form(&$form, &$form_state) {
  17. parent::options_form($form, $form_state);
  18. $form['text'] = array(
  19. '#type' => 'textfield',
  20. '#title' => t('Text to display'),
  21. '#default_value' => $this->options['text'],
  22. );
  23. }
  24. function query() {
  25. $this->ensure_my_table();
  26. $this->add_additional_fields();
  27. }
  28. function render($values) {
  29. $rid = $values->{$this->aliases['rid']};
  30. if (($redirect = redirect_load($rid)) && redirect_access('update', $redirect)) {
  31. $text = !empty($this->options['text']) ? $this->options['text'] : t('Edit');
  32. return l($text, "admin/config/search/redirect/edit/" . $rid, array('query' => drupal_get_destination()));
  33. }
  34. }
  35. }