You are here

function esi_esi_cache_settings_form in ESI: Edge Side Includes 6.2

1 string reference to 'esi_esi_cache_settings_form'
esi.inc in plugins/cache/esi.inc
ESI cache plugin. Substitutes esi-tags for a panel-pane's content.

File

plugins/cache/esi.inc, line 92
ESI cache plugin. Substitutes esi-tags for a panel-pane's content.

Code

function esi_esi_cache_settings_form($conf, $display, $pid) {

  // The ESI callback URL provides the display ID, pane ID, and the string
  // identifier for the context passed to the pane.
  // E.g. /esi/panel_panes/21/2
  // E.g. /esi/panel_panes/21/3/argument_current_page_content_1
  ctools_include('dependent');
  require_once drupal_get_path('module', 'esi') . '/esi.inc';

  // The contexts-definition for this pane is in $display->configuration['context']
  $form['scope'] = array(
    '#title' => t('Default Panel Cache Scope'),
    '#type' => 'select',
    '#options' => array(
      0 => 'Disabled',
      1 => 'Not Cached',
      2 => 'Global',
      3 => 'Page',
      4 => 'User Role',
      5 => 'User Role/Page',
      6 => 'User ID',
      7 => 'User ID/Page',
    ),
    '#default_value' => isset($conf['scope']) ? $conf['scope'] : (int) variable_get('esi_panel_default_scope', ESI_PANEL_DEFAULT_SCOPE),
    '#description' => t('Disabled - Do not use ESI. <br />Not Cached - Use ESI, but never cache the content. <br />Global - Content is same on every page. <br />Page - Content changes based on the URL. <br />User Role - Content changes based on the user role. <br />User Role/Page - Content changes based on the user role as well as the URL. <br />User ID - Content changes based on the UID; otherwise it is the same as global. <br />User ID/Page - Content changes based on the UID and based on the URL.'),
  );
  $max_age = isset($conf['max_age']) ? $conf['max_age'] : (int) variable_get('esi_panel_default_max_age', ESI_PANEL_DEFAULT_MAX_AGE);
  $form['max_age'] = array(
    '#title' => t('Cache Maximum Age (TTL)'),
    '#type' => 'select',
    '#options' => esi_max_age_options($max_age),
    '#default_value' => $max_age,
    '#description' => t('External page caches (proxy/browser) will not deliver cached paged older than this setting; time to live in short.'),
  );
  $form['aligner_start'] = array(
    '#value' => '<div class="option-text-aligner">',
  );
  $form['external'] = array(
    '#type' => 'checkbox',
    '#default_value' => isset($conf['external']) ? $conf['external'] : '',
    '#title' => t('External Link'),
    '#id' => 'external-checkbox',
  );
  $form['external_text'] = array(
    '#type' => 'textfield',
    '#default_value' => isset($conf['external_text']) ? $conf['external_text'] : '',
    '#size' => 80,
    '#id' => 'external-textfield',
    '#process' => array(
      'ctools_dependent_process',
    ),
    '#dependency' => array(
      'external-checkbox' => array(
        1,
      ),
    ),
    '#dependency_type' => 'disable',
  );
  $form['aligner_stop'] = array(
    '#value' => '</div><div style="clear: both; padding: 0; margin: 0"></div>',
  );
  $form['context'] = array(
    '#type' => 'checkbox',
    '#default_value' => isset($conf['context']) ? $conf['context'] : '',
    '#title' => t('Pass the current url to the external url as a base64 encoded string.'),
    '#id' => 'context-checkbox',
  );

  // Add some JS inline.
  $widget_vis = '
<script type="text/javascript">
<!--//--><![CDATA[//><!--' . "\nfunction esi_update_visibility() {\n  var esi_scope = \$('#edit-settings-scope').val();\n  if (esi_scope == '0' || esi_scope == '1') {\n    \$('#edit-settings-max-age-wrapper').hide();\n  }\n  else {\n    \$('#edit-settings-max-age-wrapper').show();\n  }\n}\n\$(esi_update_visibility);\n\$(function(){ \$('#edit-settings-scope').change(function (){esi_update_visibility();})});\n//--><!]]>\n</script>";
  $form['js'] = array(
    '#type' => 'markup',
    '#value' => $widget_vis,
  );
  return $form;
}