Projet

Général

Profil

Révision 5d12d676

Ajouté par Assos Assos il y a environ 6 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/views/modules/user/views_handler_field_user_picture.inc
6 6
 */
7 7

  
8 8
/**
9
 * Field handler to provide simple renderer that allows using a themed user link.
9
 * Field handler for a simple renderer that allows using a themed user link.
10 10
 *
11 11
 * @ingroup views_field_handlers
12 12
 */
13 13
class views_handler_field_user_picture extends views_handler_field {
14
  function construct() {
14

  
15
  /**
16
   * {@inheritdoc}
17
   */
18
  public function construct() {
15 19
    parent::construct();
16 20
    $this->additional_fields['uid'] = 'uid';
17 21
    $this->additional_fields['name'] = 'name';
18 22
    $this->additional_fields['mail'] = 'mail';
19 23
  }
20 24

  
21
  function element_type($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE) {
25
  /**
26
   * {@inheritdoc}
27
   */
28
  public function element_type($none_supported = FALSE, $default_empty = FALSE, $inline = FALSE) {
22 29
    if ($inline) {
23 30
      return 'span';
24 31
    }
......
40 47
    return 'div';
41 48
  }
42 49

  
43
  function option_definition() {
50
  /**
51
   * {@inheritdoc}
52
   */
53
  public function option_definition() {
44 54
    $options = parent::option_definition();
45 55
    $options['link_photo_to_profile'] = array('default' => TRUE, 'bool' => TRUE);
46 56
    $options['image_style'] = array('default' => '');
47 57
    return $options;
48 58
  }
49 59

  
50
  function options_form(&$form, &$form_state) {
60
  /**
61
   * {@inheritdoc}
62
   */
63
  public function options_form(&$form, &$form_state) {
51 64
    parent::options_form($form, $form_state);
52 65
    $form['link_photo_to_profile'] = array(
53 66
      '#title' => t("Link to user's profile"),
......
73 86
    }
74 87
  }
75 88

  
76
  function render($values) {
89
  /**
90
   * {@inheritdoc}
91
   */
92
  public function render($values) {
77 93
    if ($this->options['image_style'] && module_exists('image')) {
78
      // @todo: Switch to always using theme('user_picture') when it starts
94
      // @todo Switch to always using theme('user_picture') when it starts
79 95
      // supporting image styles. See http://drupal.org/node/1021564
80 96
      if ($picture_fid = $this->get_value($values)) {
81 97
        $picture = file_load($picture_fid);
82
        $picture_filepath = $picture->uri;
98
        if (!empty($picture)) {
99
          $picture_filepath = $picture->uri;
100
        }
101
        else {
102
          $picture_filepath = variable_get('user_picture_default', '');
103
        }
83 104
      }
84 105
      else {
85 106
        $picture_filepath = variable_get('user_picture_default', '');
86 107
      }
87 108
      if (file_valid_uri($picture_filepath)) {
88
        $output = theme('image_style', array('style_name' => $this->options['image_style'], 'path' => $picture_filepath));
109
        $account = user_load($this->get_value($values, 'uid'));
110
        $alt = t("@user's picture", array('@user' => format_username($account)));
111
        $output = theme('image_style', array('style_name' => $this->options['image_style'], 'path' => $picture_filepath, 'alt' => $alt));
89 112
        if ($this->options['link_photo_to_profile'] && user_access('access user profiles')) {
90 113
          $uid = $this->get_value($values, 'uid');
91 114
          $output = l($output, "user/$uid", array('html' => TRUE));
......
111 134

  
112 135
    return $output;
113 136
  }
137

  
114 138
}

Formats disponibles : Unified diff