panels_mini.install 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?php
  2. /**
  3. * Implementation of hook_schema().
  4. */
  5. function panels_mini_schema() {
  6. // This should always point to our 'current' schema. This makes it relatively easy
  7. // to keep a record of schema as we make changes to it.
  8. return panels_mini_schema_1();
  9. }
  10. /**
  11. * Schema version 1 for Panels in D6.
  12. */
  13. function panels_mini_schema_1() {
  14. $schema = array();
  15. $schema['panels_mini'] = array(
  16. 'export' => array(
  17. 'identifier' => 'mini',
  18. 'load callback' => 'panels_mini_load',
  19. 'load all callback' => 'panels_mini_load_all',
  20. 'save callback' => 'panels_mini_save',
  21. 'delete callback' => 'panels_mini_delete',
  22. 'export callback' => 'panels_mini_export',
  23. 'api' => array(
  24. 'owner' => 'panels_mini',
  25. 'api' => 'panels_default',
  26. 'minimum_version' => 1,
  27. 'current_version' => 1,
  28. ),
  29. ),
  30. 'fields' => array(
  31. 'pid' => array(
  32. 'type' => 'serial',
  33. 'not null' => TRUE,
  34. 'no export' => TRUE,
  35. 'description' => 'The primary key for uniqueness.',
  36. ),
  37. 'name' => array(
  38. 'type' => 'varchar',
  39. 'length' => '255',
  40. 'description' => 'The unique name of the mini panel.',
  41. ),
  42. 'category' => array(
  43. 'type' => 'varchar',
  44. 'length' => '64',
  45. 'description' => 'The category this mini panel appears in on the add content pane.',
  46. ),
  47. 'did' => array(
  48. 'type' => 'int',
  49. 'no export' => TRUE,
  50. 'description' => 'The display ID of the panel.',
  51. ),
  52. 'admin_title' => array(
  53. 'type' => 'varchar',
  54. 'length' => '128',
  55. 'description' => 'The administrative title of the mini panel.',
  56. ),
  57. 'admin_description' => array(
  58. 'type' => 'text',
  59. 'size' => 'big',
  60. 'description' => 'Administrative title of this mini panel.',
  61. 'object default' => '',
  62. ),
  63. 'requiredcontexts' => array(
  64. 'type' => 'text',
  65. 'size' => 'big',
  66. 'serialize' => TRUE,
  67. 'object default' => array(),
  68. 'description' => 'An array of required contexts.',
  69. ),
  70. 'contexts' => array(
  71. 'type' => 'text',
  72. 'size' => 'big',
  73. 'serialize' => TRUE,
  74. 'object default' => array(),
  75. 'description' => 'An array of contexts embedded into the panel.',
  76. ),
  77. 'relationships' => array(
  78. 'type' => 'text',
  79. 'size' => 'big',
  80. 'serialize' => TRUE,
  81. 'object default' => array(),
  82. 'description' => 'An array of relationships embedded into the panel.',
  83. ),
  84. ),
  85. 'primary key' => array('pid'),
  86. 'unique keys' => array(
  87. 'name' => array('name'),
  88. ),
  89. );
  90. return $schema;
  91. }
  92. /**
  93. * Implementation of hook_uninstall().
  94. */
  95. function panels_mini_uninstall() {
  96. $panels_exists = db_table_exists('panels_display');
  97. $result = db_query("SELECT * FROM {panels_mini}");
  98. $deltas = array();
  99. foreach ($result as $panel_mini) {
  100. // Delete all associated displays.
  101. if (!function_exists('panels_delete_display')) {
  102. require_once drupal_get_path('module', 'panels') .'/panels.module';
  103. }
  104. if ($panels_exists) {
  105. panels_delete_display($panel_mini->did);
  106. }
  107. $deltas[] = $panel_mini->pid;
  108. }
  109. if ($deltas) {
  110. // Delete all configured blocks.
  111. db_delete('block')
  112. ->condition('module', 'panels_mini')
  113. ->condition('delta', $deltas)
  114. ->execute();
  115. }
  116. }