--- workflow_ng_node.inc.orig	2008-01-10 21:57:43.000000000 +0200
+++ workflow_ng_node.inc	2008-01-10 23:18:03.000000000 +0200
@@ -51,7 +51,11 @@ function node_event_info() {
       '#label' => t('Content is going to be viewed'),
       '#module' => t('Node'),
       '#description' => t('Note that if drupal\'s page cache is enabled, this event won\'t be generated for pages served from cache.'),
-      '#arguments' => workflow_ng_events_node_arguments(t('viewed content'), t('content author')),
+      '#arguments' => array(      
+        'node' => array('#entity' => 'node', '#label' => t('viewed content')),
+        'node_rendered' => array('#entity' => 'rendered_node', '#label' => t('rendered content')),
+        'author' => array('#entity' => 'user', '#label' => t('content author'), '#handler' => 'workflow_ng_events_argument_node_author'),
+      ) + workflow_ng_events_global_user_argument(),
     ),
     'node_delete' => array(
       '#label' => t('Content has been deleted'),
@@ -77,10 +81,26 @@ function workflow_ng_events_node_argumen
  */
 function workflow_ng_nodeapi(&$node, $op, $teaser = NULL, $page = NULL) {
 
-  if (in_array($op, array('view', 'insert', 'update', 'submit', 'delete'))) {
+  if (in_array($op, array('insert', 'update', 'submit', 'delete'))) {
     //we pass the node by reference so that changes are saved automatically on op submit
     workflow_ng_invoke_event('node_'. $op, array('node' => &$node));
   }
+  if ($op == 'view') {
+
+    // At this stage $node is tainted; it's somewhat ruined by node_build_content()
+    // et al. So, for the benefit of later actions which will want to act upon it,
+    // we're loading a fresh node.
+    $node_pristine = node_load($node->nid);
+
+    // Nevertheless, $node isn't useless. It's a 'rendered_node' entity which
+    // certain conditions and actions know to work with. Here we're recording
+    // some flags that tell us more about the nature of the rendition:
+    $node->_wfng_teaser = $teaser;
+    $node->_wfng_page   = $page;
+
+    // Note that we pass the rendered node by reference so actions could change the rendition.
+    workflow_ng_invoke_event('node_view', array('node' => $node_pristine, 'node_rendered' => &$node));
+  }
 }
 
 /**
@@ -121,6 +141,14 @@ function node_condition_info() {
       '#description' => t('Evaluates to TRUE, if the given content has one of the selected content types.'),
       '#module' => t('Node'),
     ),
+    'workflow_ng_condition_content_rendition' => array(
+      '#label' => t('Content is rendered in a certain manner'),
+      '#arguments' => array(
+        'node_rendered' => array('#entity' => 'rendered_node', '#label' => t('Rendered content')),
+      ),
+      '#description' => t('Evaluates to TRUE, if the given content is rendered in a certain manner.'),
+      '#module' => t('Node'),
+    ),
   );
 }
 
@@ -132,6 +160,18 @@ function workflow_ng_condition_content_i
 }
 
 /**
+ * Condition: Check for the way a node is rendered
+ */
+function workflow_ng_condition_content_rendition($node_rendered, $settings) {
+  if ((bool)$settings['page']   == (bool)$node_rendered->_wfng_page &&
+      (bool)$settings['teaser'] == (bool)$node_rendered->_wfng_teaser) {
+    return TRUE;
+  } 
+  return FALSE;
+}
+
+
+/**
  * Implementation of hook_action_info()
  */
 function node_action_info() {
@@ -172,6 +212,13 @@ function node_action_info() {
       ),
       '#module' => t('Node'),
     ),     
+    'workflow_ng_action_set_rendition' => array(
+     '#label' => t('Overwrite rendition of content with typed-in HTML'),
+     '#arguments' => array(
+       'node_rendered' => array('#entity' => 'rendered_node', '#label' => t('Rendered content')),
+      ),
+      '#module' => t('Node'),
+    ),     
   );
 }
 
@@ -236,3 +283,21 @@ function workflow_ng_action_load_node($s
 
   return array('#new arguments' => array('node_loaded' => node_load($nid, $vid ? $vid : NULL)));
 }
+
+/**
+ * Overwrites rendition of a node with typed-in HTML
+ *
+ * (Note that the node object is passed by reference; that's the same object
+ *  handed to us in workflow_ng_nodeapi(). The reference is actually only needed
+ *  for PHP4 compatibility because in PHP5 all objects are passed by reference.)
+ */
+function workflow_ng_action_set_rendition(&$node_rendered, $settings, &$arguments, &$log) {
+  extract( workflow_ng_token_replace_all(array('html'), $settings, $arguments, $log) );
+  // obliterate the old content:
+  $node_rendered->content = array();
+  // install our own:
+  $node_rendered->content['message'] = array(
+    '#value' => $html,
+  );
+}
+
--- workflow_ng_node_forms.inc.orig	2008-01-10 22:03:48.000000000 +0200
+++ workflow_ng_node_forms.inc	2008-01-10 23:17:39.000000000 +0200
@@ -24,6 +24,31 @@ function workflow_ng_condition_content_i
 }
 
 /*
+ *  Check for the way a node is rendered - Configuration form
+ */
+function workflow_ng_condition_content_rendition_form($settings = array()) {
+  // TODO:
+  // In Drupal 6 we will be able to know more about how a node is
+  // rendered, thank to $node->build_mode. But for now we'll have to
+  // do with the following two flags.
+  $form['page'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Node is rendered stand-alone on a page'),
+    '#default_value' => $settings['page'],
+  );
+  $form['teaser'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Node is rendered in its trimmed version'),
+    '#default_value' => $settings['teaser'],
+  );
+  return $form;
+}
+
+function workflow_ng_condition_content_rendition_submit($form_id, $form_values) {
+  return array('page' => $form_values['page'], 'teaser' => $form_values['teaser']);
+}
+
+/*
  * Action node publish configuration form
  */
 function workflow_ng_action_node_publish_form($settings = array(), $argument_info) {
@@ -120,3 +145,22 @@ function workflow_ng_action_load_node_su
   //returns the needed settings
   return workflow_ng_token_get_settings(array('nid', 'vid'), $form_values);
 }
+
+/*
+ * Action "Overwrite rendition of content with typed-in HTML," configuration form
+ */
+function workflow_ng_action_set_rendition_form($settings, $argument_info) {
+  $form['html'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Html'),
+    '#default_value' => $settings['html'],
+    '#description' => t('New HTML that will be shown instead of the normal node body.'),
+  );
+  workflow_ng_token_replacement_help($form, $argument_info);
+  return $form;
+}
+
+function workflow_ng_action_set_rendition_submit($form_id, $form_values) {
+  return workflow_ng_token_get_settings(array('html'), $form_values);
+}
+
