'fieldset',
'#title' => t('Boost Apache .htaccess settings generation'),
'#description' => t('Explanation of .htaccess variables
Be sure to save the configuration and then go to the htaccess rules generation page and copy the rules.', array('!link' => url('http://www.askapache.com/htaccess/mod_rewrite-variables-cheatsheet.html'), '!rules' => url('admin/config/system/boost/htaccess/generator'))),
);
$form['htaccess']['boost_server_name_http_host'] = array(
'#type' => 'radios',
'#title' => t('Servers URL or Name'),
'#default_value' => variable_get('boost_server_name_http_host', BOOST_SERVER_NAME_HTTP_HOST),
'#options' => array(
'%{HTTP_HOST}' => '%{HTTP_HOST}',
'%{SERVER_NAME}' => '%{SERVER_NAME}',
$_SERVER['HTTP_HOST'] => $_SERVER['HTTP_HOST'],
$_SERVER['SERVER_NAME'] => $_SERVER['SERVER_NAME'],
),
'#description' => t('Best to leave these as %{}, only try the last option(s) if boost is still not working.'),
);
// Set DOCUMENT_ROOT
$drupal_subdir = rtrim($base_path, '/');
$document_root = str_replace("\\", '/', getcwd()); // fix windows dir slashes
$document_root = trim(str_replace($drupal_subdir, '', $document_root)); // remove subdir
$options = array('%{DOCUMENT_ROOT}' => '%{DOCUMENT_ROOT}', $document_root => $document_root); // initial options
$rejects = array('SCRIPT_FILENAME', 'DOCUMENT_ROOT'); // values to ignore
$output = boost_admin_htaccess_array_find($document_root, $_SERVER, $rejects); //search for values that match getcwd
$description_extra = '';
if (!empty($output)) {
foreach ($output as $key => $value) {
$temp = '%{ENV:' . $key . '}';
$options[$temp] = $temp . ' = ' . $value; // adding values to options
if (strcmp($value, $document_root) == 0) {
$best = $temp; // set best since it's a match
}
}
}
if (strcmp($_SERVER['DOCUMENT_ROOT'], $document_root) == 0) {
$best = '%{DOCUMENT_ROOT}';
}
elseif (!isset($best)) {
$best = $document_root;
$description_extra = t('Please open an boost issue on Drupal.org, since apache and php might not be configured correctly.', array('!link' => url('http://drupal.org/node/add/project-issue/boost')));
}
$percent = 0;
$int = similar_text(substr(trim($_SERVER['DOCUMENT_ROOT']), 18, 1), substr(trim($document_root), 18, 1), $percent);
$description = t('Value of %best is recommended for this server.', array('%best' => $best)) . ' ' . $description_extra;
$form['htaccess']['boost_document_root'] = array(
'#type' => 'radios',
'#title' => t('Document Root'),
'#default_value' => variable_get('boost_document_root', BOOST_DOCUMENT_ROOT),
'#options' => $options,
'#description' => $description,
);
$form['htaccess']['boost_apache_etag'] = array(
'#type' => 'radios',
'#title' => t('ETag Settings'),
'#default_value' => variable_get('boost_apache_etag', BOOST_APACHE_ETAG),
'#options' => array(
3 => "Set FileETag 'MTime Size' - Useful in server clusters (Highly Recommended)",
2 => "Set FileETag 'All' - Default if enabled",
1 => "Set FileETag 'None' - Do not send an etag",
0 => 'Do Nothing',
),
'#description' => t('Uses FileETag Directive to set ETags for the files cached by Boost. More info on this subject', array('!link' => url('http://httpd.apache.org/docs/trunk/mod/core.html#fileetag'), '!about' => url('http://en.wikipedia.org/wiki/HTTP_ETag'), '!stack' => url('http://stackoverflow.com/questions/tagged?tagnames=etag&sort=votes&pagesize=50'))),
);
$form['htaccess']['boost_apache_xheader'] = array(
'#type' => 'radios',
'#title' => t('Boost Tags'),
'#default_value' => variable_get('boost_apache_xheader', BOOST_APACHE_XHEADER),
'#options' => array(
1 => 'Set Boost header',
0 => 'Do not set Boost header',
),
'#description' => t('In order to identify that the page is being served from the cache, Boost can send out a header that will identify any files served from the boost cache.'),
);
$form['htaccess']['boost_ssl_bypass'] = array(
'#type' => 'checkbox',
'#title' => t('Bypass the boost cache for ssl requests.'),
'#default_value' => variable_get('boost_ssl_bypass', BOOST_SSL_BYPASS),
'#description' => t('Ticking this is recommended if you use the securepages module.'),
);
$form['htaccess']['boost_add_default_charset'] = array(
'#type' => 'checkbox',
'#title' => t('Add "AddDefaultCharset X" to the htaccess rules'),
'#default_value' => variable_get('boost_add_default_charset', BOOST_ADD_DEFAULT_CHARSET),
'#description' => t('Depending on your i18n settings you might want this disabled or enabled. X is set below'),
);
$form['htaccess']['boost_charset_type'] = array(
'#type' => 'textfield',
'#title' => t('Add "AddDefaultCharset utf-8" to the htaccess rules'),
'#default_value' => variable_get('boost_charset_type', BOOST_CHARSET_TYPE),
'#description' => t('Depending on your i18n settings you might want this disabled or enabled.'),
);
// reset htaccess on submit;
$form['#submit'][] = 'boost_form_submit_handler';
return system_settings_form($form);
}
/**
* Form builder; Configure boost settings.
*
* @ingroup forms
* @see system_settings_form()
*/
function boost_admin_htaccess_generation() {
// Generated .htaccess output
$htaccess = boost_admin_htaccess_generate_htaccess();
$form['boost_generated'] = array(
'#type' => 'textarea',
'#title' => t('Generated Rules'),
'#default_value' => $htaccess,
'#rows' => count(explode("\n", $htaccess))+1,
'#wysiwyg' => FALSE,
'#description' => t("Copy this into your .htaccess file below
# If your site is running in a VirtualDocumentRoot at http://example.com/, # uncomment the following line: # RewriteBase /and above
# Pass all requests not referring directly to files in the filesystem to # index.php. Clean URLs are handled in drupal_environment_initialize().