You are here

function cdn_admin_general_settings_form in CDN 6.2

Same name and namespace in other branches
  1. 7.2 cdn.admin.inc \cdn_admin_general_settings_form()

Form definition; general settings.

1 string reference to 'cdn_admin_general_settings_form'
cdn_menu in ./cdn.module
Implementation of hook_menu().

File

./cdn.admin.inc, line 15
Settings administration UI.

Code

function cdn_admin_general_settings_form(&$form_state) {
  $form = array();
  _cdn_settings_form_prepare($form, $form_state);

  // Check which CDN integration mechanism is being used.
  cdn_load_include('requirements');
  $integration_method = _cdn_requirements_get_integration_mechanism();
  switch ($integration_method) {
    case 'fallback':
      $desc = t('No core patch applied — falling back to theme layer to alter
                 file URLs.<br />
                 <u>Note:</u> this mechanism is unable to alter all file URLs.
                 <strong>If you want complete CDN coverage, you should either
                 apply the included Drupal core patch or switch to a
                 distribution that already includes the core patch, such as
                 <a href="http://pressflow.org/">Pressflow</a> or
                 <a href="http://drupal.cocomore.com/">Cocomore</a>.
                 </strong>');
      break;
    case 'pressflow':
      $desc = t("This is a Pressflow site — no core patch necessary.");
      break;
    case 'cocomore':
      $desc = t("This is a Cocomore site — no core patch necessary.");
      break;
    case 'core patch':
      $desc = t("Core patch applied!");
      break;
  }
  $form['integration_method'] = array(
    '#type' => 'item',
    '#title' => t('Integration method'),
    '#value' => $desc,
  );
  $perm_url = url('admin/user/permissions', array(
    'fragment' => 'module-cdn',
  ));
  $form[CDN_STATUS_VARIABLE] = array(
    '#type' => 'radios',
    '#title' => t('Status'),
    '#description' => t("If you don't want to use the CDN to serve files to your visitors yet,\n      but you do want to see if it's working well for your site, then enable\n      testing mode.<br />Users will only get the files from the CDN if they\n      have the <a href=\"!perm-url\">%cdn-testing-mode-permission\n      permission</a>.", array(
      '!perm-url' => $perm_url,
      '%cdn-testing-mode-permission' => 'access files on CDN when in testing mode',
    )),
    '#required' => TRUE,
    '#options' => array(
      CDN_DISABLED => t('Disabled'),
      CDN_TESTING => t('Testing mode'),
      CDN_ENABLED => t('Enabled'),
    ),
    '#default_value' => variable_get(CDN_STATUS_VARIABLE, CDN_DISABLED),
  );
  $form[CDN_STATS_VARIABLE] = array(
    '#type' => 'checkbox',
    '#title' => t('Display statistics'),
    '#description' => t('Shows the CDN integration statistics of the current page, to users with
      the <a href="!perm-url">%access-per-page-statistics permission</a>.', array(
      '!perm-url' => $perm_url,
      '%access-per-page-statistics' => 'access per-page statistics',
    )),
    '#return_value' => CDN_ENABLED,
    '#default_value' => variable_get(CDN_STATS_VARIABLE, CDN_DISABLED),
    '#process' => array(
      'ctools_dependent_process',
    ),
    '#dependency' => array(
      'radio:' . CDN_STATUS_VARIABLE => array(
        CDN_TESTING,
        CDN_ENABLED,
      ),
    ),
  );
  return system_settings_form($form);
}