ctools_export_test.install 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /**
  3. * Implements hook_schema();
  4. */
  5. function ctools_export_test_schema() {
  6. $schema['ctools_export_test'] = array(
  7. 'description' => 'CTools export test data table',
  8. 'export' => array(
  9. 'key' => 'machine',
  10. 'identifier' => 'ctools_export_test',
  11. 'default hook' => 'default_ctools_export_tests',
  12. 'bulk export' => TRUE,
  13. 'api' => array(
  14. 'owner' => 'ctools_export_test',
  15. 'api' => 'default_ctools_export_tests',
  16. 'minimum_version' => 1,
  17. 'current_version' => 1,
  18. ),
  19. ),
  20. 'fields' => array(
  21. 'machine' => array(
  22. 'description' => "The unique machine name (required by ctools).",
  23. 'type' => 'varchar',
  24. 'length' => 255,
  25. 'not null' => TRUE,
  26. 'default' => '',
  27. ),
  28. 'title' => array(
  29. 'description' => "The human readable title.",
  30. 'type' => 'varchar',
  31. 'length' => 255,
  32. 'not null' => TRUE,
  33. 'default' => '',
  34. ),
  35. 'number' => array(
  36. 'description' => "A number.",
  37. 'type' => 'int',
  38. 'not null' => TRUE,
  39. 'default' => 0,
  40. ),
  41. 'data' => array(
  42. 'type' => 'blob',
  43. 'description' => "A serialized array of data.",
  44. 'serialize' => TRUE,
  45. 'serialized default' => 'a:0:{}',
  46. ),
  47. ),
  48. 'primary key' => array('machine'),
  49. );
  50. return $schema;
  51. }
  52. /**
  53. * Implments hook_install();
  54. */
  55. function ctools_export_test_install() {
  56. $ctools_export_tests = array();
  57. // Put this default in the database only (no default).
  58. $ctools_export_test = new stdClass();
  59. $ctools_export_test->machine = 'database_test';
  60. $ctools_export_test->title = 'Database test';
  61. $ctools_export_test->number = 0;
  62. $ctools_export_test->data = array(
  63. 'test_1' => 'Test 1',
  64. 'test_2' => 'Test 2',
  65. );
  66. $ctools_export_tests['database_test'] = $ctools_export_test;
  67. // Put this default in the database, so we have this in code and in the database.
  68. $ctools_export_test = new stdClass();
  69. $ctools_export_test->machine = 'overridden_test';
  70. $ctools_export_test->title = 'Overridden test';
  71. $ctools_export_test->number = 1;
  72. $ctools_export_test->data = array(
  73. 'test_1' => 'Test 1',
  74. 'test_2' => 'Test 2',
  75. );
  76. $ctools_export_tests['overridden_test'] = $ctools_export_test;
  77. foreach ($ctools_export_tests as $ctools_export_test) {
  78. // Save the record to the database.
  79. drupal_write_record('ctools_export_test', $ctools_export_test);
  80. }
  81. }