function gmap_cck_field_settings in GMap Addons 5
Same name and namespace in other branches
- 6 gmap_cck.module \gmap_cck_field_settings()
- 7 gmap_cck.module \gmap_cck_field_settings()
Handle the parameters for a field.
Parameters
$op: The operation to be performed. Possible values:
- "form": Display the field settings form.
- "validate": Check the field settings form for errors.
- "save": Declare which fields to save back to the database.
- "database columns": Declare the columns that content.module should create and manage on behalf of the field. If the field module wishes to handle its own database storage, this should be omitted.
- "callbacks": Describe the field's behaviour regarding hook_field operations.
- "tables" : Declare the Views tables informations for the field. Use this operator only if you need to override CCK's default general-purpose implementation. In this case, it is probably a good idea to use the default definitions returned by content_views_field_tables($field) as a start point for your own definitions.
- "arguments" : Declare the Views arguments informations for the field. Use this operator only if you need to override CCK's default general-purpose implementation. In this case, it is probably a good idea to use the default definitions returned by content_views_field_arguments($field) as a start point for your own definitions.
- "filters": Declare the Views filters available for the field. (this is used in CCK's default Views tables definition) They always apply to the first column listed in the "database columns" array.
$field: The field on which the operation is to be performed.
Return value
This varies depending on the operation.
- "form": an array of form elements to add to the settings page.
- "validate": no return value. Use form_set_error().
- "save": an array of names of form elements to be saved in the database.
- "database columns": an array keyed by column name, with arrays of column information as values. This column information must include "type", the MySQL data type of the column, and may also include a "sortable" parameter to indicate to views.module that the column contains ordered information. Details of other information that can be passed to the database layer can be found at content_db_add_column().
- "callbacks": an array describing the field's behaviour regarding hook_field operations. The array is keyed by hook_field operations ('view', 'validate'...) and has the following possible values : CONTENT_CALLBACK_NONE : do nothing for this operation CONTENT_CALLBACK_CUSTOM : use the behaviour in hook_field(operation) CONTENT_CALLBACK_DEFAULT : use content.module's default bahaviour Note : currently only the 'view' operation implements this feature. All other field operation implemented by the module _will_ be executed no matter what.
- "tables": an array of 'tables' definitions as expected by views.module (see Views Documentation).
- "arguments": an array of 'arguments' definitions as expected by views.module (see Views Documentation).
- "filters": an array of 'filters' definitions as expected by views.module (see Views Documentation). When providing several filters, it is recommended to use the 'name' attribute in order to let the user distinguish between them. If no 'name' is specified for a filter, the key of the filter will be used instead.
File
- ./
gmap_cck.module, line 90 - display of a google map as cck field
Code
function gmap_cck_field_settings($op, $field) {
switch ($op) {
case 'form':
$def = gmap_defaults();
foreach (array(
'maptype',
'controltype',
'width',
'height',
'latlong',
) as $key) {
if (isset($field[$key]) && !empty($field[$key])) {
$def[$key] = $field[$key];
}
}
$form = gmap_macro_builder_form($def);
$form['#title'] = t('Google Map settings');
// keep: mapdiv
unset($form['macroform']['overlayedit']);
unset($form['macroform']['mapid']);
// keep: maptype, controltype
unset($form['macroform']['address']);
//unset($form['macroform']['latlong']);
// keep: width, height, alignment, zoom
unset($form['macroform']['macro']);
// GPX file support
$gpx_opts = array(
t('Disabled'),
);
if (module_exists('filefield')) {
$gpx_opts['filefield'] = t('CCK Filefield');
}
// TODO: attachment to node, uploaded file, url from user, ...
if (count($gpx_opts) > 1) {
$form['gpx'] = array(
'#type' => 'select',
'#title' => t("GPX File support"),
'#options' => array(
0 => t('Disabled'),
'filefield' => t('CCK Filefield'),
),
'#default_value' => $field['gpx'],
);
// if gpx-support is enabled we need a source for the data
$form['gpx_src'] = array(
'#type' => 'textfield',
'#title' => t('GPX data source parameter'),
'#description' => t('Only used if gpx-support is enabled'),
'#default_value' => $field['gpx_src'],
);
}
// noderef field(s) to nodes with locations for markers
if (module_exists('nodereference')) {
$form['marker_noderef'] = array(
'#type' => 'textfield',
'#title' => t('Marker noderef'),
'#description' => t('Name of noderef field to nodes to show as markers'),
'#default_value' => $field['marker_noderef'],
);
}
return $form;
case 'validate':
// check stuff entered in form-fields
break;
case 'save':
return array(
'maptype',
'controltype',
'width',
'height',
'alignment',
'zoom',
'latlong',
'gpx',
'gpx_src',
'marker_noderef',
);
case 'database columns':
$columns = array(
// TODO: ??? type -> longtext ???
'value' => array(
'type' => 'varchar',
'length' => 255,
'not null' => true,
'default' => "''",
'sortable' => false,
),
);
return $columns;
case 'callbacks':
// CHECK: ??? any effect on calling ..._field() ???
return array(
'view' => CONTENT_CALLBACK_CUSTOM,
);
}
}