You are here

function htmltidy_settings in HTML Tidy 5

Drupal hook that allows an administrator to view or modify module settings.

Return value

The form containing module-specific settings.

1 string reference to 'htmltidy_settings'
htmltidy_menu in ./htmltidy.module
Implementation of hook_menu().

File

./htmltidy.module, line 355

Code

function htmltidy_settings() {
  if (!htmltidy_test($message, $version)) {
    drupal_set_message('HTMLTidy executable is not available. ' . $message, 'error');
    $form['check_tidy'] = array(
      '#type' => 'fieldset',
      '#value' => t('We require the HTML Tidy binary to be available on the
        server. Please <a href="http://tidy.sourceforge.net/">download and
        install it</a> wherever you can, then tell me where to find it.'),
    );
  }
  else {
    $form['check_tidy'] = array(
      '#value' => t('<p>HTMLTidy is present and correct: <pre>%tidy_version</pre></p>', array(
        '%tidy_version' => $version,
      )),
    );
  }
  $form['htmltidy_apppath'] = array(
    '#type' => 'textfield',
    '#title' => t('Path to htmltidy executable'),
    '#default_value' => variable_get('htmltidy_apppath', '/usr/bin/tidy'),
    '#description' => t('Enter the full path to htmltidy. e.g. /usr/local/bin/tidy'),
  );
  $form['htmltidy_confpath'] = array(
    '#type' => 'textfield',
    '#title' => t('Path to htmltidy.conf'),
    '#default_value' => variable_get('htmltidy_confpath', ''),
    '#description' => t("For options more advanced than those shown here, you can use an <a href='http://tidy.sourceforge.net/docs/quickref.html'>HTMLTidy configuration file</a>. Enter the full path here ( eg <code>%path</code> ), or leave it blank for none. The explicit options here usually take precedence over the conf file.", array(
      '%path' => preg_replace('|\\\\|', '/', dirname(__FILE__)) . "/htmltidy.conf",
    )),
  );
  $form['formatting_paths'] = array(
    '#type' => 'fieldset',
    '#title' => t('Paths'),
    '#tree' => FALSE,
    'htmltidy_process_input' => array(
      '#type' => 'checkbox',
      '#title' => t('Validate input text'),
      '#default_value' => variable_get('htmltidy_process_input', FALSE),
      '#description' => t("More efficient than processing the output, we can instead run tidy over all text <em>entered</em> as node content. HTML will be corrected at 'Preview' time and only good HTML will ever be saved. Depending on the tidy options however, this may conflict slightly with the other output filters."),
    ),
  );
  $form['formatting_options'] = array(
    '#type' => 'fieldset',
    '#title' => t('Formatting Options'),
    'htmltidy_indent' => array(
      '#type' => 'checkbox',
      '#title' => 'Indent output',
      '#default_value' => variable_get('htmltidy_indent', 1),
      '#description' => t('When checked, htmltidy will indent HTML blocks. (&lt;div&gt;, &lt;p&gt;, etc.)'),
    ),
    'htmltidy_wrapphp' => array(
      '#type' => 'checkbox',
      '#title' => t('wrap-php'),
      '#default_value' => variable_get('htmltidy_wrapphp', 1),
      '#description' => t('When checked, htmltidy will wrap php pseudo-elements at the column entered above.  Naturally, you must set the wrap column before this will do anything.'),
    ),
    'htmltidy_tidymark' => array(
      '#type' => 'checkbox',
      '#title' => 'tidy-mark',
      '#default_value' => variable_get('htmltidy_tidymark', 1),
      '#description' => t('When checked, htmltidy will include a &lt;meta&gt; tag specifying that htmltidy was used to generate the HTML. This has no effect if the &lt;meta&gt; tag is already specified.'),
    ),
    'htmltidy_clean' => array(
      '#type' => 'checkbox',
      '#title' => 'clean',
      '#default_value' => variable_get('htmltidy_clean', 1),
      '#description' => t('Removes surplus tags and attributes, eliminating FONT tags and other, replacing them with style rules and structual markup. Be cautioned that turning this setting on will most likely break parts of Drupal (most notably the book module), and the automatically named style rules may simply not work.'),
    ),
    'htmltidy_xhtml' => array(
      '#type' => 'checkbox',
      '#title' => 'output-xhtml',
      '#default_value' => variable_get('htmltidy_xhtml', 0),
      '#description' => t('Generate XHTML content.  This will set the doctype and namespace to the appropriate XHTML spec.  Note that you need to set the doctype below to actually validate against an XHTML DTD.'),
    ),
    'htmltidy_doctype' => array(
      '#type' => 'textfield',
      '#title' => 'doctype',
      '#default_value' => variable_get('htmltidy_doctype', 'auto'),
      '#size' => 25,
      '#maxlength' => 25,
      '#description' => t('Enter the doctype declaration that tidy will generate and validate against (if generating XHTML).  Valid options include: omit, auto, strict, loose, and any valid formal public identifier (don\'t try this if you are unsure what that means).'),
    ),
    'htmltidy_enclosetext' => array(
      '#type' => 'checkbox',
      '#title' => 'enclose-text',
      '#default_value' => variable_get('htmltidy_enclosetext', 0),
      '#description' => t('Tidy will enclose any text found in the body element with &lt;p&gt; tags.  This lets you use stylesheets with greater control, fixes margins, and is required if you want valid XHTML.'),
    ),
    'htmltidy_encloseblocktext' => array(
      '#type' => 'checkbox',
      '#title' => 'enclose-block-text',
      '#default_value' => variable_get('htmltidy_encloseblocktext', 0),
      '#description' => t('Just like the above option, but applies to any text found in an element that allows mixed content for HTML Transitional but not HTML Strict.'),
    ),
    'htmltidy_wordcleanup' => array(
      '#type' => 'checkbox',
      '#title' => 'word-2000',
      '#default_value' => variable_get('htmltidy_wordcleanup', 1),
      '#description' => t('This option specifies if Tidy should go to great pains to strip out all the surplus stuff Microsoft Word 2000 inserts when you save Word documents as "Web pages".'),
    ),
  );
  $form['debug_options'] = array(
    '#type' => 'fieldset',
    '#title' => t('Debug Options'),
    '#collapsible' => TRUE,
    '#collapsed' => TRUE,
    'htmltidy_warnings' => array(
      '#type' => 'checkbox',
      '#title' => t('Append errors and warnings'),
      '#default_value' => variable_get('htmltidy_warnings', 0),
      '#description' => t('When checked, errors, warnings and info from htmltidy will be appended to the end of pages, but only for users in <a href="%admin-user-role">roles</a> with the <strong>use htmltidy debug mode</strong> <a href="%admin-user-permission">permission flag</a> set.<br />This is useful for catching non-XHTML compliant document errors, for example.', array(
        '%admin-user-role' => url('admin/user/role'),
        '%admin-user-permission' => url('admin/user/permission'),
      )),
    ),
    'htmltidy_verbose' => array(
      '#type' => 'checkbox',
      '#title' => t('Verbose'),
      '#default_value' => variable_get('htmltidy_verbose', 0),
      '#description' => t('Be more verbose (describe what warnings/errors mean in footer).'),
    ),
    'htmltidy_runtwice' => array(
      '#type' => 'checkbox',
      '#title' => t('Run twice'),
      '#default_value' => variable_get('htmltidy_runtwice', 1),
      '#description' => t('This gets the line numbers on the warnings right, but is slower.  This applies only if debug mode is on.'),
    ),
  );
  return system_settings_form($form);
}