You are here

function authcache_admin_pagecaching in Authenticated User Page Caching (Authcache) 6

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

Page caching rules form

1 string reference to 'authcache_admin_pagecaching'
authcache_menu in ./authcache.module
Implements hook_menu().

File

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

Code

function authcache_admin_pagecaching($form_state, $ahah_form = array()) {
  drupal_set_title(t('Authcache Page Caching Settings'));
  drupal_add_css(drupal_get_path('module', 'authcache') . '/authcache.css', 'module');
  if (!count(variable_get('authcache_roles', array()))) {
    drupal_set_message(t('You must first select roles to cache before defining page caching setting.'), 'error');
    return $form;
  }
  $form['#cache'] = TRUE;

  // The contents of ahah_form will either come from the db or from $form_state
  if (isset($form_state['ahah_form'])) {
    $ahah_form = $form_state['ahah_form'] + (array) $ahah_form;
  }

  // Default values
  if (empty($ahah_form)) {
    $ahah_form['ahah_form'] = variable_get('authcache_pagecaching', array(
      array(),
    ));
  }
  $form['ahah_wrapper'] = array(
    '#tree' => FALSE,
    '#prefix' => '<div class="clear-block" id="ahah-wrapper">',
    '#suffix' => '</div>',
  );
  $form['ahah_wrapper']['ahah']['#tree'] = TRUE;
  foreach ($ahah_form['ahah_form'] as $delta => $details) {
    $details = isset($details['fieldset']) ? $details['fieldset'] : $details;

    // fieldset inserted from AHAH postback
    $details['delta'] = $delta;
    $form['ahah_wrapper']['ahah'][$delta] = _authcache_pagecache_form($details);
  }

  // AHAH-enabled "Add" button
  $form['authcache_add_cache'] = array(
    '#type' => 'submit',
    '#value' => t('Add new ruleset') . '...',
    '#description' => t("If the above ruleset isn't, click here to add more choices."),
    '#submit' => array(
      'authcache_ahah_add',
    ),
    '#ahah' => array(
      'path' => 'authcache/ahah',
      'wrapper' => 'ahah-wrapper',
      'method' => 'replace',
      'effect' => 'fade',
    ),
    '#attributes' => array(
      'class' => 'authcache-add',
    ),
  );
  $form['nonhtmlfs'] = array(
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => variable_get('authcache_nonhtml', AUTHCACHE_NONHTML_DEFAULT) == AUTHCACHE_NONHTML_DEFAULT,
    '#title' => t('Non-HTML Cached Pages'),
    '#description' => t('JavaScript is appended at the end of pages to support Ajax callbacks and page manipulation ("var authcacheFooter"). If you are experiencing issues for some content, you may disable this by entering pages below that you wish to cache but do not want JavaScript appended to.'),
    '#prefix' => '<br><hr size="1"><br>',
  );
  $form['nonhtmlfs']['nonhtml'] = array(
    '#type' => 'textarea',
    '#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. Content that begins with <code>&lt;?xml</code> (i.e., XML feeds) will not be cached. ", array(
      '%blog' => 'blog',
      '%blog-wildcard' => 'blog/*',
      '%front' => '<front>',
    )),
    '#default_value' => variable_get('authcache_nonhtml', AUTHCACHE_NONHTML_DEFAULT),
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save & clear cached pages'),
    '#prefix' => '<br><hr size="1"><br>',
  );
  return $form;
}