You are here

function memcache_admin_menu in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 modules/memcache/memcache_admin/memcache_admin.module \memcache_admin_menu()

Implements hook_menu().

File

modules/memcache/memcache_admin/memcache_admin.module, line 39

Code

function memcache_admin_menu() {
  $items['admin/config/system/memcache'] = array(
    'title' => 'Memcache',
    'description' => 'Show or hide memcache statistics at the bottom of each page.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'memcache_admin_admin_settings',
    ),
    'access arguments' => array(
      'administer site configuration',
    ),
  );
  $items['admin/reports/memcache'] = array(
    'title' => 'Memcache statistics',
    'description' => "View statistics for all configured memcache servers.",
    'page callback' => 'memcache_admin_stats',
    'access arguments' => array(
      'access memcache statistics',
    ),
    'weight' => 1,
  );
  $memcache_servers = variable_get('memcache_servers', array(
    '127.0.0.1:11211' => 'default',
  ));
  $clusters = array();
  foreach ($memcache_servers as $server => $cluster) {
    $clusters[$cluster]['servers'][] = $server;
    $clusters[$cluster]['bin'] = _memcache_admin_get_bin_for_cluster($cluster);
  }
  $count = 0;
  foreach ($clusters as $cluster => $cluster_info) {
    if ($cluster_info['bin']) {
      if (empty($current_cluster)) {
        $current_cluster = arg(3);
        if (empty($current_cluster)) {
          $current_cluster = $cluster;
        }
      }
      $items['admin/reports/memcache/' . $cluster] = array(
        'title' => $cluster,
        'type' => $count == 0 ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
        'page callback' => 'memcache_admin_stats',
        'page arguments' => array(
          $cluster,
        ),
        'access arguments' => array(
          'access memcache statistics',
        ),
        'weight' => $count++,
      );
      foreach ($cluster_info['servers'] as $server) {
        $items["admin/reports/memcache/{$cluster}/{$server}"] = array(
          'title' => check_plain($server),
          'type' => MENU_CALLBACK,
          'page callback' => 'memcache_admin_stats_raw',
          'page arguments' => array(
            $cluster,
            $server,
          ),
          'access arguments' => array(
            'access memcache statistics',
          ),
        );
        foreach (memcache_admin_stats_types($cluster) as $type) {
          $items["admin/reports/memcache/{$cluster}/{$server}/{$type}"] = array(
            'type' => MENU_CALLBACK,
            'page callback' => 'memcache_admin_stats_raw',
            'page arguments' => array(
              $cluster,
              $server,
              $type,
            ),
            'title' => $type,
            'access arguments' => array(
              'access memcache statistics',
            ),
          );
        }
      }
    }
  }
  return $items;
}