View source
<?php
function gm3_field_field_schema($field) {
switch ($field['type']) {
case 'gm3_point':
return array(
'columns' => array(
'latitude' => array(
'type' => 'float',
'not null' => TRUE,
'size' => 'big',
),
'longitude' => array(
'type' => 'float',
'not null' => TRUE,
'size' => 'big',
),
),
'indexes' => array(
'latitude' => array(
'latitude',
),
'longitude' => array(
'longitude',
),
),
);
case 'gm3_polygon':
return array(
'columns' => array(
'polygon' => array(
'type' => 'text',
'size' => 'medium',
'not null' => TRUE,
),
),
);
case 'gm3_rectangle':
return array(
'columns' => array(
'rectangle' => array(
'type' => 'text',
'size' => 'medium',
'not null' => TRUE,
),
),
);
case 'gm3_polyline':
return array(
'columns' => array(
'polyline' => array(
'type' => 'text',
'size' => 'medium',
'not null' => TRUE,
),
),
);
case 'gm3_combination':
$schema = array();
if (module_exists('gm3_region_field')) {
module_load_include('install', 'gm3_region_field');
$schema = gm3_region_field_field_schema(array(
'type' => 'gm3_region',
));
}
$schema = array_merge_recursive($schema, gm3_field_field_schema(array(
'type' => 'gm3_point',
)), gm3_field_field_schema(array(
'type' => 'gm3_polygon',
)), gm3_field_field_schema(array(
'type' => 'gm3_polyline',
)), gm3_field_field_schema(array(
'type' => 'gm3_rectangle',
)));
foreach ($schema['columns'] as $column_name => $x) {
if (isset($schema['columns'][$column_name]['not null'])) {
unset($schema['columns'][$column_name]['not null']);
}
}
$schema = array_merge_recursive($schema, array(
'columns' => array(
'gm3_type' => array(
'type' => 'varchar',
'length' => 32,
),
),
'indexes' => array(
'gm3_type' => array(
'gm3_type',
),
),
));
return $schema;
break;
}
}