You are here

function wikitools_admin_settings in Wikitools 7

Same name and namespace in other branches
  1. 5 wikitools.module \wikitools_admin_settings()
  2. 6.2 wikitools.admin.inc \wikitools_admin_settings()
  3. 6 wikitools.admin.inc \wikitools_admin_settings()

Callback for wikitools settings form.

1 string reference to 'wikitools_admin_settings'
wikitools_menu in ./wikitools.module
Implements hook_menu().

File

./wikitools.admin.inc, line 11
Wikitools administration UI.

Code

function wikitools_admin_settings($form, &$form_state) {
  if (!module_exists('search')) {
    drupal_set_message(t('You will not be able to select the "Node Search" or "Link to search" options until you <a href="!url">enable</a> the search module.', array(
      '!url' => url('admin/modules'),
    )), 'warning');
  }
  $form = array();
  $form['wikitools_path'] = array(
    '#type' => 'textfield',
    '#title' => t('Wiki path'),
    '#default_value' => wikitools_wiki_path(),
    '#description' => t('The drupal path for the wiki. Do not include a trailing slash. Leave empty to disable the wiki path.'),
    '#field_prefix' => url(NULL, array(
      'absolute' => FALSE,
    )) . (variable_get('clean_url', 0) ? '' : '?q='),
  );
  $form['wikitools_main_page_title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title of main page'),
    '#default_value' => wikitools_main_page_title(),
    '#description' => t('The main page is shown if you type in the wiki path. Leave empty to disable the main page.'),
  );
  $form['wikitools_node_types'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Wiki node types'),
    '#options' => array_map('filter_xss', node_type_get_names()),
    '#default_value' => wikitools_node_types(),
    '#multiple' => TRUE,
    '#description' => t('Select the node types which will be affected by the specified options. If you select multiple node types, all nodes of these types will be searched for when a wikipath is entered. If a wikipage doesn\'t exist, an option to create any of these types will be given.'),
  );
  $form['wikitools_options'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Options'),
    '#options' => array(
      'node creation' => t('Node Creation: Let users create new nodes when they type in a node name which does not exist.'),
      'node search' => t('Node Search: Let users search for nodes when they type in a node name which does not exist.'),
      'auto redirect' => t('Automatic Redirect: If a title of a moved page is entered, redirect automatically.'),
      'unique titles' => t('Unique Titles: Enforce that titles of new nodes are different from existing ones.'),
      'move protection' => t('Move Protection: Disallow change of node titles for users without <em>administer nodes</em> permission.'),
      'underscore as space' => t('Treat underscores as spaces when looking for node titles.'),
      'dash as space' => t('Treat dashes as spaces when looking for node titles.'),
    ),
    '#default_value' => wikitools_options(),
    '#description' => '<ul><li>' . t('To take full advantage of the options <em>Node Creation</em>, <em>Node Search</em> and <em>Automatic Redirect</em> you should use an input format which creates wikilinks which point to the wiki path set. For exapmle a wikilink [[Page Name]] should be linked to <em>wikipath/Page Name</em>.') . '</li><li>' . t('The options <em>Node Creation</em>, <em>Node Search</em> and <em>Automatic Redirect</em> work only if a wiki path is set or if freelinking hijacking is enabled. They take the page name from the path after the wiki path, i.e. <em>wikipath/Page Name</em>, or the page name of a freelinking link, i.e. <em>freelinking/Page Name</em>.') . '</li><li>' . t('The option <em>Automatic Redirect</em> works only if node revisions are created.') . '</li></ul>',
  );
  $form['wikitools_404_type'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Wiki 404 type'),
    '#description' => t('Select the 404 (page not found) type for all pages under the wiki path.'),
    '#multiple' => TRUE,
    '#options' => array(
      'Link to search' => t('Link to search'),
      'Link to creation' => t('Link to creation'),
      'Creation form' => t('Creation form'),
    ),
    '#default_value' => wikitools_404(),
  );
  $form['wikitools_disallowed_characters'] = array(
    '#type' => 'textfield',
    '#title' => t('Disallowed characters in titles'),
    '#description' => t('Leave empty to disable this feature. Specify a list of characters which are not allowed in the title of a wiki page.'),
    '#default_value' => wikitools_disallowed_characters(),
  );
  if (module_exists('freelinking')) {
    $form['wikitools_hijack_freelinking'] = array(
      '#type' => 'checkbox',
      '#title' => t('Hijack freelinking filter'),
      '#default_value' => wikitools_hijack_freelinking(),
      '#description' => t('If you activate this option, the links of the freelinking filter will be processed by the wikitools module rather than the freelinking module. When active, a link to <em>freelinking/Page Name</em> behaves exactly as a link to <em>wikipath/Page Name</em>.'),
    );
  }
  $form['subpages'] = array(
    '#type' => 'fieldset',
    '#title' => t('Subpages'),
    '#description' => t('Subpages can be appended to a URL (either directly or via a query string) and will redirect the user to the named subpage.'),
  );
  $form['subpages']['wikitools_subpages_handling'] = array(
    '#type' => 'radios',
    '#title' => t('Activation'),
    '#options' => array(
      'disabled' => t('Disabled'),
      'url' => t('Enable url suffixes: With url suffixes, you can append the subpage to the URL. For example  <em>wikipath/Page/edit</em>.'),
      'query' => t('Enable query string: With query strings, you can append the subpage as a query. For example <em>wikipath/Page?wt_action=edit</em>.'),
    ),
    '#default_value' => wikitools_subpages_handling(),
  );
  $form['subpages']['wikitools_subpages'] = array(
    '#type' => 'textfield',
    '#title' => t('URL subpages'),
    '#description' => t('A list of available subpages. Only these subpages can be used as url suffixes or with the query string.'),
    '#default_value' => implode(", ", wikitools_subpages()),
  );
  $form = system_settings_form($form);

  // Rebuild the menu after updating the settings.
  $form['#submit'][] = 'menu_rebuild';
  return $form;
}