Projet

Général

Profil

Révision 503b3f7b

Ajouté par Assos Assos il y a environ 10 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/entity/views/entity.views.inc
389 389
      // Add in any reverse-relationships which have been determined.
390 390
      $data += $this->relationships;
391 391
    }
392
    if (!empty($this->info['revision table']) && !empty($this->info['entity keys']['revision'])) {
393
      $revision_table = $this->info['revision table'];
394

  
395
      $data[$table]['table']['default_relationship'] = array(
396
        $revision_table => array(
397
          'table' => $revision_table,
398
          'field' => $this->info['entity keys']['revision'],
399
        ),
400
      );
401

  
402
      // Define the base group of this table. Fields that don't
403
      // have a group defined will go into this field by default.
404
      $data[$revision_table]['table']['group']  = drupal_ucfirst($this->info['label']) . ' ' . t('Revisions');
405
      $data[$revision_table]['table']['entity type'] = $this->type;
406

  
407
      // If the plural label isn't available, use the regular label.
408
      $label = isset($this->info['plural label']) ? $this->info['plural label'] : $this->info['label'];
409
      $data[$revision_table]['table']['base'] = array(
410
        'field' => $this->info['entity keys']['revision'],
411
        'access query tag' => $this->type . '_access',
412
        'title' => drupal_ucfirst($label) . ' ' . t('Revisions'),
413
        'help' => (isset($this->info['description']) ? $this->info['description'] . ' ' : '') . t('Revisions'),
414
      );
415
      $data[$revision_table]['table']['entity type'] = $this->type;
416
      $data[$revision_table] += $this->schema_revision_fields();
417

  
418
      // Add in any reverse-relationships which have been determined.
419
      $data += $this->relationships;
420

  
421
      // For other base tables, explain how we join.
422
      $data[$revision_table]['table']['join'] = array(
423
        // Directly links to base table.
424
        $table => array(
425
          'left_field' => $this->info['entity keys']['revision'],
426
          'field' => $this->info['entity keys']['revision'],
427
        ),
428
      );
429
      $data[$revision_table]['table']['default_relationship'] = array(
430
        $table => array(
431
          'table' => $table,
432
          'field' => $this->info['entity keys']['id'],
433
        ),
434
      );
435
    }
392 436
    return $data;
393 437
  }
394 438

  
......
411 455
    return $data;
412 456
  }
413 457

  
458
  /**
459
   * Try to come up with some views fields with the help of the revision schema
460
   * and the entity property information.
461
   */
462
  protected function schema_revision_fields() {
463
    $data = array();
464
    if (!empty($this->info['revision table'])) {
465
      $schema = drupal_get_schema($this->info['revision table']);
466
      $properties = entity_get_property_info($this->type) + array('properties' => array());
467

  
468
      foreach ($properties['properties'] as $name => $property_info) {
469
        if (isset($property_info['schema field']) && isset($schema['fields'][$property_info['schema field']])) {
470
          if ($views_info = $this->map_from_schema_info($name, $schema['fields'][$property_info['schema field']], $property_info)) {
471
            $data[$name] = $views_info;
472
          }
473
        }
474
      }
475
    }
476
    return $data;
477
  }
478

  
414 479
  /**
415 480
   * Comes up with views information based on the given schema and property
416 481
   * info.

Formats disponibles : Unified diff