openlayers_test.install 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <?php
  2. /**
  3. * @file
  4. * This file holds the functions for the installing
  5. * and enabling of the openlayers_test module.
  6. *
  7. * @ingroup openlayers
  8. */
  9. /**
  10. * Implementation of hook_install().
  11. */
  12. function openlayers_test_install() {
  13. // Create test content type to be used with CCK and Views.
  14. // Only do this if CCK and Views are installed.
  15. if (module_exists('content') && module_exists('views') && module_exists('content_copy')) {
  16. // Create content type first
  17. $node_type = array(
  18. 'type' => 'openlayers_test_type',
  19. 'name' => st('OpenLayers Test Type'),
  20. 'module' => 'node',
  21. 'description' => st('This is a test content type for OpenLayers.'),
  22. 'custom' => TRUE,
  23. 'modified' => TRUE,
  24. 'locked' => TRUE,
  25. );
  26. $node_type = (object)_node_type_set_defaults($node_type);
  27. node_type_save($node_type);
  28. // Default to not promoted.
  29. variable_set('node_options_openlayers_test_type', array('status'));
  30. // The import process of CCK is not simply calling a function,
  31. // so we just feed the submit function the correct values
  32. module_load_include('inc', 'node', 'content_types.inc');
  33. module_load_include('inc', 'content', 'includes/content.admin.inc');
  34. module_load_include('inc', 'content', 'includes/content.crud');
  35. module_load_include('module', 'content_copy', 'content_copy');
  36. // Leverage macro making function
  37. $GLOBALS['content_copy']['submissions'] = _openlayers_test_content_definition();
  38. $macro = content_copy_get_macro();
  39. // Make form array
  40. $form = array();
  41. $form_state = array(
  42. 'values' => array(
  43. 'type_name' => 'openlayers_test_type',
  44. 'macro' => $macro,
  45. ),
  46. );
  47. // Call submit function
  48. content_copy_import_form_submit($form, $form_state);
  49. }
  50. }
  51. /**
  52. * Implementation of hook_uninstall().
  53. */
  54. function openlayers_test_uninstall() {
  55. // Remove any added data (check for function)
  56. if (function_exists('node_type_delete')) {
  57. node_type_delete('openlayers_test_type');
  58. }
  59. // Get module variables
  60. $variables = db_query("SELECT v.name FROM {variable} AS v WHERE v.name LIKE ':pattern'",
  61. array(':pattern' => db_like('openlayers_test_') . '%'))->fetchAll();
  62. // Remove variables
  63. foreach ($variables as $v) {
  64. variable_del($v);
  65. }
  66. }
  67. /**
  68. * Get content type definition with fields.
  69. *
  70. * Retireives content type definition and fields
  71. * as exported from CCK.
  72. */
  73. function _openlayers_test_content_definition() {
  74. $content['type'] = array(
  75. 'name' => 'OpenLayers Test Type',
  76. 'type' => 'openlayers_test_type',
  77. 'description' => 'This is a content type for testing OpenLayers functionality.',
  78. 'title_label' => 'Title',
  79. 'body_label' => 'Body',
  80. 'min_word_count' => '0',
  81. 'help' => '',
  82. 'node_options' =>
  83. array(
  84. 'status' => TRUE,
  85. 'promote' => FALSE,
  86. 'sticky' => FALSE,
  87. 'revision' => FALSE,
  88. ),
  89. 'old_type' => 'openlayers_test_type',
  90. 'orig_type' => 'openlayers_test_type',
  91. 'module' => 'node',
  92. 'custom' => '1',
  93. 'modified' => '1',
  94. 'locked' => '1',
  95. 'comment' => 2,
  96. 'comment_default_mode' => 4,
  97. 'comment_default_order' => 1,
  98. 'comment_default_per_page' => 50,
  99. 'comment_controls' => 3,
  100. 'comment_anonymous' => 0,
  101. 'comment_subject_field' => 1,
  102. 'comment_preview' => 1,
  103. 'comment_form_location' => 0,
  104. );
  105. $content['fields'] = array(
  106. 0 =>
  107. array(
  108. 'label' => 'OpenLayers Test WKT',
  109. 'field_name' => 'field_openlayers_test_wkt',
  110. 'type' => 'openlayers_wkt',
  111. 'widget_type' => 'openlayers_wkt_widget',
  112. 'change' => 'Change basic information',
  113. 'weight' => '31',
  114. 'openlayers_cck_map' => 'default',
  115. 'description' => 'This is some help text for this field.',
  116. 'default_value' =>
  117. array(
  118. 0 =>
  119. array(
  120. 'openlayers_wkt' => '',
  121. ),
  122. ),
  123. 'default_value_php' => '',
  124. 'default_value_widget' => NULL,
  125. 'group' => FALSE,
  126. 'required' => 0,
  127. 'multiple' => '0',
  128. 'openlayers_cck_feature_types' =>
  129. array(
  130. 'point' => 'point',
  131. 'path' => 'path',
  132. 'polygon' => 'polygon',
  133. ),
  134. 'op' => 'Save field settings',
  135. 'module' => 'openlayers_cck',
  136. 'widget_module' => 'openlayers_cck',
  137. 'columns' =>
  138. array(
  139. 'openlayers_wkt' =>
  140. array(
  141. 'type' => 'text',
  142. 'size' => 'big',
  143. 'not null' => FALSE,
  144. 'sortable' => TRUE,
  145. 'views' => TRUE,
  146. ),
  147. ),
  148. 'display_settings' =>
  149. array(
  150. 'label' =>
  151. array(
  152. 'format' => 'above',
  153. 'exclude' => 0,
  154. ),
  155. 'teaser' =>
  156. array(
  157. 'format' => 'default',
  158. 'exclude' => 0,
  159. ),
  160. 'full' =>
  161. array(
  162. 'format' => 'default',
  163. 'exclude' => 0,
  164. ),
  165. 4 =>
  166. array(
  167. 'format' => 'default',
  168. 'exclude' => 0,
  169. ),
  170. ),
  171. ),
  172. );
  173. $content['extra'] = array(
  174. 'title' => '-5',
  175. 'body_field' => '0',
  176. 'revision_information' => '20',
  177. 'comment_settings' => '30',
  178. 'menu' => '-2',
  179. );
  180. return $content;
  181. }