Projet

Général

Profil

Paste
Télécharger (1,47 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / views / modules / locale / views_handler_field_locale_link_edit.inc @ d719f12f

1
<?php
2

    
3
/**
4
 * @file
5
 * Definition of views_handler_field_locale_link_edit.
6
 */
7

    
8
/**
9
 * Field handler to present a link to edit a translation.
10
 *
11
 * @ingroup views_field_handlers
12
 */
13
class views_handler_field_locale_link_edit extends views_handler_field {
14
  function construct() {
15
    parent::construct();
16
    $this->additional_fields['lid'] = 'lid';
17
  }
18

    
19
  function option_definition() {
20
    $options = parent::option_definition();
21

    
22
    $options['text'] = array('default' => '', 'translatable' => TRUE);
23

    
24
    return $options;
25
  }
26

    
27
  function options_form(&$form, &$form_state) {
28
    $form['text'] = array(
29
      '#type' => 'textfield',
30
      '#title' => t('Text to display'),
31
      '#default_value' => $this->options['text'],
32
    );
33
    parent::options_form($form, $form_state);
34
  }
35

    
36
  function query() {
37
    $this->ensure_my_table();
38
    $this->add_additional_fields();
39
  }
40

    
41
  function access() {
42
    // Ensure user has access to edit translations.
43
    return user_access('translate interface');
44
  }
45

    
46
  function render($values) {
47
    $value = $this->get_value($values, 'lid');
48
    return $this->render_link($this->sanitize_value($value), $values);
49
  }
50

    
51
  function render_link($data, $values) {
52
    $text = !empty($this->options['text']) ? $this->options['text'] : t('edit');
53

    
54
    $this->options['alter']['make_link'] = TRUE;
55
    $this->options['alter']['path'] = 'admin/config/regional/translate/edit/' . $data;
56
    $this->options['alter']['query'] = drupal_get_destination();
57

    
58
    return $text;
59
  }
60
}