Index: wikitools.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/wikitools/Attic/wikitools.admin.inc,v
retrieving revision 1.1.2.3
diff -u -p -r1.1.2.3 wikitools.admin.inc
--- wikitools.admin.inc	20 Sep 2009 16:02:10 -0000	1.1.2.3
+++ wikitools.admin.inc	12 Feb 2011 18:11:10 -0000
@@ -9,24 +9,20 @@
 /**
  * Callback for wikitools settings form.
  */
-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');
-    }
+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=')
+    '#field_prefix' => url(NULL, array('absolute' => FALSE)) . (variable_get('clean_url', 0) ? '' : '?q='),
   );
   $form['wikitools_main_page_title'] = array(
     '#type' => 'textfield',
@@ -37,7 +33,7 @@ function wikitools_admin_settings() {
   $form['wikitools_node_types'] = array(
     '#type' => 'checkboxes',
     '#title' => t('Wiki node types'),
-    '#options' => node_get_types('names'),
+    '#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.'),
@@ -55,10 +51,10 @@ function wikitools_admin_settings() {
       '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>',
+    '#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',
@@ -127,14 +123,14 @@ function wikitools_page_duplicates() {
 
     // Grab all nodes that have the same title
     $result = pager_query($select_query, $nodes_per_page, 0, $count_query, $arguments);
-    while ($node = db_fetch_object($result)) {
+    foreach ($result as $node) {
       $output .= node_view(node_load($node->nid), 1);
       $found_nodes = TRUE;
     }
   }
 
   if ($found_nodes) {
-    $output .= theme('pager', NULL, $nodes_per_page);
+    $output .= theme('pager', array('tags' => NULL));
   }
 
   // Return a nice listing of all the duplicate nodes
@@ -160,11 +156,10 @@ function _wikitools_duplicate_nodes_quer
     }
 
     // Grab all nodes that have the same title
-    $node_types_placeholders = db_placeholders($node_types, 'varchar');
-    $from_part = 'FROM {node} n1, {node} n2 WHERE LOWER('. $n1_title .') = LOWER('. $n2_title .') AND n1.nid != n2.nid AND n1.type IN('. $node_types_placeholders .') AND n2.type IN('. $node_types_placeholders .')';
+    $from_part = 'FROM {node} n1, {node} n2 WHERE LOWER(' . $n1_title . ') = LOWER(' . $n2_title . ') AND n1.nid != n2.nid AND n1.type IN(:type) AND n2.type IN(:type)';
     $select_query = 'SELECT DISTINCT(n1.nid), n1.title ' . $from_part . ' ORDER BY n1.title ASC';
     $count_query = 'SELECT COUNT(DISTINCT(n1.nid)) ' . $from_part;
-    return array($select_query, $count_query, array_merge($node_types, $node_types));
+    return array($select_query, $count_query, array(':type' => $node_types));
   }
   return array(NULL, NULL, NULL);
 }
Index: wikitools.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/wikitools/wikitools.info,v
retrieving revision 1.4
diff -u -p -r1.4 wikitools.info
--- wikitools.info	31 Dec 2007 23:35:06 -0000	1.4
+++ wikitools.info	12 Feb 2011 18:11:10 -0000
@@ -1,4 +1,8 @@
 ; $Id: wikitools.info,v 1.4 2007/12/31 23:35:06 cwgordon7 Exp $
 name = Wikitools
 description = Provides helper functionality to have wiki-like behaviour.
-core = "6.x"
\ No newline at end of file
+core = 7.x
+files[] = wikitools.admin.inc
+files[] = wikitools.module
+files[] = wikitools.pages.inc
+configure = admin/config/wikitools
\ No newline at end of file
Index: wikitools.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/wikitools/wikitools.module,v
retrieving revision 1.4.2.13
diff -u -p -r1.4.2.13 wikitools.module
--- wikitools.module	18 Jun 2009 04:25:27 -0000	1.4.2.13
+++ wikitools.module	12 Feb 2011 18:11:10 -0000
@@ -7,18 +7,18 @@
  */
 
 /**
- * Implementation of hook_help().
+ * Implements hook_help().
  */
 function wikitools_help($path, $arg) {
   switch ($path) {
     case 'admin/help#wikitools':
-      $output = '<p>'. t('The wikitools module allows you to set several options for your content to get a more wiki-like behaviour.') .'</p>';
+      $output = '<p>' . t('The wikitools module allows you to set several options for your content to get a more wiki-like behaviour.') . '</p>';
       return $output;
-    case 'admin/settings/wikitools':
-      $output = '<p>'. t('Below you can configure the settings for the wikitools module. The "wiki path" will be the path that will redirect you to the wiki page with the appropriate title; only the wiki node types selected can be accesssed from the wiki path. Choose from the other options to determine the behavior of the wiki path.') .'</p>';
+    case 'admin/config/wikitools':
+      $output = '<p>' . t('Below you can configure the settings for the wikitools module. The "wiki path" will be the path that will redirect you to the wiki page with the appropriate title; only the wiki node types selected can be accesssed from the wiki path. Choose from the other options to determine the behavior of the wiki path. To check if nodes with duplicate titles exist in your wiki, visit the <a href="!url">duplicate titles</a> page.', array('!url' => url('admin/content/wikitools'))) . '</p>';
       return $output;
     case 'admin/content/wikitools':
-      $output = '<p>'. t('Wikitools allows restrictions on node titles so that all new created nodes have guaranteed unique titles. Titles of nodes that were created before it was included in this option, however, are not guaranteed to have unique page titles. This page lists all nodes that have duplicate page titles, so that their titles may be changed to be unique.') .'</p>';
+      $output = '<p>' . t('Wikitools allows restrictions on node titles so that all new created nodes have guaranteed unique titles. Titles of nodes that were created before it was included in this option, however, are not guaranteed to have unique page titles. This page lists all nodes that have duplicate page titles, so that their titles may be changed to be unique.') . '</p>';
       return $output;
   }
 }
@@ -28,11 +28,11 @@ function wikitools_help($path, $arg) {
  */
 
 /**
- * Implementation of hook_menu().
+ * Implements hook_menu().
  */
 function wikitools_menu() {
   $items = array();
-  $items['admin/settings/wikitools'] = array(
+  $items['admin/config/wikitools'] = array(
     'title' => t('Wikitools'),
     'description' => t('Settings for wiki-like behaviour.'),
     'access arguments' => array('administer site configuration'),
@@ -103,7 +103,7 @@ function wikitools_node_types($value = N
     static $node_types = NULL;
     if (is_null($node_types)) {
       $node_types = array();
-      foreach(variable_get('wikitools_node_types', array()) as $type => $active) {
+      foreach (variable_get('wikitools_node_types', array()) as $type => $active) {
         if ($active) {
           $node_types[$type] = $type;
         }
@@ -130,9 +130,13 @@ function wikitools_type_affected($type) 
  */
 function wikitools_404($value = NULL) {
   if (is_null($value)) {
-    return variable_get('wikitools_404_type', drupal_map_assoc(array('Link to creation')));
+    $variable = variable_get('wikitools_404_type', drupal_map_assoc(array('Link to creation')));
+    if (!module_exists('search')) {
+      unset($variable['Link to search']);
+    }
+    return $variable;
   }
-  variable_set('wikitools_404_type', $values);
+  variable_set('wikitools_404_type', $value);
 }
 
 /**
@@ -149,7 +153,11 @@ function wikitools_disallowed_characters
  * Various wikitool options.
  */
 function wikitools_options() {
-  return variable_get('wikitools_options', drupal_map_assoc(array('node creation', 'node search', 'unique titles', 'underscore as space')));
+  $variable = variable_get('wikitools_options', drupal_map_assoc(array('node creation', 'node search', 'unique titles', 'underscore as space')));
+  if (!module_exists('search')) {
+    unset($variable['node search']);
+  }
+  return $variable;
 }
 
 /**
@@ -301,7 +309,7 @@ function wikitools_create_url($type, $ti
  *   title to search for
  */
 function wikitools_search_url($title) {
-  return url('search/node/'. $title);
+  return url('search/node/' . $title);
 }
 
 /**
@@ -327,17 +335,17 @@ function wikitools_wikilink_url($title, 
  */
 function wikitools_wikilink_drupal_path($title) {
   if ($wiki_path = wikitools_wiki_path()) {
-    return $wiki_path .'/'. wikitools_encode_page_name($title);
+    return $wiki_path . '/' . wikitools_encode_page_name($title);
   }
   elseif (wikitools_hijack_freelinking()) {
-    return 'freelinking/'. wikitools_encode_page_name($title);
+    return 'freelinking/' . wikitools_encode_page_name($title);
   }
   else {
     // Neither wikitools nor freelinking will handle the link.
     // Try to find a node with the given name and link directly to the first match.
-    $result = db_query("SELECT nid, type FROM {node} WHERE LOWER(title) = LOWER('%s')", $title);
+    $result = db_query("SELECT nid, type FROM {node} WHERE LOWER(title) = LOWER(:title)", array(':title' => $title));
     $found_nodes = array();
-    while ($node = db_fetch_object($result)) {
+    foreach ($result as $node) {
       if (wikitools_type_affected($node->type)) {
         return "node/$node->nid";
       }
@@ -346,17 +354,6 @@ function wikitools_wikilink_drupal_path(
 }
 
 /**
- * Implementation of hook_nodeapi().
- */
-function wikitools_nodeapi(&$node, $op, $form = NULL, $a4 = NULL) {
-  switch ($op) {
-    case 'validate':
-      wikitools_node_validate($node);
-      break;
-  }
-}
-
-/**
  * Validate check of node edit form.
  */
 function wikitools_node_validate($node) {
@@ -364,24 +361,12 @@ function wikitools_node_validate($node) 
     // Check for unique titles.
     if (wikitools_enforce_unique_titles()) {
       // Build node type condition.
-      $types_clause = NULL;
-      foreach(wikitools_node_types() as $type) {
-        if ($types_clause) {
-          $types_clause .= ",'" . db_escape_string($type) . "'";
-        }
-        else {
-          $types_clause = "type IN ('" . db_escape_string($type) . "'";
-        }
-      }
-      // There is at least one node type, so this will always be well-formed.
-      $types_clause .= ')';
-
-      $nid = db_result(db_query("SELECT nid FROM {node} WHERE LOWER(title) = LOWER('%s') AND $types_clause", $node->title));
+      $nid = db_query("SELECT nid FROM {node} WHERE LOWER(title) = LOWER(:title) AND type IN (:types)", array(':title' => $node->title, ':types' => wikitools_node_types()))->fetchField();
       if (!$nid && wikitools_treat_underscore_as_space()) {
-        $nid = db_result(db_query("SELECT nid FROM {node} WHERE LOWER(REPLACE(title, '_', ' ')) = LOWER(REPLACE('%s', '_', ' ')) AND $types_clause", $node->title));
+        $nid = db_query("SELECT nid FROM {node} WHERE LOWER(REPLACE(title, '_', ' ')) = LOWER(REPLACE(:title, '_', ' ')) AND type IN (:types)", array(':title' => $node->title, ':types' => wikitools_node_types()))->fetchField();
       }
       if (!$nid && wikitools_treat_dash_as_space()) {
-        $nid = db_result(db_query("SELECT nid FROM {node} WHERE LOWER(REPLACE(title, '-', ' ')) = LOWER(REPLACE('%s', '-', ' ')) AND $types_clause", $node->title));
+        $nid = db_query("SELECT nid FROM {node} WHERE LOWER(REPLACE(title, '-', ' ')) = LOWER(REPLACE(:title, '-', ' ')) AND type IN (:types)", array(':title' => $node->title, ':types' => wikitools_node_types()))->fetchField();
       }
       // It is only an error if the node which already exists is not the currently edited node.
       if ($nid && $nid != $node->nid) {
@@ -408,57 +393,54 @@ function wikitools_node_validate($node) 
 }
 
 /**
- * Implementation of hook_form_alter().
+ * Implements hook_form_FORM_ID_alter().
  */
-function wikitools_form_alter(&$form, $form_state, $form_id) {
-  // Check if it is a node editing form of an affected type.
-  if (isset($form['type']) && $form['type']['#value'] .'_node_form' == $form_id) {
-    if (wikitools_type_affected($form['type']['#value'])) {
-      if ($form['nid']['#value']) {
-        // Node is edited.
-        if (wikitools_move_protection() && !user_access('administer nodes')) {
-          $form['wikitools_title'] = $form['title'];
-          $form['wikitools_title']['#attributes']['readonly'] = 'readonly';
-          $form['title']['#type'] = 'value';
-        }
+function wikitools_form_node_form_alter(&$form, $form_state) {
+  if (wikitools_type_affected($form['type']['#value'])) {
+    if ($form['nid']['#value']) {
+      // Node is edited.
+      if (wikitools_move_protection() && !user_access('bypass node access')) {
+        $form['wikitools_title'] = $form['title'];
+        $form['wikitools_title']['#attributes']['readonly'] = 'readonly';
+        $form['title']['#type'] = 'value';
       }
-      else {
-        // Node is new.
-        if (isset($_GET['edit'])) {
-          $form['title']['#default_value'] = urldecode($_GET['edit']['title']);
-        }
+    }
+    else {
+      // Node is new.
+      if (isset($_GET['edit'])) {
+        $form['title']['#default_value'] = urldecode($_GET['edit']['title']);
       }
     }
   }
 }
 
 /**
- * Implementation of hook_theme().
+ * Implements hook_theme().
  */
 function wikitools_theme() {
   return array(
     'wikitools_page_found' => array(
-      'arguments' => array('page_name' => NULL, 'found_nodes' => NULL),
+      'variables' => array('page_name' => NULL, 'found_nodes' => NULL),
       'file' => 'wikitools.pages.inc',
     ),
     'wikitools_page_moved' => array(
-      'arguments' => array('page_name' => NULL, 'moved_nodes' => NULL),
+      'variables' => array('page_name' => NULL, 'moved_nodes' => NULL),
       'file' => 'wikitools.pages.inc',
     ),
     'wikitools_page_does_not_exist' => array(
-      'arguments' => array('page_name' => NULL),
+      'variables' => array('page_name' => NULL),
       'file' => 'wikitools.pages.inc',
     ),
     'wikitools_search_notice' => array(
-      'arguments' => array('page_name' => NULL),
+      'variables' => array('page_name' => NULL),
       'file' => 'wikitools.pages.inc',
     ),
     'wikitools_create_notice' => array(
-      'arguments' => array('page_name' => NULL),
+      'variables' => array('page_name' => NULL),
       'file' => 'wikitools.pages.inc',
     ),
     'wikitools_create' => array(
-      'arguments' => array('page_name' => NULL),
+      'variables' => array('page_name' => NULL),
       'file' => 'wikitools.pages.inc',
     ),
   );
Index: wikitools.pages.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/wikitools/Attic/wikitools.pages.inc,v
retrieving revision 1.1.2.9
diff -u -p -r1.1.2.9 wikitools.pages.inc
--- wikitools.pages.inc	10 Jul 2009 05:51:12 -0000	1.1.2.9
+++ wikitools.pages.inc	12 Feb 2011 18:11:10 -0000
@@ -36,7 +36,7 @@ function wikitools_handle_request() {
   }
   elseif (wikitools_subpages_handling() == 'url') {
     // Check if there are more than one part, and if the last one is a valid subpage.
-    if (count($args)-$i > 1 && in_array(end($args), wikitools_subpages())) {
+    if (count($args) -$i > 1 && in_array(end($args), wikitools_subpages())) {
       $subpage = end($args);
       array_pop($args);
     }
@@ -54,12 +54,14 @@ function wikitools_handle_request() {
   // Don't do anything if no node types are active or no page name is available
   $node_types = wikitools_node_types();
   if (count($node_types) && $page_name) {
+    $page_name = check_plain($page_name);
     // Try to find the current page with this name, limit the query by node types
-    $params = $node_types;
-    $params[] = $page_name;
-    $result = db_query("SELECT nid, type FROM {node} WHERE type IN (". db_placeholders($node_types, 'varchar') .") AND LOWER(title) = LOWER('%s')", $params);
+    $result = db_query("SELECT nid, type FROM {node} WHERE type IN (:type) AND LOWER(title) = LOWER(:title)", array(
+      ':type' => $node_types,
+      'title' => $page_name,
+    ));
     $found_nodes = array();
-    while ($node = db_fetch_object($result)) {
+    foreach ($result as $node) {
       if (wikitools_type_affected($node->type)) {
         $found_nodes[] = $node;
       }
@@ -76,14 +78,14 @@ function wikitools_handle_request() {
     }
     else if (count($found_nodes) > 1) {
       // Multiple match for title.
-      drupal_set_title(t('Page found: %page', array('%page' => $page_name)));
-      $output .= theme('wikitools_page_found', $page_name, $found_nodes);
+      drupal_set_title(t('Page found: %page', array('%page' => $page_name)), PASS_THROUGH);
+      $output .= theme('wikitools_page_found', array('page_name' => $page_name, 'found_nodes' => $found_nodes));
     }
     else {
       // No match for title. Try to find an old page with this name
-      $result = db_query("SELECT n.nid, n.type, n.title FROM {node} n LEFT JOIN {node_revisions} r ON n.nid = r.nid WHERE LOWER(r.title) = LOWER('%s') ORDER BY n.vid DESC", $page_name);
+      $result = db_query("SELECT n.nid, n.type, n.title FROM {node} n LEFT JOIN {node_revision} r ON n.nid = r.nid WHERE LOWER(r.title) = LOWER(:title) ORDER BY n.vid DESC", array(':title' => $page_name));
       $moved_nodes = array();
-      while ($node = db_fetch_object($result)) {
+      foreach ($result as $node) {
         if (wikitools_type_affected($node->type)) {
           $moved_nodes[] = $node;
         }
@@ -94,12 +96,12 @@ function wikitools_handle_request() {
         drupal_goto("node/$node->nid");
       }
       else if (count($moved_nodes) > 0) {
-        drupal_set_title(t('Page moved: %page', array('%page' => $page_name)));
-        $output = theme('wikitools_page_moved', $page_name, $moved_nodes);
+        drupal_set_title(t('Page moved: %page', array('%page' => $page_name)), PASS_THROUGH);
+        $output = theme('wikitools_page_moved', array('page_name' => $page_name, 'moved_nodes' => $moved_nodes));
       }
       else {
-        drupal_set_title(t('Page does not exist: %page', array('%page' => $page_name)));
-        $output = theme('wikitools_page_does_not_exist', $page_name);
+        drupal_set_title(t('Page does not exist: %page', array('%page' => $page_name)), PASS_THROUGH);
+        $output = theme('wikitools_page_does_not_exist', array('page_name' => $page_name));
       }
     }
   }
@@ -116,99 +118,133 @@ function wikitools_handle_request() {
  * @ingroup themeable
  */
 
-function theme_wikitools_page_found($page_name, $found_nodes) {
-  $output = '<p>'. t('Multiple pages have this name:') .'</p>';
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
+function theme_wikitools_page_found($variables) {
+  $page_name = $variables['page_name'];
+  $found_nodes = $variables['found_nodes'];
+  $output = '<p>' . t('Multiple pages have this name:') . '</p>';
   foreach ($found_nodes as $info) {
     $node = node_load($info->nid);
     $output .= node_view($node, TRUE, FALSE, FALSE);
   }
-  $output .= theme('wikitools_search_notice', $page_name);
+  $output .= theme('wikitools_search_notice', array('page_name' => $page_name));
   if (!wikitools_enforce_unique_titles()) {
-    $output .= theme('wikitools_create_notice', $page_name);
+    $output .= theme('wikitools_create_notice', array('page_name' => $page_name));
   }
   return $output;
 }
 
-function theme_wikitools_page_moved($page_name, $moved_nodes) {
-  $output = '<p>'. t('The page %page_name has been moved.', array('%page_name' => $page_name)) .'</p>';
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
+function theme_wikitools_page_moved($variables) {
+  $page_name = $variables['page_name'];
+  $moved_nodes = $variables['moved_nodes'];
+  $output = '<p>' . t('The page %page_name has been moved.', array('%page_name' => $page_name)) . '</p>';
   $node = current($moved_nodes);
-  $output .= '<p>'. t('The new page name is !new_name', array('!new_name' => l($node->title, "node/$node->nid"))) .'</p>';
+  $output .= '<p>' . t('The new page name is !new_name', array('!new_name' => l($node->title, "node/$node->nid"))) . '</p>';
   // Todo: show all moved pages
-  $output .= theme('wikitools_search_notice', $page_name);
-  $output .= theme('wikitools_create_notice', $page_name);
+  $output .= theme('wikitools_search_notice', array('page_name' => $page_name));
+  $output .= theme('wikitools_create_notice', array('page_name' => $page_name));
   return $output;
 }
 
-function theme_wikitools_page_does_not_exist($page_name) {
-  $output = '<p>'. t('The page %page_name does not exist.', array('%page_name' => $page_name)) .'</p>';
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
+function theme_wikitools_page_does_not_exist($variables) {
+  $page_name = $variables['page_name'];
+  $output = '<p>' . t('The page %page_name does not exist.', array('%page_name' => $page_name)) . '</p>';
   $settings = wikitools_404();
   if (!empty($settings['Link to search'])) {
-    $output .= theme('wikitools_search_notice', $page_name);
+    $output .= theme('wikitools_search_notice', array('page_name' => $page_name));
   }
   if (!empty($settings['Link to creation'])) {
-    $output .= theme('wikitools_create_notice', $page_name);
+    $output .= theme('wikitools_create_notice', array('page_name' => $page_name));
   }
   if (!empty($settings['Creation form'])) {
-    $output .= theme('wikitools_create', $page_name);
+    $output .= theme('wikitools_create', array('page_name' => $page_name));
   }
+  drupal_add_http_header('Status', '404 Not Found');
   return $output;
 }
 
-function theme_wikitools_search_notice($page_name) {
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
+function theme_wikitools_search_notice($variables) {
+  $page_name = $variables['page_name'];
   $output = '';
   if (module_exists('search') && user_access('search content') && wikitools_node_search()) {
-    $output .= '<p>'. t('You can <a href="@url">search for %page_name</a>', array('@url' => wikitools_search_url($page_name), '%page_name' => $page_name)) .'</p>';
+    $output .= '<p>' . t('You can <a href="@url">search for %page_name</a>', array('@url' => wikitools_search_url($page_name), '%page_name' => $page_name)) . '</p>';
   }
   return $output;
 }
 
-function theme_wikitools_create_notice($page_name) {
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
+function theme_wikitools_create_notice($variables) {
+  $page_name = $variables['page_name'];
   $output = '';
   $node_types = wikitools_node_types();
   if (wikitools_node_creation() && count($node_types)) {
     $create = '';
     $count = 0;
     foreach ($node_types as $type) {
-      $type = node_get_types('type', $type);
+      $type = node_type_get_type($type);
       if (node_access('create', $type->type)) {
-        $create .= '<dt><a href="'. wikitools_create_url($type, $page_name) .'">'. $type->name .'</a></dt>';
-        $create .= '<dd>'. filter_xss_admin($type->description) .'</dd>';
+        $create .= '<dt><a href="' . wikitools_create_url($type, $page_name) . '">' . $type->name . '</a></dt>';
+        $create .= '<dd>' . filter_xss_admin($type->description) . '</dd>';
       }
     }
     if ($create) {
-      $output .= '<p>'. t('You can create the page as:') .'</p>';
-      $output .= '<dl>'. $create .'</dl>';
+      $output .= '<p>' . t('You can create the page as:') . '</p>';
+      $output .= '<dl>' . $create . '</dl>';
     }
   }
   return $output;
 }
 
-function theme_wikitools_create($page_name) {
+/**
+ * @todo Please document this function.
+ * @see http://drupal.org/node/1354
+ */
+function theme_wikitools_create($variables) {
+  $page_name = $variables['page_name'];
   $node_types = wikitools_node_types();
-  $form = array();
   $output = '';
   if (wikitools_node_creation() && count($node_types)) {
-    $output .= '<p>'. t('You can create the page as:') .'</p>';
+    module_load_include('inc', 'node', 'node.pages');
+    $output .= '<p>' . t('You can create the page as:') . '</p>';
     // Collapse the forms initially if there are more than one.
     $collapsed = count($node_types) > 1 ? ' collapsed' : '';
     // The form_alter hooks excpects the preset title in the GET array, so we put it there.
     $_GET['edit']['title'] = $page_name;
     foreach ($node_types as $type) {
       drupal_add_js('misc/collapse.js');
-      $type = node_get_types('type', $type);
+      $type = node_type_get_type($type);
       if (node_access('create', $type->type)) {
-        $output .= '<fieldset class="collapsible' . $collapsed . '"><legend>'. $type->name .'</legend>';
-        if ($router_item = menu_get_item('node/add/'. str_replace('_', '-', $type->type))) {
-          if ($router_item['file']) {
-            require_once($router_item['file']);
+        $output .= '<fieldset class="collapsible' . $collapsed . '"><legend>' . $type->name . '</legend>';
+        if ($router_item = menu_get_item('node/add/' . str_replace('_', '-', $type->type))) {
+          if (isset($router_item['file'])) {
+            require_once DRUPAL_ROOT . '/' . $router_item['file'];
           }
-          $output .= call_user_func_array($router_item['page_callback'], $router_item['page_arguments']);
+          $form = call_user_func_array($router_item['page_callback'], $router_item['page_arguments']);
+          $output .= drupal_render($form);
         }
         $output .= '</fieldset>';
       }
     }
     // Some of the callbacks could have set the page title, so we reset it.
-    drupal_set_title(t('Page does not exist: %page', array('%page' => $page_name)));
+    drupal_set_title(t('Page does not exist: %page', array('%page' => $page_name)), PASS_THROUGH);
   }
   return $output;
 }
