| 1 |
<?php
|
| 2 |
// $Id: date_facets_format.module,v 1.2 2008/08/26 04:28:10 davidlesieur Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Provides formatting options for date-based facets.
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Implementation of hook_menu().
|
| 11 |
*/
|
| 12 |
function date_facets_format_menu() {
|
| 13 |
$items = array();
|
| 14 |
$items['admin/settings/faceted_search/date_format'] = array(
|
| 15 |
'title' => 'Date formats',
|
| 16 |
'page callback' => 'drupal_get_form',
|
| 17 |
'page arguments' => array('date_facets_format_admin_settings_form'),
|
| 18 |
'access arguments' => array('administer faceted search'),
|
| 19 |
'type' => MENU_LOCAL_TASK,
|
| 20 |
);
|
| 21 |
|
| 22 |
return $items;
|
| 23 |
}
|
| 24 |
|
| 25 |
/**
|
| 26 |
* Menu callback for the administration settings.
|
| 27 |
*/
|
| 28 |
function date_facets_format_admin_settings_form() {
|
| 29 |
// Possible date formats (based on choices from system_date_time_settings()).
|
| 30 |
$y = array(
|
| 31 |
'Y',
|
| 32 |
'y',
|
| 33 |
);
|
| 34 |
$ym = array(
|
| 35 |
// Short
|
| 36 |
'Y-m',
|
| 37 |
'Y/m',
|
| 38 |
'Y M',
|
| 39 |
'm/Y',
|
| 40 |
'm.Y',
|
| 41 |
'M Y',
|
| 42 |
// Medium
|
| 43 |
'Y, F',
|
| 44 |
'F, Y',
|
| 45 |
'F Y',
|
| 46 |
);
|
| 47 |
$ymd = array(
|
| 48 |
// Short
|
| 49 |
'Y-m-d',
|
| 50 |
'Y/m/d',
|
| 51 |
'Y M j',
|
| 52 |
'm/d/Y',
|
| 53 |
'M j Y',
|
| 54 |
'd/m/Y',
|
| 55 |
'd.m.Y',
|
| 56 |
'j M Y',
|
| 57 |
// Medium
|
| 58 |
'D, Y-m-d',
|
| 59 |
'D, Y/m/d',
|
| 60 |
'D, m/d/Y',
|
| 61 |
'D, d/m/Y',
|
| 62 |
'Y, F j',
|
| 63 |
'F j, Y',
|
| 64 |
'j F Y',
|
| 65 |
'j F, Y',
|
| 66 |
'j. F Y',
|
| 67 |
// Long
|
| 68 |
'l, Y, F j',
|
| 69 |
'l, F j, Y',
|
| 70 |
'l, j F Y',
|
| 71 |
'l, j F, Y',
|
| 72 |
'l, j. F Y',
|
| 73 |
);
|
| 74 |
foreach ($y as $format) {
|
| 75 |
$y_choices[$format] = format_date(time(), 'custom', $format);
|
| 76 |
}
|
| 77 |
foreach ($ym as $format) {
|
| 78 |
$ym_choices[$format] = format_date(time(), 'custom', $format);
|
| 79 |
}
|
| 80 |
foreach ($ymd as $format) {
|
| 81 |
$ymd_choices[$format] = format_date(time(), 'custom', $format);
|
| 82 |
}
|
| 83 |
$form['format'] = array(
|
| 84 |
'#type' => 'fieldset',
|
| 85 |
'#title' => t('Date formats'),
|
| 86 |
'#description' => t('Choose the display formats to use when navigating date-based facets.'),
|
| 87 |
);
|
| 88 |
$form['format']['date_facets_format_y'] = array(
|
| 89 |
'#type' => 'select',
|
| 90 |
'#title' => t('Year format'),
|
| 91 |
'#description' => t('The format for year display.'),
|
| 92 |
'#options' => $y_choices,
|
| 93 |
'#default_value' => variable_get('date_facets_format_y', $y[0]),
|
| 94 |
);
|
| 95 |
$form['format']['date_facets_format_ym'] = array(
|
| 96 |
'#type' => 'select',
|
| 97 |
'#title' => t('Year & month format'),
|
| 98 |
'#description' => t('The format for year & month display.'),
|
| 99 |
'#options' => $ym_choices,
|
| 100 |
'#default_value' => variable_get('date_facets_format_ym', $ym[1]),
|
| 101 |
);
|
| 102 |
$form['format']['date_facets_format_ymd'] = array(
|
| 103 |
'#type' => 'select',
|
| 104 |
'#title' => t('Full date format'),
|
| 105 |
'#description' => t('The format for full date display.'),
|
| 106 |
'#options' => $ymd_choices,
|
| 107 |
'#default_value' => variable_get('date_facets_format_ymd', $ymd[1]),
|
| 108 |
);
|
| 109 |
return system_settings_form($form);
|
| 110 |
}
|
| 111 |
|