context.install 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. /**
  3. * Implementation of hook_install().
  4. */
  5. function context_install() {
  6. // Nothing todo...
  7. }
  8. /**
  9. * Implementation of hook_uninstall().
  10. */
  11. function context_uninstall() {
  12. drupal_uninstall_schema('context');
  13. variable_del('context_ui_show_empty_regions');
  14. variable_del('context_reaction_block_disable_core');
  15. variable_del('context_reaction_block_all_regions');
  16. }
  17. /**
  18. * Implementation of hook_schema().
  19. */
  20. function context_schema() {
  21. $schema = array();
  22. $schema['context'] = array(
  23. 'description' => 'Storage for normal (user-defined) contexts.',
  24. 'export' => array(
  25. 'key' => 'name',
  26. 'identifier' => 'context',
  27. 'default hook' => 'context_default_contexts', // Function hook name.
  28. 'status' => 'context_status',
  29. 'api' => array(
  30. 'owner' => 'context',
  31. 'api' => 'context', // Base name for api include files.
  32. 'minimum_version' => 3,
  33. 'current_version' => 3,
  34. ),
  35. 'export callback' => 'context_export',
  36. ),
  37. 'fields' => array(
  38. 'name' => array(
  39. 'description' => 'The primary identifier for a context.',
  40. 'type' => 'varchar',
  41. 'length' => 255,
  42. 'not null' => TRUE,
  43. 'default' => '',
  44. ),
  45. 'description' => array(
  46. 'description' => 'Description for this context.',
  47. 'type' => 'varchar',
  48. 'length' => 255,
  49. 'not null' => TRUE,
  50. 'default' => '',
  51. ),
  52. 'tag' => array(
  53. 'description' => 'Tag for this context.',
  54. 'type' => 'varchar',
  55. 'length' => 255,
  56. 'not null' => TRUE,
  57. 'default' => '',
  58. ),
  59. 'conditions' => array(
  60. 'description' => 'Serialized storage of all context condition settings.',
  61. 'type' => 'text',
  62. 'serialize' => TRUE,
  63. ),
  64. 'reactions' => array(
  65. 'description' => 'Serialized storage of all context reaction settings.',
  66. 'type' => 'text',
  67. 'serialize' => TRUE,
  68. ),
  69. 'condition_mode' => array(
  70. 'description' => 'Condition mode for this context.',
  71. 'type' => 'int',
  72. 'default' => 0,
  73. ),
  74. ),
  75. 'primary key' => array('name'),
  76. );
  77. return $schema;
  78. }
  79. /**
  80. * Update 7000: Handle adjustments to split of theme reaction to support D7 preprocess split between _page and _html
  81. */
  82. function context_update_7000() {
  83. drupal_load('module', 'ctools');
  84. drupal_load('module', 'context');
  85. $updated = array();
  86. $contexts = context_load(NULL, TRUE);
  87. foreach ($contexts as $c) {
  88. // if the old data is in the old reaction and the new reaction hasn't been saved, migrate the old data to the new reaction
  89. if (isset($c->reactions['theme']) &&
  90. isset($c->reactions['theme']['class']) &&
  91. !empty($c->reactions['theme']['class']) &&
  92. !isset($c->reactions['theme_html'])
  93. ) {
  94. $c->reactions['theme_html']['class'] = $c->reactions['theme']['class'];
  95. context_save($c);
  96. $updated[] = $c->name;
  97. }
  98. }
  99. if (empty($updated)) {
  100. $ret = t('No contexts requiring migration detected.');
  101. }
  102. else {
  103. $ret = t('The following contexts had theme reaction data migrated: @names', array('@names' => join(', ', $updated)));
  104. }
  105. return $ret;
  106. }