You are here

function authcache_p13n_admin_markup_configs in Authenticated User Page Caching (Authcache) 7.2

Display a list of markup substitution configurations.

1 string reference to 'authcache_p13n_admin_markup_configs'
authcache_p13n_menu in modules/authcache_p13n/authcache_p13n.module
Implements hook_menu().

File

modules/authcache_p13n/authcache_p13n.admin.inc, line 137
Administrative interface for the authcache personalization module.

Code

function authcache_p13n_admin_markup_configs($form, &$form_state) {
  $resources = authcache_p13n_request_resources();
  $processors = authcache_p13n_resource_processors();

  // Gather group information from modules.
  $group_descriptions = module_invoke_all('authcache_p13n_admin_groups');

  // Preseed groups with group names from group descriptions.
  $groups = array_fill_keys(array_keys($group_descriptions), array());
  foreach ($resources as $route_id => $resource) {
    try {
      $factory = new AuthcacheP13nObjectFactory($resource, $processors);
      $entry = $factory
        ->get('admin entry object');
      $groups[$entry->group][$route_id] = $entry;
    } catch (Exception $e) {
      drupal_set_message(t('Failed to retrieve info for route %route_id', array(
        '%route_id' => $route_id,
      )));
    }
  }
  ksort($groups);
  $header = array(
    t('Name'),
    t('Location'),
    t('Client'),
    t('Cache lifetime'),
    t('Cache granularity'),
    t('Route ID'),
    '',
  );
  $rows = array();
  foreach ($groups as $groupname => $group) {
    $rows[] = array(
      array(
        'class' => array(
          'p13n-markup-substitution-group',
        ),
        'colspan' => 7,
        'data' => $groupname,
      ),
    );
    if (isset($group_descriptions[$groupname])) {
      $rows[] = array(
        array(
          'class' => array(
            'p13n-markup-substitution-message',
          ),
          'colspan' => 7,
          'data' => $group_descriptions[$groupname],
        ),
      );
    }
    foreach ($group as $route_id => $entry) {
      $rows[] = array(
        array(
          'class' => array(
            'p13n-markup-substitution-title',
          ),
          'data' => $entry->name,
        ),
        $entry->description,
        implode(', ', _authcache_p13n_admin_format_clients($entry->clients)),
        !empty($entry->cacheMaxage) ? format_interval($entry->cacheMaxage) : '',
        implode(', ', _authcache_p13n_admin_cache_granularity($entry->cacheGranularity)),
        $route_id,
        !empty($entry->adminPath) ? l(t('Edit'), $entry->adminPath, array(
          'query' => array(
            'destination' => $_GET['q'],
          ),
        )) : '',
      );
    }
  }
  $page['configs'] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#attached' => array(
      'css' => array(
        drupal_get_path('module', 'authcache_p13n') . '/authcache_p13n.admin.css',
      ),
    ),
  );
  return $page;
}