You are here

function views_autorefresh_ajax_data_alter in Views Hacks 6

Implementation of hook_ajax_data_alter().

File

views_autorefresh/views_autorefresh.module, line 64

Code

function views_autorefresh_ajax_data_alter(&$object, $type, $view) {
  if (!empty($view->autorefresh['incremental']) || !empty($view->autorefresh['ping'])) {
    $object->view_name = $view->name;
    $object->timestamp = __views_autorefresh_get_timestamp($view);
    if (!empty($view->autorefresh['incremental']) && $view->autorefresh['incremental']['view_base_path'] == $_REQUEST['view_base_path']) {

      // remove 'Drupal.Views.Ajax.ajaxViewResponse' from callbacks because we're not replacing the whole div.
      unset($object->__callbacks[array_search('Drupal.Views.Ajax.ajaxViewResponse', $object->__callbacks)]);
      array_unshift($object->__callbacks, 'Drupal.views_autorefresh.ajaxViewResponseUpdate');
    }
    else {
      $object->__callbacks[] = 'Drupal.views_autorefresh.ajaxViewResponseRefresh';
    }
  }
}