Projet

Général

Profil

Paste
Télécharger (2,42 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / ctools / tests / ctools_export_test / ctools_export_test.install @ 1e39edcb

1
<?php
2

    
3
/**
4
 * Implements hook_schema();
5
 */
6
function ctools_export_test_schema() {
7
  $schema['ctools_export_test'] = array(
8
   'description' => 'CTools export test data table',
9
   'export' => array(
10
      'key' => 'machine',
11
      'identifier' => 'ctools_export_test',
12
      'default hook' => 'default_ctools_export_tests',
13
      'bulk export' => TRUE,
14
      'api' => array(
15
        'owner' => 'ctools_export_test',
16
        'api' => 'default_ctools_export_tests',
17
        'minimum_version' => 1,
18
        'current_version' => 1,
19
      ),
20
    ),
21
    'fields' => array(
22
      'machine' => array(
23
        'description' => "The unique machine name (required by ctools).",
24
        'type' => 'varchar',
25
        'length' => 255,
26
        'not null' => TRUE,
27
        'default' => '',
28
      ),
29
      'title' => array(
30
        'description' => "The human readable title.",
31
        'type' => 'varchar',
32
        'length' => 255,
33
        'not null' => TRUE,
34
        'default' => '',
35
      ),
36
      'number' => array(
37
        'description' => "A number.",
38
        'type' => 'int',
39
        'not null' => TRUE,
40
        'default' => 0,
41
      ),
42
      'data' => array(
43
        'type' => 'blob',
44
        'description' => "A serialized array of data.",
45
        'serialize' => TRUE,
46
        'serialized default' => 'a:0:{}',
47
      ),
48
    ),
49
    'primary key' => array('machine'),
50
  );
51

    
52
  return $schema;
53
}
54

    
55
/**
56
 * Implments hook_install();
57
 */
58
function ctools_export_test_install() {
59
  $ctools_export_tests = array();
60
  // Put this default in the database only (no default).
61
  $ctools_export_test = new stdClass();
62
  $ctools_export_test->machine = 'database_test';
63
  $ctools_export_test->title = 'Database test';
64
  $ctools_export_test->number = 0;
65
  $ctools_export_test->data = array(
66
    'test_1' => 'Test 1',
67
    'test_2' => 'Test 2',
68
  );
69
  $ctools_export_tests['database_test'] = $ctools_export_test;
70

    
71
  // Put this default in the database, so we have this in code and in the database.
72
  $ctools_export_test = new stdClass();
73
  $ctools_export_test->machine = 'overridden_test';
74
  $ctools_export_test->title = 'Overridden test';
75
  $ctools_export_test->number = 1;
76
  $ctools_export_test->data = array(
77
    'test_1' => 'Test 1',
78
    'test_2' => 'Test 2',
79
  );
80
  $ctools_export_tests['overridden_test'] = $ctools_export_test;
81

    
82
  foreach ($ctools_export_tests as $ctools_export_test) {
83
    // Save the record to the database.
84
    drupal_write_record('ctools_export_test', $ctools_export_test);
85
  }
86
}