function views_autorefresh_views_ajax_data_alter in Views Auto-Refresh 7
Same name and namespace in other branches
- 7.2 views_autorefresh.module \views_autorefresh_views_ajax_data_alter()
Implementation of hook_views_ajax_data_alter().
File
- ./
views_autorefresh.module, line 96
Code
function views_autorefresh_views_ajax_data_alter(&$commands, $view) {
$autorefresh = views_autorefresh_get_settings($view);
if (isset($_REQUEST['autorefresh']) && $_REQUEST['autorefresh'] && $autorefresh) {
$view_name_id = $view->name . '-' . $view->current_display;
$view_dom = '.view-dom-id-' . $view->dom_id;
if ($commands) {
foreach ($commands as $key => &$command) {
if (!empty($autorefresh['incremental']) && $command['command'] == 'insert' && $command['selector'] == $view_dom) {
$command['command'] = 'viewsAutoRefreshIncremental';
$command['view_name'] = $view_name_id;
}
if ($command['command'] == 'viewsScrollTop') {
unset($commands[$key]);
}
}
}
$timestamp = views_autorefresh_get_timestamp($view);
if ($timestamp) {
$commands[] = array(
'command' => 'viewsAutoRefreshTriggerUpdate',
'selector' => $view_dom,
'timestamp' => $timestamp,
);
}
}
}