function cdn_admin_details_form in CDN 7.2
Same name and namespace in other branches
- 6.2 cdn.admin.inc \cdn_admin_details_form()
Form definition; details.
1 string reference to 'cdn_admin_details_form'
- cdn_menu in ./
cdn.module - Implements hook_menu().
File
- ./
cdn.admin.inc, line 71 - Settings administration UI.
Code
function cdn_admin_details_form($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. (To learn about how to define more advanced set-ups, install the Advanced Help module.)"),
'#size' => 35,
'#default_value' => variable_get(CDN_BASIC_MAPPING_VARIABLE, ''),
'#attributes' => array(
'placeholder' => '//my-cdn.com|.css .js .jpg .jpeg .png',
),
'#states' => array(
'visible' => array(
':input[name="' . CDN_MODE_VARIABLE . '"]' => array(
'value' => 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).<br><strong>Note:</strong> only use Far Future
expiration when using a CDN or a reverse proxy.', array(
'!preprocess-css-link' => l('"Aggregate and compress CSS files"', 'admin/config/development/performance', array(
'fragment' => 'edit-bandwidth-optimization',
)),
)),
'#default_value' => variable_get(CDN_BASIC_FARFUTURE_VARIABLE, CDN_BASIC_FARFUTURE_DEFAULT),
'#states' => array(
'visible' => array(
':input[name="' . CDN_MODE_VARIABLE . '"]' => array(
'value' => 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', array(
'items' => $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),
'#states' => array(
'visible' => array(
':input[name="' . CDN_MODE_VARIABLE . '"]' => array(
'value' => CDN_MODE_BASIC,
),
':input[name="' . CDN_BASIC_FARFUTURE_VARIABLE . '"]' => array(
'checked' => TRUE,
),
),
),
);
$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>',
'#states' => array(
'visible' => array(
':input[name="' . CDN_MODE_VARIABLE . '"]' => array(
'value' => CDN_MODE_BASIC,
),
':input[name="' . CDN_BASIC_FARFUTURE_VARIABLE . '"]' => array(
'checked' => TRUE,
),
),
),
);
$form['settings']['ufis']['content'] = array(
'#markup' => 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, ''),
'#states' => array(
'visible' => array(
':input[name="' . CDN_MODE_VARIABLE . '"]' => array(
'value' => 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, ''),
'#states' => array(
'visible' => array(
':input[name="' . CDN_MODE_VARIABLE . '"]' => array(
'value' => CDN_MODE_ADVANCED,
),
),
),
);
return system_settings_form($form);
}