Projet

Général

Profil

Révision 082b75eb

Ajouté par Assos Assos il y a plus de 6 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/entity/views/handlers/entity_views_handler_area_entity.inc
40 40
    $form['entity_id'] = array(
41 41
      '#type' => 'textfield',
42 42
      '#title' => t('Entity id'),
43
      '#description' => t('Choose the entity you want to display in the area.'),
43
      '#description' => t('Choose the entity you want to display in the area. To render an entity given by a contextual filter use "%1" for the first argument, "%2" for the second, etc.'),
44 44
      '#default_value' => $this->options['entity_id'],
45 45
    );
46 46

  
......
105 105
   * Render an entity using the view mode.
106 106
   */
107 107
  public function render_entity($entity_type, $entity_id, $view_mode) {
108
    $tokens = $this->get_render_tokens();
109
    // Replace argument tokens in entity id.
110
    $entity_id = strtr($entity_id, $tokens);
108 111
    if (!empty($entity_type) && !empty($entity_id) && !empty($view_mode)) {
109 112
      $entity = entity_load_single($entity_type, $entity_id);
110 113
      if (!empty($this->options['bypass_access']) || entity_access('view', $entity_type, $entity)) {
......
117 120
      return '';
118 121
    }
119 122
  }
123

  
124
  /**
125
   * Get the 'render' tokens to use for advanced rendering.
126
   *
127
   * This runs through all of the fields and arguments that
128
   * are available and gets their values. This will then be
129
   * used in one giant str_replace().
130
   */
131
  function get_render_tokens() {
132
    $tokens = array();
133
    if (!empty($this->view->build_info['substitutions'])) {
134
      $tokens = $this->view->build_info['substitutions'];
135
    }
136
    $count = 0;
137
    foreach ($this->view->display_handler->get_handlers('argument') as $arg => $handler) {
138
      $token = '%' . ++$count;
139
      if (!isset($tokens[$token])) {
140
        $tokens[$token] = '';
141
      }
142
      // Use strip tags as there should never be HTML in the path.
143
      // However, we need to preserve special characters like " that
144
      // were removed by check_plain().
145
      $tokens['%' . $count] = $handler->argument;
146
    }
147

  
148
    return $tokens;
149
  }
120 150
}

Formats disponibles : Unified diff