You are here

function openlayers_test_install in Openlayers 6.2

Same name and namespace in other branches
  1. 7.2 tests/openlayers_test.install \openlayers_test_install()

Implementation of hook_install().

File

tests/openlayers_test.install, line 14
This file holds the functions for the installing and enabling of the openlayers_test module.

Code

function openlayers_test_install() {

  // Create test content type to be used with CCK and Views.
  // Only do this if CCK and Views are installed.
  if (module_exists('content') && module_exists('views') && module_exists('content_copy')) {

    // Create content type first
    $node_type = array(
      'type' => 'openlayers_test_type',
      'name' => st('OpenLayers Test Type'),
      'module' => 'node',
      'description' => st('This is a test content type for OpenLayers.'),
      'custom' => TRUE,
      'modified' => TRUE,
      'locked' => TRUE,
    );
    $node_type = (object) _node_type_set_defaults($node_type);
    node_type_save($node_type);

    // Default to not promoted.
    variable_set('node_options_openlayers_test_type', array(
      'status',
    ));

    // The import process of CCK is not simply calling a function,
    // so we just feed the submit function the correct values
    module_load_include('inc', 'node', 'content_types.inc');
    module_load_include('inc', 'content', 'includes/content.admin.inc');
    module_load_include('inc', 'content', 'includes/content.crud');
    module_load_include('module', 'content_copy', 'content_copy');

    // Leverage macro making function
    $GLOBALS['content_copy']['submissions'] = _openlayers_test_content_definition();
    $macro = content_copy_get_macro();

    // Make form array
    $form = array();
    $form_state = array(
      'values' => array(
        'type_name' => 'openlayers_test_type',
        'macro' => $macro,
      ),
    );

    // Call submit function
    content_copy_import_form_submit($form, $form_state);
  }
}