191 lines
5.1 KiB
Plaintext
191 lines
5.1 KiB
Plaintext
<?php
|
|
|
|
/**
|
|
* @file
|
|
* This file holds the functions for the installing
|
|
* and enabling of the openlayers_test module.
|
|
*
|
|
* @ingroup openlayers
|
|
*/
|
|
|
|
/**
|
|
* Implementation of hook_install().
|
|
*/
|
|
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);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Implementation of hook_uninstall().
|
|
*/
|
|
function openlayers_test_uninstall() {
|
|
// Remove any added data (check for function)
|
|
if (function_exists('node_type_delete')) {
|
|
node_type_delete('openlayers_test_type');
|
|
}
|
|
|
|
// Get module variables
|
|
$variables = db_query("SELECT v.name FROM {variable} AS v WHERE v.name LIKE ':pattern'",
|
|
array(':pattern' => db_like('openlayers_test_') . '%'))->fetchAll();
|
|
// Remove variables
|
|
foreach ($variables as $v) {
|
|
variable_del($v);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Get content type definition with fields.
|
|
*
|
|
* Retireives content type definition and fields
|
|
* as exported from CCK.
|
|
*/
|
|
function _openlayers_test_content_definition() {
|
|
$content['type'] = array(
|
|
'name' => 'OpenLayers Test Type',
|
|
'type' => 'openlayers_test_type',
|
|
'description' => 'This is a content type for testing OpenLayers functionality.',
|
|
'title_label' => 'Title',
|
|
'body_label' => 'Body',
|
|
'min_word_count' => '0',
|
|
'help' => '',
|
|
'node_options' =>
|
|
array(
|
|
'status' => TRUE,
|
|
'promote' => FALSE,
|
|
'sticky' => FALSE,
|
|
'revision' => FALSE,
|
|
),
|
|
'old_type' => 'openlayers_test_type',
|
|
'orig_type' => 'openlayers_test_type',
|
|
'module' => 'node',
|
|
'custom' => '1',
|
|
'modified' => '1',
|
|
'locked' => '1',
|
|
'comment' => 2,
|
|
'comment_default_mode' => 4,
|
|
'comment_default_order' => 1,
|
|
'comment_default_per_page' => 50,
|
|
'comment_controls' => 3,
|
|
'comment_anonymous' => 0,
|
|
'comment_subject_field' => 1,
|
|
'comment_preview' => 1,
|
|
'comment_form_location' => 0,
|
|
);
|
|
$content['fields'] = array(
|
|
0 =>
|
|
array(
|
|
'label' => 'OpenLayers Test WKT',
|
|
'field_name' => 'field_openlayers_test_wkt',
|
|
'type' => 'openlayers_wkt',
|
|
'widget_type' => 'openlayers_wkt_widget',
|
|
'change' => 'Change basic information',
|
|
'weight' => '31',
|
|
'openlayers_cck_map' => 'default',
|
|
'description' => 'This is some help text for this field.',
|
|
'default_value' =>
|
|
array(
|
|
0 =>
|
|
array(
|
|
'openlayers_wkt' => '',
|
|
),
|
|
),
|
|
'default_value_php' => '',
|
|
'default_value_widget' => NULL,
|
|
'group' => FALSE,
|
|
'required' => 0,
|
|
'multiple' => '0',
|
|
'openlayers_cck_feature_types' =>
|
|
array(
|
|
'point' => 'point',
|
|
'path' => 'path',
|
|
'polygon' => 'polygon',
|
|
),
|
|
'op' => 'Save field settings',
|
|
'module' => 'openlayers_cck',
|
|
'widget_module' => 'openlayers_cck',
|
|
'columns' =>
|
|
array(
|
|
'openlayers_wkt' =>
|
|
array(
|
|
'type' => 'text',
|
|
'size' => 'big',
|
|
'not null' => FALSE,
|
|
'sortable' => TRUE,
|
|
'views' => TRUE,
|
|
),
|
|
),
|
|
'display_settings' =>
|
|
array(
|
|
'label' =>
|
|
array(
|
|
'format' => 'above',
|
|
'exclude' => 0,
|
|
),
|
|
'teaser' =>
|
|
array(
|
|
'format' => 'default',
|
|
'exclude' => 0,
|
|
),
|
|
'full' =>
|
|
array(
|
|
'format' => 'default',
|
|
'exclude' => 0,
|
|
),
|
|
4 =>
|
|
array(
|
|
'format' => 'default',
|
|
'exclude' => 0,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
$content['extra'] = array(
|
|
'title' => '-5',
|
|
'body_field' => '0',
|
|
'revision_information' => '20',
|
|
'comment_settings' => '30',
|
|
'menu' => '-2',
|
|
);
|
|
|
|
return $content;
|
|
} |