You are here

function theme_views_autorefresh in Views Auto-Refresh 7

Same name and namespace in other branches
  1. 7.2 views_autorefresh.module \theme_views_autorefresh()

Theme function for views_autorefresh.

1 theme call to theme_views_autorefresh()
views_autorefresh_handler_area_autorefresh::render in views/views_autorefresh_handler_area_autorefresh.inc
Render the area.

File

./views_autorefresh.module, line 33

Code

function theme_views_autorefresh($variables) {

  // Get Auto-Refresh settings.
  $interval = $variables['interval'];
  $ping = $variables['ping'];
  $trigger_onload = $variables['trigger_onload'];
  $incremental = $variables['incremental'];
  $nodejs = $variables['nodejs'];
  $view = $variables['view'];
  if (empty($view)) {
    $view = views_get_current_view();
  }
  $view_name_id = $view->name . '-' . $view->current_display;

  // Add the JavaScript settings.
  drupal_add_js(drupal_get_path('module', 'views_autorefresh') . '/js/views_autorefresh.js');
  drupal_add_js(array(
    'views_autorefresh' => array(
      $view_name_id => array(
        'interval' => $interval,
        'ping' => $ping,
        'trigger_onload' => $trigger_onload,
        'incremental' => $incremental,
        'nodejs' => $nodejs,
      ),
    ),
  ), 'setting');
  $timestamp = views_autorefresh_get_timestamp($view);
  if ($timestamp) {
    drupal_add_js(array(
      'views_autorefresh' => array(
        $view_name_id => array(
          'timestamp' => $timestamp,
        ),
      ),
    ), 'setting');
  }

  // Signal modules to add their own plugins.
  module_invoke_all('views_autorefresh_plugins', $view);

  // Check for nodejs and create view channel.
  if (!empty($nodejs) && module_exists('nodejs') && function_exists('nodejs_send_content_channel_token')) {
    $channel = 'views_autorefresh_' . $view_name_id;
    drupal_alter('views_autorefresh_nodejs_channel', $channel, $view);
    nodejs_send_content_channel_token($channel);
  }

  // Return link to autorefresh.
  $query = drupal_get_query_parameters($_REQUEST, array_merge(array(
    'q',
    'pass',
  ), array_keys($_COOKIE)));
  $link = l('', $_GET['q'], array(
    'query' => $query,
  ));
  return '<div class="auto-refresh">' . $link . '</div>';
}