You are here

function _authcache_pagecache_form in Authenticated User Page Caching (Authcache) 7

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

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

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

File

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

Code

function _authcache_pagecache_form($delta, $details, $count) {
  $form['#tree'] = TRUE;
  $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("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 settings')) {
    $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', array(
      '%delta' => $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']['noadmin'] = array(
    '#type' => 'checkbox',
    '#title' => t('Exclude Admin pages'),
    '#description' => t('Do not cache administrative pages.'),
    '#default_value' => $details['noadmin'],
  );
  $form['fieldset']['roles'] = array(
    '#title' => 'Apply to these roles',
    '#type' => 'checkboxes',
    '#options' => _authcache_get_roles(),
    '#default_value' => is_array($details['roles']) ? $details['roles'] : array(),
  );
  if ($count > 1) {
    $form['fieldset']['remove_rule'] = array(
      '#type' => 'submit',
      '#value' => t('Delete ruleset #@delta', array(
        '@delta' => $delta + 1,
      )),
      '#submit' => array(
        'authcache_admin_pagecaching_remove_one',
      ),
      '#ajax' => array(
        'callback' => 'authcache_admin_pagecaching_ajax_callback',
        'wrapper' => 'ajax-wrapper',
      ),
      '#authcache_rule_id' => $delta,
    );
  }
  return $form;
}