You are here

function geolocation_field_settings in Geolocation Field 6

Implementation of hook_field_settings().

File

./geolocation.module, line 32

Code

function geolocation_field_settings($op, $field) {
  switch ($op) {
    case 'form':

      // Create the form element to be used on the field
      // settings form. Field settings will be the same for
      // all shared instances of the same field and should
      // define the way the value will be stored
      // in the database.
      break;
    case 'save':

      // Return an array of the names of the field settings
      // defined by this module. These are the items that
      // CCK will store in the field definition
      // and they will be available in the $field array.
      // This should match the items defined in 'form' above.
      break;
    case 'database columns':

      // Define the database storage for this field using
      // the same construct used by schema API. Most fields
      // have only one column, but there can be any number
      // of different columns. After the schema API values,
      // add two optional values to each column,
      //  'views', to define a Views field
      //  'sortable', to add a Views sort field
      $columns = array(
        'lat' => array(
          'description' => 'Stores the latitude value',
          'type' => 'float',
          'size' => 'big',
          'not null' => TRUE,
          'default' => 0,
        ),
        'lng' => array(
          'description' => 'Stores the longitude value',
          'type' => 'float',
          'size' => 'big',
          'not null' => TRUE,
          'default' => 0,
        ),
        'lat_sin' => array(
          'description' => 'Stores the sine of latitude',
          'type' => 'float',
          'not null' => TRUE,
          'default' => 0,
        ),
        'lat_cos' => array(
          'description' => 'Stores the cosine of latitude',
          'type' => 'float',
          'not null' => TRUE,
          'default' => 0,
        ),
        'lng_rad' => array(
          'description' => 'Stores the radian longitude',
          'type' => 'float',
          'not null' => TRUE,
          'default' => 0,
        ),
      );
      return $columns;
    case 'views data':

      // Optional: Make changes to the default $data array
      // created for Views. Omit this if no changes are
      // needed, use it to add a custom handler or make
      // other changes.
      // Start with the $data created by CCK
      // and alter it as needed. The following
      // code illustrates how you would retrieve
      // the necessary data.
      $data = content_views_field_views_data($field);
      $db_info = content_database_info($field);
      $table_alias = content_views_tablename($field);
      $field_data = $data[$table_alias][$field['field_name'] . '_value'];

      // Make changes to $data as needed here.
      return $data;
  }
}