function quant_time_form in Quant 6
Same name and namespace in other branches
- 7 quant.pages.inc \quant_time_form()
Provide a simple form to change time periods
1 string reference to 'quant_time_form'
- quant_page in includes/
pages.inc - The analytics page callback
File
- includes/
forms.inc, line 11 - Form-building functions
Code
function quant_time_form() {
$form = array();
// If jQuery UI, load some javascript for datepicker
if (module_exists('jquery_ui')) {
jquery_ui_add(array(
'ui.datepicker',
));
drupal_add_css(drupal_get_path('module', 'quant') . '/theme/datepicker.css');
drupal_add_js("\n \$(document).ready(function() {\n \$('#edit-custom-to').datepicker();\n \$('#edit-custom-from').datepicker();\n });\n ", 'inline');
}
$period_options = array(
'1_week' => t('1 week'),
'2_weeks' => t('2 weeks'),
'1_month' => t('1 month'),
'3_months' => t('3 months'),
'6_months' => t('6 months'),
'1_year' => t('1 year'),
'2_years' => t('2 years'),
);
$period = filter_xss($_GET['period']);
if (!$period || !array_key_exists($period, $period_options)) {
$period = '1_month';
// Default value
}
$form['message'] = array(
'#type' => 'item',
'#value' => t('Select a timeframe and click Update to see what\'s happening on your site during that time, as well as a total for all the activity during that timeframe.'),
);
$form['option'] = array(
'#type' => 'radios',
'#options' => array(
'period' => '',
'custom' => '',
),
'#default_value' => isset($_GET['option']) ? filter_xss($_GET['option']) : 'period',
);
$form['period'] = array(
'#type' => 'select',
'#options' => $period_options,
'#default_value' => $period,
);
$form['custom_from'] = array(
'#type' => 'textfield',
'#size' => 10,
'#default_value' => isset($_GET['from']) ? filter_xss($_GET['from']) : '',
);
$form['custom_to'] = array(
'#type' => 'textfield',
'#size' => 10,
'#default_value' => isset($_GET['to']) ? filter_xss($_GET['to']) : '',
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Update'),
);
return $form;
}