ctools_export_test.install 2.4 KB

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