function cdn_touch_file_form in CDN 6.2
Same name and namespace in other branches
- 7.2 cdn.stats.inc \cdn_touch_file_form()
@file Per-page CDN integration statistics functionality.
1 string reference to 'cdn_touch_file_form'
- cdn_menu in ./
cdn.module - Implementation of hook_menu().
File
- ./
cdn.stats.inc, line 8 - Per-page CDN integration statistics functionality.
Code
function cdn_touch_file_form(&$form_state) {
// All arguments after the first are in fact the different parts of the file
// path that is being passed in.
$additional_args = func_get_args();
// Ignore the first function argument: this is $form_state.
array_shift($additional_args);
$filepath = implode('/', $additional_args);
// Store the page we should redirect to after the file has been touched, or
// upon cancellation.
if (!isset($form_state['storage']['redirect'])) {
$form_state['storage']['redirect'] = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '<front>';
}
if (!file_exists($filepath)) {
drupal_set_message(t('The file %filepath does not exist and thus could not be touched.', array(
'%filepath' => $filepath,
)), 'error');
drupal_goto($form_state['storage']['redirect']);
}
else {
return confirm_form(array(
'filepath' => array(
'#type' => 'value',
'#value' => $filepath,
),
'redirect' => array(
'#type' => 'value',
'#value' => $form_state['storage']['redirect'],
),
), t('Are you sure you want to touch %filepath?', array(
'%filepath' => $filepath,
)), $form_state['storage']['redirect'], t('This action cannot be undone, but is completely harmless. Touching a file merely means that its last modification date will be updated to \'right now\'.'), t('Touch file'), t('Cancel'));
}
}