cvs diff: Diffing .
? .buildpath
? .project
? bin
Index: skeleton_instance.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/skeleton/skeleton_instance.inc,v
retrieving revision 1.21
diff -u -p -r1.21 skeleton_instance.inc
--- skeleton_instance.inc	16 Jul 2009 18:09:19 -0000	1.21
+++ skeleton_instance.inc	10 Aug 2009 03:31:15 -0000
@@ -714,14 +714,11 @@ function skeleton_create_instance_form_s
       // Replace custom tokens in the title and body fields. Replace skeleton
       // tokens first so they may be used as node tokens such as [title].
       if (!empty($form_state['values']['skeleton_tokens'])) {
-        $node['values']['title'] = token_replace($node['values']['title'], 'skeleton', $form_state['values']['skeleton_tokens']);
-        $node['values']['body'] = token_replace($node['values']['body'], 'skeleton', $form_state['values']['skeleton_tokens']);
+        $node['values'] = (array)_skeleton_token_replace_values((object)$node['values'], 'skeleton', $form_state['values']['skeleton_tokens']);
       }
 
-      $node['values']['title'] = token_replace($node['values']['title'], 'node', (object)$node['values']);
+      $node['values'] = (array)_skeleton_token_replace_values((object)$node['values'], 'node', (object)$node['values']);
       $form_state['values']['title'] = $node['values']['title'];
-
-      $node['values']['body'] = token_replace($node['values']['body'], 'node', (object)$node['values']);
       $form_state['values']['body'] = $node['values']['body'];
 
       $node['values']['tokens'] = $form_state['values']['skeleton_tokens'];
@@ -793,24 +790,13 @@ function skeleton_create_instance_form_s
       $node['values']['book']['weight'] = $data->weight;
       $node['values']['book']['options'] = array();
 
-      // For subpages, we can simply simulate the [bookpathalias] token here.
-      // Otherwise, it will be replaced with '' during token_replace() as the
-      // node isn't saved yet.
-      if (module_exists('pathauto')) {
-        $book_root = node_load($book_id);
-        $node['values']['title'] = str_replace('[bookpathalias]', drupal_get_path_alias($book_root->path), $node['values']['title']);
-        $node['values']['body'] = str_replace('[bookpathalias]', drupal_get_path_alias($book_root->path), $node['values']['body']);
-      }
-
       // Replace custom tokens in the title and body fields. Replace skeleton
       // tokens first so they may be used as node tokens such as [title].
       if (!empty($form_state['values']['skeleton_tokens'])) {
-        $node['values']['title'] = token_replace($node['values']['title'], 'skeleton', $form_state['values']['skeleton_tokens']);
-        $node['values']['body'] = token_replace($node['values']['body'], 'skeleton', $form_state['values']['skeleton_tokens']);
+        $node['values'] = (array)_skeleton_token_replace_values((object)$node['values'], 'skeleton', $form_state['values']['skeleton_tokens']);
       }
 
-      $node['values']['title'] = token_replace($node['values']['title'], 'node', (object)$node['values']);
-      $node['values']['body'] = token_replace($node['values']['body'], 'node', (object)$node['values']);
+      $node['values'] = (array)_skeleton_token_replace_values((object)$node['values'], 'node', (object)$node['values'], TRUE);
 
       $node['values']['uid'] = $user->uid;
       $node['values']['name'] = $user->name;
Index: skeleton_sync.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/skeleton/skeleton_sync.inc,v
retrieving revision 1.2
diff -u -p -r1.2 skeleton_sync.inc
--- skeleton_sync.inc	16 Jul 2009 18:12:35 -0000	1.2
+++ skeleton_sync.inc	10 Aug 2009 03:31:15 -0000
@@ -1,5 +1,7 @@
 <?php
 
