Index: page_title.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/page_title/page_title.admin.inc,v
retrieving revision 1.4.4.3
diff -u -p -r1.4.4.3 page_title.admin.inc
--- page_title.admin.inc	16 Jul 2010 10:14:07 -0000	1.4.4.3
+++ page_title.admin.inc	15 Oct 2010 23:25:20 -0000
@@ -25,6 +25,8 @@ function page_title_admin_settings() {
     '#type' => 'textfield',
     '#size' => 60,
     '#maxlength' => 256,
+    '#element_validate' => array('token_element_validate_token_context'),
+    '#token_types' => array(),
   );
 
 
@@ -44,7 +46,7 @@ function page_title_admin_settings() {
     //Define the default pattern - this is a "fallback" pattern.
     'page_title_default' => array(
       '#title' => t('Default'),
-      '#default_value' => variable_get('page_title_default', '[site:page-title] | [site:name]'),
+      '#default_value' => variable_get('page_title_default', '[current-page:page-title] | [site:name]'),
       '#description' => t('This pattern will be used as a <em>fallback</em> (ie, when no other pattern is defined)'),
       '#required' => TRUE,
     ) + $pattern_form_element,
@@ -68,6 +70,7 @@ function page_title_admin_settings() {
       '#title' => t('Comment Reply'),
       '#default_value' => variable_get('page_title_comment_reply', ''),
       '#description' => t('This pattern will be used for comment reply pages, where the reply is directly to a "node"'),
+      '#token_types' => array('node'),
     ) + $pattern_form_element,
 
     // Define the comment reply to comment pattern. This is used for a reply to a comment (ie comment/[0-9]+/[0-9]+).
@@ -75,6 +78,7 @@ function page_title_admin_settings() {
       '#title' => t('Comment Child Reply'),
       '#default_value' => variable_get('page_title_comment_child_reply', ''),
       '#description' => t('This pattern with be used for comment reply pages where the reply is to an existing "comment" (eg a comment thread)'),
+      '#token_types' => array('comment'),
     ) + $pattern_form_element,
 
     // Define the user profile page pattern. This is used on any 'user/[0-9]' pages
@@ -82,6 +86,7 @@ function page_title_admin_settings() {
       '#title' => t('User Profile'),
       '#default_value' => variable_get('page_title_user', ''),
       '#description' => t('This pattern will be used for any user profile pages'),
+      '#token_types' => array('user'),
     ) + $pattern_form_element,
   );
 
