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_plugin_row_user_view.inc
2 2

  
3 3
/**
4 4
 * @file
5
 * Contains the user view row plugin.
5
 * Definition of views_plugin_row_user_view.
6 6
 */
7 7

  
8 8
/**
......
11 11
 * @ingroup views_row_plugins
12 12
 */
13 13
class views_plugin_row_user_view extends views_plugin_row {
14
  var $base_table = 'users';
15
  var $base_field = 'uid';
14

  
15
  /**
16
   *
17
   */
18
  public $base_table = 'users';
19

  
20
  /**
21
   *
22
   */
23
  public $base_field = 'uid';
16 24

  
17 25
  // Store the users to be used for pre_render.
18
  var $users = array();
26
  public $users = array();
19 27

  
20
  function option_definition() {
28
  /**
29
   * {@inheritdoc}
30
   */
31
  public function option_definition() {
21 32
    $options = parent::option_definition();
22 33
    $options['view_mode'] = array('default' => 'full');
23 34

  
24 35
    return $options;
25 36
  }
26 37

  
27
  function options_form(&$form, &$form_state) {
38
  /**
39
   * {@inheritdoc}
40
   */
41
  public function options_form(&$form, &$form_state) {
28 42
    parent::options_form($form, $form_state);
29 43

  
30 44
    $options = $this->options_form_summary_options();
......
33 47
      '#options' => $options,
34 48
      '#title' => t('View mode'),
35 49
      '#default_value' => $this->options['view_mode'],
36
     );
50
    );
37 51
    $form['help']['#markup'] = t("Display the user with standard user view. It might be necessary to add a user-profile.tpl.php in your theme's template folder, because the default <a href=\"@user-profile-api-link\">user-profile</a> template doesn't show the username by default.", array('@user-profile-api-link' => url('http://api.drupal.org/api/drupal/modules--user--user-profile.tpl.php/7')));
38 52
  }
39 53

  
40

  
41
    /**
42
     * Return the main options, which are shown in the summary title.
43
     */
44
    function options_form_summary_options() {
45
      $entity_info = entity_get_info('user');
46
      $options = array();
47
      if (!empty($entity_info['view modes'])) {
48
        foreach ($entity_info['view modes'] as $mode => $settings) {
49
          $options[$mode] = $settings['label'];
50
        }
51
      }
52
      if (empty($options)) {
53
        $options = array(
54
          'full' => t('User account')
55
        );
54
  /**
55
   * Return the main options, which are shown in the summary title.
56
   */
57
  public function options_form_summary_options() {
58
    $entity_info = entity_get_info('user');
59
    $options = array();
60
    if (!empty($entity_info['view modes'])) {
61
      foreach ($entity_info['view modes'] as $mode => $settings) {
62
        $options[$mode] = $settings['label'];
56 63
      }
57

  
58
      return $options;
59 64
    }
60

  
61
    function summary_title() {
62
      $options = $this->options_form_summary_options();
63
      return check_plain($options[$this->options['view_mode']]);
65
    if (empty($options)) {
66
      $options = array(
67
        'full' => t('User account'),
68
      );
64 69
    }
65 70

  
66
  function pre_render($values) {
71
    return $options;
72
  }
73

  
74
  /**
75
   * {@inheritdoc}
76
   */
77
  public function summary_title() {
78
    $options = $this->options_form_summary_options();
79
    return check_plain($options[$this->options['view_mode']]);
80
  }
81

  
82
  /**
83
   * {@inheritdoc}
84
   */
85
  public function pre_render($values) {
67 86
    $uids = array();
68 87
    foreach ($values as $row) {
69 88
      $uids[] = $row->{$this->field_alias};
......
71 90
    $this->users = user_load_multiple($uids);
72 91
  }
73 92

  
74
  function render($row) {
93
  /**
94
   * {@inheritdoc}
95
   */
96
  public function render($row) {
75 97
    $account = $this->users[$row->{$this->field_alias}];
76 98
    $account->view = $this->view;
77 99
    $build = user_view($account, $this->options['view_mode']);
78 100

  
79 101
    return drupal_render($build);
80 102
  }
103

  
81 104
}

Formats disponibles : Unified diff