You are here

function boost_admin_htaccess_page in Boost 6

Form builder; Displays Boost's htaccess generation page.

See also

system_settings_form()

1 string reference to 'boost_admin_htaccess_page'
boost_menu in ./boost.module
Implementation of hook_menu().

File

./boost.admin.inc, line 1274
All the code for the Boost module's administrative interface.

Code

function boost_admin_htaccess_page() {
  if (is_writable('robots.txt') || is_writable('.htaccess')) {

    // Filesystem autoupdates
    $form['autoupdate'] = array(
      '#type' => 'fieldset',
      '#title' => t('Auto patch .htaccess & robots.txt'),
    );

    // robots.txt
    if (is_writable('robots.txt')) {
      $form['autoupdate']['boost_autoupdate_robots_txt'] = array(
        '#type' => 'checkbox',
        '#title' => t('Insert rule into robots.txt on Save'),
        '#description' => t('If this box is checked, insert "Disallow: /boost_stats.php" into robots.txt if boost is enabled.'),
        '#default_value' => variable_get('boost_autoupdate_robots_txt', FALSE),
      );
    }

    // .htaccess
    if (is_writable('.htaccess')) {
      $form['autoupdate']['boost_autoupdate_htaccess'] = array(
        '#type' => 'checkbox',
        '#title' => t('Update .htaccess on Save'),
        '#description' => t('If this box is checked, update .htaccess with the generated Boost htaccess rules if Boost is enabled. Shown below is what will be inserted; editing the text below will have no impact on what gets written.'),
        '#default_value' => variable_get('boost_autoupdate_htaccess', FALSE),
      );
    }
    $form['autoupdate']['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Save configuration to file system'),
    );
  }

  // Generated .htaccess output
  $htaccess = boost_admin_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 <pre><tt>  # RewriteBase / </tt></pre> and above <pre><tt>  # Rewrite URLs of the form 'x' to the form 'index.php?q=x'</tt></pre><br />Note that the generated rules' settings can be configure at !link under 'Boost Apache .htaccess settings generation' section.", array(
      '!link' => l('admin/settings/performance/boost', 'admin/settings/performance/boost'),
    )),
  );
  $form['#submit'][] = 'boost_admin_htaccess_page_submit';
  return $form;
}