You are here

function cdn_admin_details_form in CDN 6.2

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

Form definition; details.

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

File

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

Code

function cdn_admin_details_form(&$form_state) {
  $form = array();
  _cdn_settings_form_prepare($form, $form_state);
  $form[CDN_MODE_VARIABLE] = array(
    '#type' => 'radios',
    '#title' => t('Mode'),
    '#description' => _cdn_help('admin-details-mode') . t('Choose a CDN integration mode.'),
    '#required' => TRUE,
    '#options' => array(
      CDN_MODE_BASIC => t('Origin Pull'),
      CDN_MODE_ADVANCED => t('File Conveyor'),
    ),
    '#default_value' => variable_get(CDN_MODE_VARIABLE, CDN_MODE_BASIC),
  );
  $form['settings'] = array(
    '#type' => 'fieldset',
    '#title' => t('Mode-specific settings'),
  );

  //
  // Origin Pull mode settings.
  //
  $form['settings'][CDN_BASIC_MAPPING_VARIABLE] = array(
    '#type' => 'textarea',
    '#title' => t('CDN mapping'),
    '#description' => _cdn_help('admin-details-mode-pull-cdn-mapping') . t("Define which files are mapped to which CDN."),
    '#size' => 35,
    '#default_value' => variable_get(CDN_BASIC_MAPPING_VARIABLE, ''),
    '#process' => array(
      'ctools_dependent_process',
    ),
    '#dependency' => array(
      'radio:' . CDN_MODE_VARIABLE => array(
        CDN_MODE_BASIC,
      ),
    ),
  );
  $form['settings'][CDN_BASIC_FARFUTURE_VARIABLE] = array(
    '#type' => 'checkbox',
    '#title' => t('Far Future expiration'),
    '#description' => _cdn_help('admin-details-mode-pull-far-future') . t('Mark all files served from the CDN to expire in the far future —
      improves client-side cacheability.<br /><strong>Note:</strong> this
      requires the !preprocess-css-link performance setting to be enabled (or
      your site will break). Alternatively, having the AdvAgg module enabled is
      also sufficient.<br><strong>Note:</strong> only use Far Future expiration
      when using a CDN or a reverse proxy.', array(
      '!preprocess-css-link' => l('"Optimize CSS files"', 'admin/settings/performance', array(
        'fragment' => 'bw-optimizations',
      )),
    )),
    '#default_value' => variable_get(CDN_BASIC_FARFUTURE_VARIABLE, CDN_BASIC_FARFUTURE_DEFAULT),
    '#process' => array(
      'ctools_dependent_process',
    ),
    '#dependency' => array(
      'radio:' . CDN_MODE_VARIABLE => array(
        CDN_MODE_BASIC,
      ),
    ),
  );
  $format_variables = array(
    '@format-directory' => '<' . t('directory') . '>',
    '@format-extensions' => '<' . t('extensions') . '>',
    '@format-unique-identifier-method' => '<' . t('unique identifier method') . '>',
  );
  $methods = array();
  $ufi_info = module_invoke_all('cdn_unique_file_identifier_info');
  foreach ($ufi_info as $ufi_method => $ufi) {
    $methods[] = $ufi['label'] . ' (<code>' . $ufi_method . '</code>): ' . $ufi['description'];
  }
  $format_variables['!ufi-methods'] = theme('item_list', $methods);
  $form['settings'][CDN_BASIC_FARFUTURE_UNIQUE_IDENTIFIER_MAPPING_VARIABLE] = array(
    '#type' => 'textarea',
    '#title' => t('Unique file identifier generation'),
    '#description' => _cdn_help('admin-details-mode-pull-ufi') . t('Define how unique file identifiers (UFIs) are generated.'),
    '#size' => 35,
    '#default_value' => variable_get(CDN_BASIC_FARFUTURE_UNIQUE_IDENTIFIER_MAPPING_VARIABLE, CDN_BASIC_FARFUTURE_UNIQUE_IDENTIFIER_MAPPING_DEFAULT),
    '#process' => array(
      'ctools_dependent_process',
    ),
    '#dependency' => array(
      'edit-cdn-farfuture-status' => array(
        '1',
      ),
      'radio:' . CDN_MODE_VARIABLE => array(
        CDN_MODE_BASIC,
      ),
    ),
    '#dependency_count' => 2,
  );
  $form['settings']['ufis'] = array(
    '#type' => 'fieldset',
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    '#title' => t('Available UFI methods'),
    '#input' => TRUE,
    '#id' => 'ufi-fs-id',
    '#prefix' => '<div id="ufi-fs-id-wrapper">',
    '#suffix' => '</div>',
    '#process' => array(
      'ctools_dependent_process',
    ),
    '#dependency_count' => 2,
    '#dependency' => array(
      'radio:' . CDN_MODE_VARIABLE => array(
        CDN_MODE_BASIC,
      ),
      'edit-cdn-farfuture-status' => array(
        '1',
      ),
    ),
  );
  $form['settings']['ufis']['content'] = array(
    '#value' => t('Available UFI methods: !ufi-methods', $format_variables) . '<p>' . t('Note that if no UFI method is specified for a file
                          (because no rule matches), the CDN module will fall
                          back to the mtime method.') . '</p>',
    '#prefix' => '<div>',
    '#suffix' => '</div>',
  );

  //
  // File Conveyor mode settings.
  //
  $form['settings'][CDN_ADVANCED_PID_FILE_VARIABLE] = array(
    '#type' => 'textfield',
    '#title' => t('PID file'),
    '#description' => _cdn_help('admin-details-mode-fc-pid') . t('Full path to File Conveyor\'s PID file.'),
    '#size' => 60,
    '#default_value' => variable_get(CDN_ADVANCED_PID_FILE_VARIABLE, ''),
    '#process' => array(
      'ctools_dependent_process',
    ),
    '#dependency' => array(
      'radio:' . CDN_MODE_VARIABLE => array(
        CDN_MODE_ADVANCED,
      ),
    ),
  );
  $form['settings'][CDN_ADVANCED_SYNCED_FILES_DB_VARIABLE] = array(
    '#type' => 'textfield',
    '#title' => t('Synced files database'),
    '#description' => _cdn_help('admin-details-mode-fc-db') . t('Full path to File Conveyor\'s synced files database file.'),
    '#size' => 60,
    '#default_value' => variable_get(CDN_ADVANCED_SYNCED_FILES_DB_VARIABLE, ''),
    '#process' => array(
      'ctools_dependent_process',
    ),
    '#dependency' => array(
      'radio:' . CDN_MODE_VARIABLE => array(
        CDN_MODE_ADVANCED,
      ),
    ),
  );
  return system_settings_form($form);
}