function partial_date_type_format_elements in Partial Date 7
2 calls to partial_date_type_format_elements()
File
- ./
partial_date.pages.inc, line 52 - Page and form callbacks for handling the date format.
Code
function partial_date_type_format_elements($settings, $field = NULL, $instance = NULL, $view_mode = NULL) {
$elements['meridiem'] = array(
'#type' => 'radios',
'#title' => t('Ante meridiem and Post meridiem format'),
'#options' => partial_date_meridiem_options(),
'#default_value' => !isset($settings['meridiem']) ? 'a' : $settings['meridiem'],
);
$elements['year_designation'] = array(
'#type' => 'radios',
'#title' => t('Year designation format'),
'#default_value' => !isset($settings['year_designation']) ? 'ce' : $settings['year_designation'],
'#options' => partial_date_year_designation_options(),
'#required' => TRUE,
'#description' => t('This controls how year designation is handled: 1BC = 1BCE = -1 and 1AD = 1CE = 1.'),
);
$elements['display'] = array(
'#type' => 'fieldset',
'#title' => t('Component display'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$elements['separator'] = array(
'#type' => 'fieldset',
'#title' => t('Component separators'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$elements['separator']['date'] = array(
'#type' => 'textfield',
'#title' => t('Date component separators'),
'#maxlength' => 15,
'#size' => 8,
'#default_value' => !isset($settings['separator']['date']) ? ' ' : $settings['separator']['date'],
);
$elements['separator']['time'] = array(
'#type' => 'textfield',
'#title' => t('Time component separators'),
'#maxlength' => 15,
'#size' => 8,
'#default_value' => !isset($settings['separator']['time']) ? ' ' : $settings['separator']['time'],
);
$elements['separator']['datetime'] = array(
'#type' => 'textfield',
'#title' => t('Date and time separators'),
'#size' => 8,
'#maxlength' => 15,
'#default_value' => !isset($settings['separator']['datetime']) ? ' ' : $settings['separator']['datetime'],
);
$elements['separator']['other'] = array(
'#type' => 'textfield',
'#title' => t('Other separators'),
'#size' => 8,
'#maxlength' => 15,
'#default_value' => !isset($settings['separator']['other']) ? ' ' : $settings['separator']['other'],
);
$elements['separator']['range'] = array(
'#type' => 'textfield',
'#title' => t('Range separator'),
'#size' => 8,
'#maxlength' => 15,
'#default_value' => !isset($settings['separator']['range']) ? '' : $settings['separator']['range'],
'#description' => t('This separator is used to seperate date components in the range element. This defaults to " to " if this field is empty. Add spaces if you need spaces between the separator and the date values.'),
);
$custom = array(
'c1' => t('Custom component 1'),
'c2' => t('Custom component 2'),
'c3' => t('Custom component 3'),
'approx' => t('Approximation text'),
);
foreach (partial_date_components() + $custom as $key => $label) {
$component = empty($settings['components'][$key]) ? array(
'weight' => 0,
) : $settings['components'][$key];
$elements['components'][$key] = array(
'#weight' => $component['weight'],
);
$elements['components'][$key]['label'] = array(
'#markup' => $label,
);
if (in_array($key, array(
'c1',
'c2',
'c3',
'approx',
))) {
$component += array(
'value' => '',
'empty' => '',
'weight' => 0,
);
$elements['components'][$key]['value'] = array(
'#type' => 'textfield',
'#title' => $label,
'#title_display' => 'invisible',
'#default_value' => isset($component['value']) ? $component['value'] : '',
);
if ($key == 'approx') {
$elements['components'][$key]['value']['#description'] = t('Only shows if the date is flagged as approximate.');
}
}
else {
$component += array(
'format' => '',
);
$elements['display'][$key] = array(
'#type' => 'select',
'#title' => t('Display source for %label', array(
'%label' => $label,
)),
'#options' => partial_date_estimate_handling_options(),
'#default_value' => $settings['display'][$key],
'#required' => TRUE,
);
if ($key == 'timezone') {
$options =& $elements['display'][$key]['#options'];
$options = array_intersect_key($options, array(
'none' => 1,
'date_only' => 1,
));
}
$elements['components'][$key]['format'] = array(
'#type' => 'radios',
'#title' => t('Format for %label', array(
'%label' => $label,
)),
'#title_display' => 'invisible',
'#options' => partial_date_component_format_options($key),
'#default_value' => $component['format'],
'#required' => TRUE,
);
$elements['components'][$key]['empty'] = array(
'#type' => 'textfield',
'#title' => t('Empty text for %label', array(
'%label' => $label,
)),
'#title_display' => 'invisible',
'#default_value' => $component['empty'],
'#size' => 8,
);
}
$elements['components'][$key]['weight'] = array(
'#type' => 'weight',
'#title' => t('Weight for %label', array(
'%label' => $label,
)),
'#title_display' => 'invisible',
'#default_value' => $component['weight'],
'#required' => TRUE,
);
}
$elements['components']['#theme'] = 'partial_date_format_settings_form';
return $elements;
}