modules/custom/deims_variable/deims_variable.module
<?php
/**
* @file
* Provides a custom field for DEIMS data source variables.
*
* This module would have been named 'variable' but it conflicts with an
* existing namespace on Drupal.org.
*/
require_once dirname(__FILE__) . '/deims_variable.field.inc';
/**
* The nominal variable type.
*/
define('DEIMS_VARIABLE_TYPE_NOMINAL', '');
/**
* The physical measurement variable type.
*/
define('DEIMS_VARIABLE_TYPE_PHYSICAL', 'physical');
/**
* The date or time variable type.
*/
define('DEIMS_VARIABLE_TYPE_DATE', 'date');
/**
* The list/code variable type.
*/
define('DEIMS_VARIABLE_TYPE_CODES', 'codes');
/**
* Implements hook_menu().
*/
function deims_variable_menu() {
$info = array();
$info['deims-variable/field-remove-item/ajax'] = array(
'title' => 'Remove item callback',
'page callback' => 'deims_variable_remove_js',
'delivery callback' => 'ajax_deliver',
'access callback' => TRUE,
'theme callback' => 'ajax_base_page_theme',
'type' => MENU_CALLBACK,
'file' => 'deims_variable.field.inc',
);
return $info;
}
/**
* Implements hook_theme().
*/
function deims_variable_theme() {
$theme['deims_variable_summary'] = array(
'variables' => array('variable' => NULL),
'file' => 'deims_variable.theme.inc',
'template' => 'deims-variable-summary',
);
$theme['deims_variable_table'] = array(
'variables' => array('variables' => array()),
'file' => 'deims_variable.theme.inc',
);
$theme['deims_variable_codes_list'] = array(
'variables' => array(
'codes' => array(),
'title' => NULL,
'type' => 'ul',
'attributes' => array(),
),
'file' => 'deims_variable.theme.inc',
);
return $theme;
}
function _deims_variable_types() {
return array(
DEIMS_VARIABLE_TYPE_NOMINAL => t('Nominal'),
DEIMS_VARIABLE_TYPE_PHYSICAL => t('Physical quantity'),
DEIMS_VARIABLE_TYPE_DATE => t('Date/time'),
DEIMS_VARIABLE_TYPE_CODES => t('Code list'),
);
}
function deims_variable_type_label($type) {
$types = _deims_variable_types();
return $types[$type];
}
/**
* Implements hook_migrate_api().
*/
function deims_variable_migrate_api() {
return array(
'api' => 2,
'field handlers' => array(
'DeimsVariableMigrateFieldHandler',
),
);
}