function views_data_export_plugin_style_export::generate_filename in Views data export 7.3
Same name and namespace in other branches
- 7.4 plugins/views_data_export_plugin_style_export.inc \views_data_export_plugin_style_export::generate_filename()
Generate the filename for the export.
1 call to views_data_export_plugin_style_export::generate_filename()
- views_data_export_plugin_style_export::add_http_headers in plugins/
views_data_export_plugin_style_export.inc - Add any HTTP headers that this style plugin wants to.
File
- plugins/
views_data_export_plugin_style_export.inc, line 319 - Plugin include file for export style plugin.
Class
- views_data_export_plugin_style_export
- Generalized style plugin for export plugins.
Code
function generate_filename() {
$view = $this->view;
$filename = '';
if (isset($this->options['filename']) && !empty($this->options['provide_file'])) {
// General tokens.
$tokens = array(
'%view' => check_plain($view->name),
'%display' => check_plain($view->current_display),
);
// Argument tokens.
$count = 0;
foreach ($view->display_handler
->get_handlers('argument') as $arg => $handler) {
$token = '%' . ++$count;
$tokens[$token . '-title'] = $handler
->get_title();
$tokens[$token . '-value'] = isset($view->args[$count - 1]) ? check_plain($view->args[$count - 1]) : '';
}
// Effective exposed filters token.
$exposed = array();
foreach ($view->display_handler
->get_handlers('filter') as $arg => $handler) {
if (!$handler->options['exposed']) {
continue;
}
if (!empty($view->exposed_input[$handler->options['expose']['identifier']])) {
$identifier = $handler->options['expose']['identifier'];
$option = $view->exposed_input[$identifier];
// The option may be a string or an array or even an array of arrays,
// depending on whether the widget is a text box/area, a select box
// or a date range.
if (is_array($option)) {
// loop over each option
foreach ($option as $key => $item) {
if (!is_array($item)) {
continue;
}
else {
$option[$key] = implode('--', $item);
}
}
$option = implode('--', $option);
}
$exposed[] = check_plain($identifier) . '_' . check_plain($option);
}
}
if (!empty($exposed)) {
$tokens['%exposed'] = implode('-', $exposed);
}
else {
$tokens['%exposed'] = 'default';
}
// Timestamp token.
$time = REQUEST_TIME;
$parts = array(
'full' => 'Y-m-d\\TH-i-s',
'yy' => 'y',
'yyyy' => 'Y',
'mm' => 'm',
'mmm' => 'M',
'dd' => 'd',
'ddd' => 'D',
'hh' => 'H',
'ii' => 'i',
'ss' => 's',
);
foreach ($parts as $part => $format) {
$tokens['%timestamp-' . $part] = format_date($time, 'custom', $format);
}
$filename = strtr($this->options['filename'], $tokens);
}
return $filename;
}