You are here

function theme_varnish_status in Varnish 6

Same name and namespace in other branches
  1. 7 varnish.module \theme_varnish_status()

Theme handler for theme('varnish_status').

1 theme call to theme_varnish_status()
varnish_admin_settings_form in ./varnish.admin.inc
Menu callback for varnish admin settings.

File

./varnish.module, line 254
varnish.module Provide drupal hooks for integration with the Varnish control layer.

Code

function theme_varnish_status($status, $version = 2.1) {
  $items = array();
  foreach ($status as $terminal => $state) {
    list($server, $port) = explode(':', $terminal);
    if ($state == VARNISH_SERVER_STATUS_UP) {
      $icon = theme('image', 'misc/watchdog-ok.png', t("Server OK: @server:@port", array(
        '@server' => $server,
        '@port' => $port,
      )), "{$server}:{$port}");
      if ($version < 3) {
        $items[] = t('!status_icon Varnish running. Observe more detailed statistics !link.', array(
          '!status_icon' => $icon,
          '!link' => l(t('here'), 'admin/reports/varnish'),
        ));
      }
      else {
        $items[] = t('!status_icon Varnish running.', array(
          '!status_icon' => $icon,
        ));
      }
    }
    else {
      $icon = theme('image', 'misc/watchdog-error.png', t('Server down: @server:@port', array(
        '@server' => $server,
        '@port' => $port,
      )), "{$server}:{$port}");
      $items[] = t('!status_icon The Varnish control terminal is not responding at @server on port @port.', array(
        '!status_icon' => $icon,
        '@server' => $server,
        '@port' => $port,
      ));
    }
  }
  return theme('item_list', $items);
}