js.admin.inc 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. /**
  3. * @file
  4. * JavaScript callback handler module.
  5. */
  6. /**
  7. * Form callback for the js configuration form.
  8. */
  9. function js_configure_form($form, &$form_state) {
  10. $htaccess = '# Rewrite JavaScript callback URLs of the form js.php?q=x.' . PHP_EOL;
  11. $htaccess .= 'RewriteCond %{REQUEST_URI} ^' . str_replace("/", "\/", base_path()) . '([a-z]{2}\/)?js\/.*' . PHP_EOL;
  12. $htaccess .= 'RewriteRule ^(.*)$ js.php?q=$1 [L,QSA]' . PHP_EOL;
  13. $htaccess .= 'RewriteCond %{QUERY_STRING} (^|&)q=((\/)?[a-z]{2})?(\/)?js\/.*' . PHP_EOL;
  14. $htaccess .= 'RewriteRule .* js.php [L]';
  15. $form['js_server_software'] = array(
  16. '#type' => 'select',
  17. '#options' => array('apache' => 'Apache', 'other' => t('Other')),
  18. '#title' => t('Server software'),
  19. '#description' => t('The server software for the http server, used to detect if the requirements for the module are met. Set this to other if running on anything other than Apache.'),
  20. '#default_value' => variable_get('js_server_software', 'apache'),
  21. );
  22. $form['htaccess'] = array(
  23. '#type' => 'textarea',
  24. '#title' => t('Add the following lines in front of the existing RewriteRules in your .htaccess.'),
  25. '#value' => $htaccess,
  26. );
  27. return system_settings_form($form);
  28. }