@@ -103,6 +108,7 @@ function page_title_admin_settings() {
       '#title' => t('Content Type - %type', array('%type' => $type->name)),
       '#default_value' => variable_get($key, ''),
       '#description' => t('This pattern will be used for all %type node-type pages', array('%type' => $type->name)),
+      '#token_types' => array('node'),
     ) + $pattern_form_element;
 
     $form['patterns']['showfield'][$key .'_showfield'] = array(
@@ -125,6 +131,7 @@ function page_title_admin_settings() {
         '#title' => t('Vocabulary - %vocab_name', array('%vocab_name' => $vocab->name)),
         '#default_value' => variable_get($key, ''),
         '#description' => t('This pattern will be used for all %title term pages', array('%title' => $vocab->name)),
+        '#token_types' => array('term'),
       ) + $pattern_form_element;
 
       $form['patterns']['showfield'][$key .'_showfield'] = array(
@@ -142,6 +149,7 @@ function page_title_admin_settings() {
     $form['patterns']['pattern'][$key] = array(
       '#title' => t('Blog Homepage'),
       '#default_value' => variable_get($key, ''),
+      '#token_types' => array('user'),
     ) + $pattern_form_element;
 
     $form['patterns']['scope'][$key] = array('#markup' => t('User'),);
@@ -167,7 +175,8 @@ function page_title_admin_settings() {
     '#collapsed' => TRUE,
   );
   $form['token_help']['content'] = array(
-    '#markup' => theme('page_title_token_help'),
+    '#theme' => 'token_tree',
+    '#token_types' => array('node', 'comment', 'term', 'user'),
   );
 
 
@@ -205,28 +214,3 @@ function theme_page_title_admin_settings
   $output .= drupal_render_children($form);
   return $output;
 }
-
-
-/**
- * An internal theme function to render the tokens to help the user. NOTE: Why is this not a core theme function?!
- */
-function theme_page_title_token_help() {
-  $token_info = token_info();
-
-  $output = '<p>'. t('Available tokens are:') .'</p>';
-  $output .= '<dl>';
-
-  // TODO - figure out what to do with the curren user token...
-  unset($token_info['types']['current-user']);
-
-  foreach($token_info['types'] as $key => $type) {
-    $output .= "<dt><strong>{$type['name']}</strong> - {$type['description']}</dt>";
-    $token_pairs = array();
-    foreach ($token_info['tokens'][$key] as $token => $info) {
-      $token_pairs[] = "<code>[{$key}:{$token}]</code> - {$info['name']}";
-    }
-    $output .= '<dd>'. theme('item_list', array('items' => $token_pairs)) .'</dd>';
-  }
-  $output .= '</dl>';
-  return $output;
-}
Index: page_title.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/page_title/page_title.info,v
retrieving revision 1.6.4.2
diff -u -p -r1.6.4.2 page_title.info
--- page_title.info	25 Aug 2010 14:33:30 -0000	1.6.4.2
+++ page_title.info	15 Oct 2010 23:25:20 -0000
@@ -2,6 +2,7 @@
 name = Page Title
 description = "Enhanced control over the page title (in the &lt;head> tag)."
 core = 7.x
+dependencies[] = token
 files[] = page_title.module
 files[] = page_title.admin.inc
 files[] = page_title.test
Index: page_title.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/page_title/page_title.module,v
retrieving revision 1.21.4.10
diff -u -p -r1.21.4.10 page_title.module
--- page_title.module	25 Aug 2010 14:33:30 -0000	1.21.4.10
+++ page_title.module	15 Oct 2010 23:25:20 -0000
@@ -29,8 +29,8 @@ function page_title_help($path, $arg) {
         t('<strong>Default Frontpage</strong>: <samp><em>site name</em> | <em>site slogan</em></samp>'),
       );
       $output .= theme('item_list', $items, NULL, 'ol');
-      $output .= '<p>'. t('The <strong>Page Title</strong> module lets you change these defaults in two ways. First, you can adjust the patterns below using the placeholders given. This will change the way the default page titles are created. Second, on enabled forms (curently node, term & user editing forms) you have the option of specifying a title that is different to the title of the item. This field only appears if the <em>Show Field</em> box is checked for the item. If a value is provided it will be used to generate the <samp>[site:page-title]</samp> placeholder however if it is left blank the <samp>[site:page-title]</samp> token will inherit the item\'s own title.') .'</p>';
-      $output .= '<p>'. t('The <samp>[site:page-title]</samp> token will default to the value returned from <samp>drupal_get_title</samp> if there is no value specified or no available page title field.') .'</p>';
+      $output .= '<p>'. t('The <strong>Page Title</strong> module lets you change these defaults in two ways. First, you can adjust the patterns below using the placeholders given. This will change the way the default page titles are created. Second, on enabled forms (curently node, term & user editing forms) you have the option of specifying a title that is different to the title of the item. This field only appears if the <em>Show Field</em> box is checked for the item. If a value is provided it will be used to generate the <samp>[current-page:page-title]</samp> placeholder however if it is left blank the <samp>[current-page:page-title]</samp> token will inherit the item\'s own title.') .'</p>';
+      $output .= '<p>'. t('The <samp>[current-page:page-title]</samp> token will default to the value returned from <samp>drupal_get_title</samp> if there is no value specified or no available page title field.') .'</p>';
       $output .= '<p>'. t('Certain types of page title pattern have access to special tokens which others do not, depending on their <em>scope</em>. All patterns have access to the <strong>Global</strong> scope. Content type patterns have access to the <strong>Node</strong> tokens, vocabulary patterns have access to the <strong>Taxonomy</strong> tokens and finally the user patterns have access to the <strong>User</strong> tokens.') .'</p>';
       break;
   }
@@ -489,16 +489,16 @@ function page_title_page_get_title($raw 
     // Allow hook_page_title_pattern_alter() to modify the pattern and tokens
     drupal_alter('page_title_pattern', $page_title_pattern, $tokens);
 
-    // If pattern is emtpy (either if the type is not overridable or simply not set) fallback to the default pattern
+    // If pattern is empty (either if the type is not overridable or simply not set) fallback to the default pattern
     if (empty($page_title_pattern)) {
-      $page_title_pattern = variable_get('page_title_default', '[site:page-title] | [site:name]');
+      $page_title_pattern = variable_get('page_title_default', '[current-page:page-title] | [site:name]');
     }
 
     // Append the pattern for pages with a pager on them
     $page_title_pattern .= isset($_REQUEST['page']) ? variable_get('page_title_pager_pattern', '') : '';
 
     // Apply token patterns using token_replace
-    $title = token_replace($page_title_pattern, $types);
+    $title = token_replace($page_title_pattern, $types, array('sanitize' => FALSE));
   }
 
   return $raw ? $title : filter_xss($title);
@@ -506,54 +506,6 @@ function page_title_page_get_title($raw 
 
 
 /**
- * Implement hook_token_values().
- *
- * @param
- *   string The type of token being generated
- *
- * @return
- *   array An array of Token ID and Token Value pairs
- */
-function page_title_tokens($type, $tokens, $data, $language = NULL, $sanitize = TRUE) {
-  $replacements = array();
-
-  if ($type == 'site') {
-    if (isset($tokens['page-title'])) {
-      $replacements[$tokens['page-title']] = page_title_get_title();
-    }
-
-    if (isset($tokens['page-title-raw'])) {
-      $replacements[$tokens['page-title-raw']] = page_title_get_title(TRUE);
-    }
-
-    // Temporary token until issue #619704 gets committed
-    if (isset($tokens['page-number'])) {
-      $replacements[$tokens['page-number']] = preg_match('/^\d+/', $_GET['page'], $match) ? $match[0] + 1 : '';
-    }
-  }
-
-  return $replacements;
-}
-
-
-/**
- * Implement hook_token_info().
- */
-function page_title_token_info() {
-  return array(
-    'tokens' => array(
-      'site' => array(
-        'page-title'     => array('name' => t('Page Title'),       'description' => t('The Page Title is used in the head of the page')),
-        'page-title-raw' => array('name' => t('Page Title - Raw'), 'description' => t('The Page Title is used in the head of the page. WARNING - raw user input')),
-        // Temporary token until issue #619704 gets committed
-        'page-number'    => array('name' => t('Page Number'),      'description' => t('The Page Number is used on pages with pagenation')),
-      ),
-    ),
-  );
-}
-
-
-/**
  * Implement hook_preprocess_html().
  */
 function page_title_preprocess_html(&$vars) {
Index: page_title.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/page_title/Attic/page_title.test,v
retrieving revision 1.1.4.2
diff -u -p -r1.1.4.2 page_title.test
--- page_title.test	14 Feb 2010 11:53:29 -0000	1.1.4.2
+++ page_title.test	15 Oct 2010 23:25:20 -0000
@@ -12,11 +12,12 @@ class PageTitleTestCase extends DrupalWe
       'name' => 'Page Title',
       'description' => 'Ensure that Page Title functions correctly',
       'group' => 'Page Title',
+      'dependencies' => array('token'),
     );
   }
 
   public function setUp() {
-    parent::setUp('page_title', 'forum', 'taxonomy');
+    parent::setUp('token', 'page_title', 'forum', 'taxonomy');
   }
 
 
@@ -75,18 +76,18 @@ class PageTitleTestCase extends DrupalWe
 
     // Define our settings
     $settings = array(
-      'page_title_default' => '[site:page-title] - DEFAULT TEST',
+      'page_title_default' => '[current-page:page-title] - DEFAULT TEST',
       'page_title_front' => '[site:name]',
       'page_title_user' => 'Profile For [user]',
-      'page_title_type_page' => 'PAGE NODE: [site:page-title]',
+      'page_title_type_page' => 'PAGE NODE: [current-page:page-title]',
       'page_title_type_page_showfield' => 1,
-      'page_title_type_forum' => 'Forum - [term:name] - [site:page-title]',
-      'page_title_pager_pattern' => ' - page [site:page-number]',
+      'page_title_type_forum' => 'Forum - [term:name] - [current-page:page-title]',
+      'page_title_pager_pattern' => ' - page [current-page:page-number]',
       'page_title_vocab_1' => 'FORUM: [term:name]',
-      'page_title_vocab_2' => 'TERM: [site:page-title]',
+      'page_title_vocab_2' => 'TERM: [current-page:page-title]',
       'page_title_vocab_1_showfield' => 1,
       'page_title_vocab_2_showfield' => 1,
-      'page_title_forum_root_title' => 'Welcome to [site:name] [site:page-title]',
+      'page_title_forum_root_title' => 'Welcome to [site:name] [current-page:page-title]',
     );
 
     // Save the settings
@@ -129,7 +130,7 @@ class PageTitleTestCase extends DrupalWe
     $this->pass(t('Created Node !nid', array('!nid' => $node->nid)), 'Page Title');
 
     // Load the node page and check for the title in the head
-    $this->pageTitleCheck('node/'. $node->nid, $settings['page_title_type_page'], array('[site:page-title]' => $node->title), 'Page Node Type');
+    $this->pageTitleCheck('node/'. $node->nid, $settings['page_title_type_page'], array('[current-page:page-title]' => $node->title), 'Page Node Type');
 
     // Post a page_title into the node and reload the node
     $edit['page_title'] = 'I am a test Page Title field';
@@ -137,7 +138,7 @@ class PageTitleTestCase extends DrupalWe
     $node = node_load($node->nid, NULL, TRUE);
 
     // Node load the node page and check for the title in the head
-    $this->pageTitleCheck('node/'. $node->nid, $settings['page_title_type_page'], array('[site:page-title]' => $node->page_title), 'Page Node Type');
+    $this->pageTitleCheck('node/'. $node->nid, $settings['page_title_type_page'], array('[current-page:page-title]' => $node->page_title), 'Page Node Type');
 
 
 
@@ -157,7 +158,7 @@ class PageTitleTestCase extends DrupalWe
     $this->pageTitleCheck(
       array('path' => 'taxonomy/term/1', 'options' => array('query' => array('page' => 1))),
       $settings['page_title_vocab_2'] . $settings['page_title_pager_pattern'],
-      array('[site:page-title]' => $term['name'], '[site:page-number]' => 2),
+      array('[current-page:page-title]' => $term['name'], '[current-page:page-number]' => 2),
       'Taxonomy Title with pagenation suffix'
     );
 return;
@@ -188,11 +189,11 @@ return;
 
 
     // Node load the node page and check for the title in the head
-    $this->pageTitleCheck('node'. $forum_node->nid, $settings['page_title_type_forum'], array('[site:page-title]' => $forum_node->title, '[term:name]' => $forum_forum['name']), 'Forum Topic');
+    $this->pageTitleCheck('node'. $forum_node->nid, $settings['page_title_type_forum'], array('[current-page:page-title]' => $forum_node->title, '[term:name]' => $forum_forum['name']), 'Forum Topic');
 
 
     //Now test the forum root...
-    $this->pageTitleCheck('forum', $settings['page_title_forum_root_title'], array('[site:page-title]' => 'Forums', '[site:name]' => 'Drupal'), 'Forum Topic');
+    $this->pageTitleCheck('forum', $settings['page_title_forum_root_title'], array('[current-page:page-title]' => 'Forums', '[site:name]' => 'Drupal'), 'Forum Topic');
 
     //Now test the forum container...
     $this->pageTitleCheck('forum/2', $settings['page_title_vocab_1'], array('[term:name]' => $forum_container['name']), 'Forum Container');
Index: page_title.tokens.inc
===================================================================
RCS file: page_title.tokens.inc
diff -N page_title.tokens.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ page_title.tokens.inc	15 Oct 2010 23:25:20 -0000
@@ -0,0 +1,39 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Builds placeholder replacement tokens for page titles.
+ */
+
+/**
+ * Implements hook_token_info().
+ */
+function page_title_token_info() {
+  $info['tokens']['current-page']['page-title'] = array(
+    'name' => t('Page Title'),
+    'description' => t('The title of the current page, as processed by the Page Title module.'),
+  );
+
+  return $info;
+}
+
+/**
+ * Implements hook_token_values().
+ */
+function page_title_tokens($type, $tokens, array $data = array(), array $options = array()) {
+  $replacements = array();
+  $sanitize = !empty($options['sanitize']);
+
+  if ($type == 'current-page') {
+    foreach ($tokens as $name => $original) {
+      switch ($name) {
+        case 'page-title':
+          $replacements[$original] = page_title_get_title(!$sanitize);
+          break;
+      }
+    }
+  }
+
+  return $replacements;
+}
