You are here

function _authcache_pagecache_form in Authenticated User Page Caching (Authcache) 6

Same name and namespace in other branches
  1. 7.2 authcache.admin.inc \_authcache_pagecache_form()
  2. 7 authcache.admin.inc \_authcache_pagecache_form()

Add new page caching rule to form (part of AHAH)

1 call to _authcache_pagecache_form()
authcache_admin_pagecaching in ./authcache.admin.inc
Page caching rules form

File

./authcache.admin.inc, line 202
Admin forms and pages.

Code

function _authcache_pagecache_form($details) {
  $form['#tree'] = TRUE;
  $delta = $details['delta'];
  $roles = user_roles();
  $roles[DRUPAL_AUTHENTICATED_RID] .= t(' (without additional roles)');

  // Cacheability settings
  $options = array(
    t('Cache every page except the listed pages.'),
    t('Cache only the listed pages.'),
  );
  $description = t("To delete this ruleset, leave the textbox empty.") . ' ' . t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are '%blog' for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array(
    '%blog' => 'blog',
    '%blog-wildcard' => 'blog/*',
    '%front' => '<front>',
  ));
  if (user_access('use PHP for block visibility')) {
    $options[] = t('Cache pages for which the following PHP code returns <code>TRUE</code> (PHP-mode, experts only).');
    $description .= t('If the PHP-mode is chosen, enter PHP code between %php. Note that executing incorrect PHP-code can severely break your Drupal site.', array(
      '%php' => '<?php ?>',
    ));
  }
  $form['fieldset'] = array(
    '#type' => 'fieldset',
    '#title' => t('Caching Ruleset') . '#' . ($delta + 1),
    '#collapsible' => TRUE,
  );
  $form['fieldset']['option'] = array(
    '#type' => 'radios',
    '#title' => t('Cache specified pages'),
    '#options' => $options,
    '#default_value' => $details['option'],
  );
  $form['fieldset']['pages'] = array(
    '#type' => 'textarea',
    '#title' => t('Pages'),
    '#description' => $description,
    '#default_value' => $details['pages'],
  );
  $form['fieldset']['roles'] = array(
    '#title' => 'Apply to these roles',
    '#type' => 'checkboxes',
    '#options' => _authcache_get_roles(),
    '#default_value' => is_array($details['roles']) ? $details['roles'] : array(),
  );
  return $form;
}