+// $Id$
+
 /**
  * Syncronize form. Contains lists of updated, added, and deleted templates.
  *
@@ -181,12 +183,10 @@ function skeleton_sync_add_template_form
           // Replace custom tokens in the title and body fields. Replace skeleton
           // tokens first so they may be used as node tokens such as [title].
           if (!empty($parent_info->tokens)) {
-            $node['values']['title'] = token_replace($node['values']['title'], 'skeleton', $parent_info->tokens);
-            $node['values']['body'] = token_replace($node['values']['body'], 'skeleton', $parent_info->tokens);
+            $node = _skeleton_token_replace_values($node, 'skeleton', $parent_info->tokens);
           }
-    
-          $node['values']['title'] = token_replace($node['values']['title'], 'node', (object)$node['values']);
-          $node['values']['body'] = token_replace($node['values']['body'], 'node', (object)$node['values']);
+
+          $node = _skeleton_token_replace_values($node, 'node', $node);
     
           $node['values']['uid'] = $parent_node->uid;
           $node['values']['name'] = $parent_node->name;
@@ -307,10 +307,8 @@ function skeleton_sync_update_node($nid,
     $node->$key = $value;
   }
   // Replace body and title tokens.
-  $node->title = token_replace($node->title, 'skeleton', $node->skeleton_template->tokens);
-  $node->body = token_replace($node->body, 'skeleton', $node->skeleton_template->tokens);
-  $node->title = token_replace($node->title, 'node', $node);
-  $node->body = token_replace($node->body, 'node', $node);
+  $node = _skeleton_token_replace_values($node, 'skeleton', $node->skeleton_template->tokens);
+  $node = _skeleton_token_replace_values($node, 'node', $node);
 
   // Add a flag so that we keep this node as "unmodified".
   $node->skeleton_template->keep_connected = TRUE;
Index: skeleton_token.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/skeleton/skeleton_token.inc,v
retrieving revision 1.1
diff -u -p -r1.1 skeleton_token.inc
--- skeleton_token.inc	7 Jan 2009 17:38:58 -0000	1.1
+++ skeleton_token.inc	10 Aug 2009 03:31:15 -0000
@@ -1,6 +1,6 @@
 <?php
 
-// $Id
+// $Id$
 
 /**
  * Form API callback for Tokens tab
@@ -210,8 +210,8 @@ function skeleton_token_values($type, $o
     foreach ($skeleton_tokens as $token => $value) {
       $tokens[$token] = $value;
     }
-    return $tokens;
   }
+  return $tokens;
 }
 
 /**
@@ -289,6 +289,50 @@ function _skeleton_build_other_token_hel
 }
 
 /**
+ * Replace tokens within the title, body, and an CCK text fields on a node.
+ *
+ * @param $node
+ *   The node object to act upon.
+ *
+ * @param $type
+ *   The token type to replace, corresponding to the types used with
+ *   token_replace().
+ *
+ * @param $tokens
+ *   The tokens to pass to token_replace().
+ *
+ * @param $fix_bookpathalias [optional]
+ *   If the node contains [bookpathalias] tokens, replace them manually so that
+ *   it can be used when the node hasn't been saved yet.
+ *
+ * @return
+ *   The node object with the tokenized title, body, and CCK text fields.
+ */
+function _skeleton_token_replace_values($node, $type, $tokens, $fix_bookpathalias = FALSE) {
+  // For subpages, we can simply simulate the [bookpathalias] token here.
+  // Otherwise, it will be replaced with '' during token_replace() as the
+  // node isn't saved yet.
+  if ($fix_bookpathalias && module_exists('pathauto')) {
+    $book_root = node_load($node->book['bid']);
+    $node->title = str_replace('[bookpathalias]', drupal_get_path_alias($book_root->path), $node->title);
+    $node->body = str_replace('[bookpathalias]', drupal_get_path_alias($book_root->path), $node->body);
+  }
+  $node->title = token_replace($node->title, $type, $tokens);
+  $node->body = token_replace($node->body, $type, $tokens);
+  // Also do any CCK text fields.
+  $content_type = content_types($node->type);
+  $fields = $content_type['fields'];
+  foreach ($fields as $field) {
+    if ($field['type'] == 'text') {
+      foreach (array_keys($node->{$field['field_name']}) as $delta) {
+        $node->{$field['field_name']}[$delta]['value'] = token_replace($node->{$field['field_name']}[$delta]['value'], $type, $tokens);
+      }
+    }
+  }
+  return $node;
+}
+
+/**
  * theme_skeleton_token_help()
  *
  * @param $tokens
