You are here

function wikitools_admin_settings in Wikitools 5

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

Builder function for settings form.

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

File

./wikitools.module, line 106
A non-intrusive module to have some wiki-like behaviour.

Code

function wikitools_admin_settings() {
  $form = array();
  list($select_query, $count_query, $arguments) = _wikitools_duplicate_nodes_query();
  if ($count_query) {
    $duplicates_exist = db_result(db_query($count_query, $arguments));
    if ($duplicates_exist) {
      drupal_set_message(t('Nodes with duplicate titles exist in your wiki. To clear up this issue, visit the <a href="!url">duplicate titles</a> page.', array(
        '!url' => url('admin/content/wikitools'),
      )), 'warning');
    }
  }
  $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. Set to &lt;none&gt; to disable the wiki path.'),
    '#field_prefix' => url(NULL, NULL, NULL, TRUE) . (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' => node_get_types('names'),
    '#size' => count(node_get_types('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.'),
      'delete protection' => t('Delete Protection: Disallow deletion of nodes 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_disallowed_characters'] = array(
    '#type' => 'textfield',
    '#title' => t('Disallowed characters in titles'),
    '#description' => t('A list of characters which are not allowed in the title of a wiki page. This setting is important for the wikilink feature to work. Set it so that your input syntax will not be confused by titles. Make sure you don\'t enter a space character unless you really want to disallow spaces in titles. Leave empty to disable this feature.'),
    '#default_value' => wikitools_disallowed_characters(),
  );
  $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()),
  );
  return system_settings_form($form);
}