function advagg_admin_settings_form in Advanced CSS/JS Aggregation 6
Same name and namespace in other branches
- 7.2 advagg.admin.inc \advagg_admin_settings_form()
Form builder; Configure advagg settings.
See also
1 string reference to 'advagg_admin_settings_form'
- advagg_admin_page in ./
advagg.admin.inc - Page generation function for admin/settings/advagg
File
- ./
advagg.admin.inc, line 217 - Admin page callbacks for the advanced CSS/JS aggregation module.
Code
function advagg_admin_settings_form() {
$form = array();
$readme = drupal_get_path('module', 'advagg') . '/README.txt';
$bundle_count = db_result(db_query("SELECT COUNT(*) FROM (SELECT bundle_md5 FROM {advagg_bundles} GROUP BY bundle_md5) as temp"));
$form['advagg_enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Enable Advanced Aggregation'),
'#default_value' => variable_get('advagg_enabled', ADVAGG_ENABLED),
);
$form['advagg_closure'] = array(
'#type' => 'checkbox',
'#title' => t('Use AdvAgg in closure'),
'#default_value' => variable_get('advagg_closure', ADVAGG_CLOSURE),
'#description' => t('If enabled javascript files in the closure region will be aggregated.'),
);
// Make sure the advagg_check_missing_handler function is available.
module_load_install('advagg');
$ret = advagg_check_missing_handler();
$form['advagg_async_generation'] = array(
'#type' => 'checkbox',
'#title' => t('Generate CSS/JS files on request (async mode)'),
'#default_value' => variable_get('advagg_async_generation', ADVAGG_ASYNC_GENERATION),
'#disabled' => $ret['advagg_async_generation']['severity'] == REQUIREMENT_ERROR ? TRUE : FALSE,
'#description' => t('Current State: !value', array(
'!value' => filter_xss(' ' . $ret['advagg_async_generation']['value'] . ' ' . (!empty($ret['advagg_async_generation']['description']) ? $ret['advagg_async_generation']['description'] : '') . ' '),
)),
);
$form['advagg_async_test'] = array(
'#type' => 'fieldset',
'#title' => t('Async Test HTTP Basic Credentials'),
'#collapsed' => TRUE,
'#collapsible' => TRUE,
);
$form['advagg_async_test']['advagg_async_test_username'] = array(
'#type' => 'textfield',
'#title' => t('Username'),
'#default_value' => variable_get('advagg_async_test_username', ''),
);
$form['advagg_async_test']['advagg_async_test_password'] = array(
'#type' => 'password',
'#title' => t('Password'),
);
$form['advagg_gzip_compression'] = array(
'#type' => 'checkbox',
'#title' => t('Gzip CSS/JS files'),
'#default_value' => variable_get('advagg_gzip_compression', ADVAGG_GZIP_COMPRESSION),
'#description' => t('This might break CSS/JS handling at the Apache level. If it does, use the rules for your webroot level htaccess file before re-enabling. Directions on what to change are located in the <a href="@readme">readme</a> file. In short, be sure to test this out.', array(
'@readme' => url($readme),
)),
);
$form['advagg_dir_htaccess'] = array(
'#type' => 'checkbox',
'#title' => t('Generate .htaccess files in the advagg_* dirs'),
'#default_value' => variable_get('advagg_dir_htaccess', ADVAGG_DIR_HTACCESS),
'#description' => t('Disable if your using the rules from the <a href="@readme">readme</a> file in your webroot level htaccess file.', array(
'@readme' => url($readme),
)),
);
$form['advagg_rebuild_on_flush'] = array(
'#type' => 'checkbox',
'#title' => t('Regenerate flushed bundles in the cache flush request'),
'#default_value' => variable_get('advagg_rebuild_on_flush', ADVAGG_REBUILD_ON_FLUSH),
'#description' => t('You can enable if your server will not timeout on a request. This will call advagg_rebuild_bundle() as a <a href="http://php.net/register-shutdown-function">shutdown function</a> for every bundle that has been marked as expired; thus rebuilding that bundle in the same request as the flush.'),
);
$public_downloads = variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC;
if (!$public_downloads) {
$extra = module_exists('boost') ? t('If boost is installed, you can use the cache directory for advagg files.') : '';
$form['advagg_custom_files_dir'] = array(
'#type' => 'textfield',
'#field_prefix' => '<div>' . t('You are using a private file system. You must serve aggregated files via a public folder.') . '</div>',
'#title' => t('Use a different directory for storing advagg files'),
'#default_value' => variable_get('advagg_custom_files_dir', ADVAGG_CUSTOM_FILES_DIR),
'#description' => check_plain(t('You need to create a publicly writable directory (same permissions as Drupals files folder) and it needs to be relative to the Drupal index.php file.') . ' ' . $extra . ' ' . t('If you do not need this, you can put a space in this box.')),
'#required' => TRUE,
);
}
$options = array(
0 => t('Wait for locks'),
1 => t('Do not wait for locks'),
2 => t('Only serve aggregated files if they are already built (only works if async is enabled)'),
);
$form['advagg_aggregate_mode'] = array(
'#type' => 'radios',
'#title' => t('Aggregation Inclusion Mode'),
'#default_value' => variable_get('advagg_aggregate_mode', ADVAGG_AGGREGATE_MODE),
'#options' => $options,
'#description' => t('Should the page wait for the aggregate to be built before including the file, or should it send out the page with aggregates not included.'),
);
$form['advagg_page_cache_mode'] = array(
'#type' => 'checkbox',
'#title' => t('Disable page caching if all aggregates are not included on the page.'),
'#default_value' => variable_get('advagg_page_cache_mode', ADVAGG_PAGE_CACHE_MODE),
);
$form['advagg_checksum_mode'] = array(
'#type' => 'radios',
'#title' => t('File Checksum Mode'),
'#default_value' => variable_get('advagg_checksum_mode', ADVAGG_CHECKSUM_MODE),
'#options' => array(
'mtime' => 'mtime',
'md5' => 'md5',
),
'#description' => t('If Drupal is on multiple servers and the file system is not shared; using md5 is recommended. The file modification time (mtime) could be different with this type of setup. WARNING: Changing this value will invalidate all bundles and new ones will have to be built.'),
);
$form['advagg_server_addr'] = array(
'#type' => 'textfield',
'#title' => t('IP Address to send all asynchronous requests to'),
'#default_value' => variable_get('advagg_server_addr', FALSE),
'#description' => t('If left blank it will use the same server as the request. If set to -1 it will use the host name instead of an IP address.'),
);
// $form['advagg_debug'] = array(
// '#type' => 'checkbox',
// '#title' => t('Debug to watchdog.'),
// '#default_value' => variable_get('advagg_debug', ADVAGG_DEBUG),
// );
$form['flush'] = array(
'#type' => 'fieldset',
'#title' => t('Smart cache flush'),
'#description' => t('Scan all files referenced in aggregated files. If any of them have changed, increment the counters containing that file and rebuild the bundle.'),
);
$form['flush']['advagg_flush'] = array(
'#type' => 'submit',
'#value' => t('Flush AdvAgg Cache'),
'#submit' => array(
'advagg_admin_flush_cache_button',
),
);
$form['rebuild'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Cache Rebuild'),
'#description' => t('Recreate all aggregated files. Useful if JS or CSS compression was just enabled. %count Files', array(
'%count' => $bundle_count,
)),
);
$form['rebuild']['advagg_rebuild'] = array(
'#type' => 'submit',
'#value' => t('Rebuild AdvAgg Cache'),
'#submit' => array(
'advagg_admin_batch_rebuild',
),
);
$form['forced_rebuild'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Forced Cache Rebuild'),
'#description' => t('Recreate all aggregated files by incrementing internal counter for every bundle. %count Files', array(
'%count' => $bundle_count,
)),
);
$form['forced_rebuild']['advagg_forced_build'] = array(
'#type' => 'submit',
'#value' => t('Force all counters to be increment by one'),
'#submit' => array(
'advagg_admin_batch_rebuild',
),
);
$form['master_reset'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Master Reset'),
'#description' => t('Clean Slate - Truncate all advagg tables and delete all advagg files. Useful for testing purposes. Running this on a production site is not a good idea.'),
);
$form['master_reset']['advagg_reset'] = array(
'#type' => 'submit',
'#value' => t('Master Reset'),
'#submit' => array(
'advagg_admin_master_reset',
),
);
$form['htaccess'] = array(
'#type' => 'fieldset',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#title' => t('Rebuild htaccess files'),
'#description' => t('This will recreate the htaccess files located in the advagg_* directories.'),
);
$form['htaccess']['advagg_recreate_htaccess'] = array(
'#type' => 'submit',
'#value' => t('Recreate htaccess files'),
'#submit' => array(
'advagg_admin_recreate_htaccess',
),
);
$form['bypass'] = array(
'#type' => 'fieldset',
'#title' => t('Aggregation Bypass Cookie'),
'#description' => t('This will set or remove a cookie that disables aggregation for the remainder of the browser session.'),
);
$form['bypass']['submit'] = array(
'#type' => 'submit',
#'#button_type' => 'button',
'#value' => t('Toggle the "aggregation bypass cookie" for this browser'),
'#attributes' => array(
'onclick' => 'javascript:return advagg_toggle_cookie()',
),
'#submit' => array(
'advagg_admin_toggle_bypass_cookie',
),
);
$form['#submit'][] = 'advagg_admin_settings_form_submit';
return system_settings_form($form);
}