? 0-user-text-field-tokens.txt
? field_token.tpl.php
? jquery-ui-tree
? jstree
? menu.tokens.inc
? patches
? theme
? token.inc
? treeTable
Index: token.tokens.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/token/token.tokens.inc,v
retrieving revision 1.36
diff -u -p -r1.36 token.tokens.inc
--- token.tokens.inc	18 Dec 2010 01:53:33 -0000	1.36
+++ token.tokens.inc	3 Jan 2011 20:20:33 -0000
@@ -35,15 +35,28 @@ function token_token_info_alter(&$info) 
     }
     $token_type = $entity_info['token type'];
 
-    // Add [entity:path] tokens if they do not already exist.
-    if (!isset($info['tokens'][$token_type]['path']) && (!empty($entity_info['uri callback']) || !empty($entity_info['bundles'][$entity]['uri callback']))) {
-      $info['tokens'][$token_type]['path'] = array(
-        'name' => t('Path'),
-        'description' => t('The URL alias of the @entity.', array('@entity' => drupal_strtolower($entity_info['label']))),
+    // Add [entity:url] tokens if they do not already exist.
+    // @todo Support entity:label
+    if (!isset($info['tokens'][$token_type]['url']) && (!empty($entity_info['uri callback']) || !empty($entity_info['bundles'][$entity]['uri callback']))) {
+      $info['tokens'][$token_type]['url'] = array(
+        'name' => t('URL'),
+        'description' => t('The URL of the @entity.', array('@entity' => drupal_strtolower($entity_info['label']))),
         'module' => 'token',
+        'type' => 'url',
       );
     }
   }
+
+  $info['tokens']['comment']['url']['type'] = 'url';
+  $info['tokens']['file']['url']['type'] = 'url';
+  $info['tokens']['node']['url']['type'] = 'url';
+  $info['tokens']['term']['url']['type'] = 'url';
+  $info['tokens']['user']['url']['type'] = 'url';
+}
+
+function _token_module($type, $name) {
+  $token_info = token_get_info($type, $name);
+  return isset($token_info['module']) ? $token_info['module'] : NULL;
 }
 
 /**
@@ -156,10 +169,6 @@ function token_token_info() {
     'name' => t('Title'),
     'description' => t('The title of the menu link.'),
   );
-  $info['tokens']['menu-link']['path'] = array(
-    'name' => t('Path'),
-    'description' => t('The URL alias of the menu link.'),
-  );
   $info['tokens']['menu-link']['url'] = array(
     'name' => t('URL'),
     'description' => t('The URL of the menu link.'),
@@ -184,13 +193,10 @@ function token_token_info() {
     'name' => t('Title'),
     'description' => t('The title of the current page.'),
   );
-  $info['tokens']['current-page']['path'] = array(
-    'name' => t('Path'),
-    'description' => t('The URL alias of the current page.'),
-  );
   $info['tokens']['current-page']['url'] = array(
     'name' => t('URL'),
     'description' => t('The URL of the current page.'),
+    'type' => 'url',
   );
   $info['tokens']['current-page']['page-number'] = array(
     'name' => t('Page number'),
@@ -202,6 +208,28 @@ function token_token_info() {
     'dynamic' => TRUE,
   );
 
+  $info['types']['url'] = array(
+    'name' => t('URL'),
+    'description' => t('Tokens related to URLs.'),
+    'needs-data' => 'url',
+  );
+  $info['tokens']['url']['path'] = array(
+    'name' => t('Internal path'),
+    'description' => t('The internal Drupal path of the URL.'),
+  );
+  $info['tokens']['url']['alias'] = array(
+    'name' => t('Alias'),
+    'description' => t('The alias of the URL.'),
+  );
+  $info['tokens']['url']['relative'] = array(
+    'name' => t('Relative URL'),
+    'description' => t('The relative URL.'),
+  );
+  $info['tokens']['url']['absolute'] = array(
+    'name' => t('Absolute URL'),
+    'description' => t('The absolute URL.'),
+  );
+
   return $info;
 }
 
@@ -257,6 +285,9 @@ function token_tokens($type, $tokens, ar
     if (($node_type_tokens = token_find_with_prefix($tokens, 'content-type')) && $node_type = node_type_load($node->type)) {
       $replacements += token_generate('content-type', $node_type_tokens, array('node_type' => $node_type), $options);
     }
+    if (($url_tokens = token_find_with_prefix($tokens, 'url'))) {
+      $replacements += token_generate('url', $url_tokens, entity_uri('node', $node), $options);
+    }
   }
 
   // Content type tokens.
@@ -384,10 +415,6 @@ function token_tokens($type, $tokens, ar
         case 'title':
           $replacements[$original] = $sanitize ? check_plain($link['title']) : $link['title'];
           break;
-        case 'path':
-          $alias = drupal_get_path_alias($link['href'], $language_code);
-          $replacements[$original] = $sanitize ? check_plain($alias) : $alias;
-          break;
         case 'url':
           $replacements[$original] = url($link['href'], $url_options);
           break;
@@ -411,6 +438,9 @@ function token_tokens($type, $tokens, ar
     if (!empty($link['p1']) && $link['p1'] != $link['mlid'] && ($root_tokens = token_find_with_prefix($tokens, 'root')) && $root = token_menu_link_load($link['p1'])) {
       $replacements += token_generate('menu-link', $root_tokens, array('menu-link' => $root), $options);
     }
+    if ($url_tokens = token_find_with_prefix($tokens, 'url')) {
+      $replacements += token_generate('url', $url_tokens, array('path' => $link['href']), $options);
+    }
   }
 
   // Current page tokens.
@@ -422,10 +452,6 @@ function token_tokens($type, $tokens, ar
         case 'title':
           $replacements[$original] = drupal_get_title();
           break;
-        case 'path':
-          $alias = drupal_get_path_alias($current_path, $language_code);
-          $replacements[$original] = $sanitize ? check_plain($alias) : $alias;
-          break;
         case 'url':
           $replacements[$original] = url($current_path, $url_options);
           break;
@@ -448,6 +474,35 @@ function token_tokens($type, $tokens, ar
         }
       }
     }
+
+    // Chained token relationships.
+    if ($url_tokens = token_find_with_prefix($tokens, 'url')) {
+      $replacements += token_generate('url', $url_tokens, array('path' => $current_path), $options);
+    }
+  }
+
+  // URL tokens.
+  if ($type == 'url' && !empty($data['path'])) {
+    $path = $data['path'];
+
+    foreach ($tokens as $name => $original) {
+      switch ($name) {
+        case 'path':
+          $replacements[$original] = $sanitize ? check_plain($path) : $path;
+          break;
+        case 'alias':
+          $alias = drupal_get_path_alias($path, $language_code);
+          $replacements[$original] = $sanitize ? check_plain($alias) : $alias;
+          break;
+        case 'absolute':
+          $replacements[$original] = url($path, $url_options);
+          break;
+        case 'relative':
+          unset($url_options['absolute']);
+          $replacements[$original] = url($path, $url_options);
+          break;
+      }
+    }
   }
 
   // Entity tokens.
@@ -462,22 +517,18 @@ function token_tokens($type, $tokens, ar
 
     foreach ($tokens as $name => $original) {
       switch ($name) {
-        // @todo Support entity:label
-        // @todo Support entity:url
-        case 'path':
-          $token_info = token_get_info($type, $name);
-          if (!isset($token_info['module']) || $token_info['module'] != 'token') {
-            // We must check that this token was added by token.module itself
-            // otherwise we may cause an array to be returned.
-            continue;
-          }
-          if ($uri = entity_uri($entity_type, $entity)) {
-            $alias = drupal_get_path_alias($uri['path'], $language_code);
-            $replacements[$original] = $sanitize ? check_plain($alias) : $alias;
+        case 'url':
+          if (_token_module($type, 'url') == 'token' && $uri = entity_uri($entity_type, $entity)) {
+            $replacements[$original] = url($uri['path'], $uri['options']);
           }
           break;
       }
     }
+
+    // Chained token relationships.
+    if (($url_tokens = token_find_with_prefix($tokens, 'url')) && _token_module($type, 'url') == 'token') {
+      $replacements += token_generate('url', $url_tokens, entity_uri($entity_type, $entity), $options);
+    }
   }
 
   // If $type is a token type, $data[$type] is empty but $data[$entity_type] is
