--- includes/views_customfield_handler_field_phpcode.inc.unpatched	2010-11-12 15:13:06.000000000 +0000
+++ includes/views_customfield_handler_field_phpcode.inc	2010-11-15 14:22:42.000000000 +0000
@@ -27,6 +27,7 @@ class views_customfield_handler_field_ph
     $options = parent::option_definition();
     $options['value'] = array('default' => '');
     $options['sortable'] = array('default' => VIEWS_CUSTOMFIELD_SORTABLE_NO);
+    $options['alter_value'] = array('default' => FALSE);
     return $options;
   }
 
@@ -62,6 +63,22 @@ class views_customfield_handler_field_ph
         VIEWS_CUSTOMFIELD_SORTABLE_NAT_NOCASE => t('Natural (case-insensitive)'),
       ),
     );
+    $form['alter_value'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Use replacement patterns'),
+      '#default_value' => $this->options['alter_value'],
+      '#description' => t('Check this to use replacement patterns in the value field, like in <em>Rewrite the output of this field</em>'),
+    );
+    $form['alter']['help']['#dependency']['edit-options-alter-value'] = array(1);
+    $form['alter_value_help'] = array(
+      '#type' => 'hidden',
+      '#id' => 'views-tokens-help-alter-value',
+      '#prefix' => '<div><fieldset id="views-tokens-help-alter-value"><legend>' . t('Replacement patterns') . '</legend>' . t('See above for specific values.') . '</fieldset></div>',
+      '#process' => array('views_process_dependency'),
+      '#dependency' => array(
+        'edit-options-alter-value' => array(1),
+      ),
+    );
   }
 
   function click_sortable() {
@@ -130,7 +147,19 @@ class views_customfield_handler_field_ph
   }
 
   function render($values) {
-    return $values->{$this->field_alias};
+    if ($this->options['alter_value']) {
+      $alter = array(
+        'alter_text' => $this->options['alter_value'],
+        'text' => $this->render_phpcode($this->options['value'], $this->static, $values),
+      );
+      $tokens = $this->get_render_tokens($alter);
+      $value = $this->render_altered($alter, $tokens);
+    }
+
+    if (isset($value))
+      return $value;
+    else
+      return $values->{$this->field_alias};
   }
 
   /**
@@ -142,6 +171,7 @@ class views_customfield_handler_field_ph
   function render_row($values) {
     $d = $this->view->display[$this->view->current_display];
     $field_handlers = $d->handler->handlers['field'];
+	
     foreach ($field_handlers as $h) {
       // Handle grouped fields
       if (is_a($h, 'content_handler_field_multiple') && $h->defer_query) {
@@ -158,7 +188,7 @@ class views_customfield_handler_field_ph
         $values->{$h->table.'_'.$h->field} = $tmp;
       }
     }
-    
+
     return $this->render_phpcode($this->options['value'], $this->static, $values);
   }
 
