function _date_format_types_build in Date 6.2
Builds and returns the list of available date format types.
Return value
Array of date format types.
2 calls to _date_format_types_build()
- date_get_format_types in ./
date_api.module - Get the list of available date format types and attributes.
- _date_formats_build in ./
date_api.module - Builds and returns the list of available date formats.
File
- ./
date_api.module, line 2075 - This module will make the date API available to other modules. Designed to provide a light but flexible assortment of functions and constants, with more functionality in additional files that are not loaded unless other modules specifically include them.
Code
function _date_format_types_build() {
$types = array();
// Prevent errors in the upgrade before the date_format_types table exists.
if (defined('MAINTENANCE_MODE') && !db_table_exists('date_format_types')) {
return $types;
}
// Get list of modules which implement hook_date_format_types().
$modules = module_implements('date_format_types');
foreach ($modules as $module) {
$module_types = module_invoke($module, 'date_format_types');
foreach ($module_types as $module_type => $type_title) {
$type = array();
$type['module'] = $module;
$type['type'] = $module_type;
$type['title'] = $type_title;
$type['locked'] = 1;
$type['is_new'] = TRUE;
// Will be over-ridden later if in the db.
$types[$module_type] = $type;
}
}
// Get custom formats added to the database by the end user.
$result = db_query('SELECT dft.type, dft.title, dft.locked FROM {date_format_types} dft ORDER BY dft.title');
while ($object = db_fetch_object($result)) {
if (!in_array($object->type, $types)) {
$type = array();
$type['is_new'] = FALSE;
$type['module'] = '';
$type['type'] = $object->type;
$type['title'] = $object->title;
$type['locked'] = $object->locked;
$types[$object->type] = $type;
}
else {
$type = array();
$type['is_new'] = FALSE;
// Over-riding previous setting.
$types[$object->type] = array_merge($types[$object->type], $type);
}
}
// Allow other modules to modify these format types.
drupal_alter('date_format_types', $types);
return $types;
}