Index: operations.file.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/transformations/transformations/operations.file.inc,v
retrieving revision 1.5
diff -u -r1.5 operations.file.inc
--- operations.file.inc	23 Jun 2009 19:15:19 -0000	1.5
+++ operations.file.inc	7 Jul 2009 13:15:36 -0000
@@ -282,3 +282,85 @@
     return 'line';
   }
 }
+
+/**
+ * Implementation of [module]_operation_[class]().
+ */
+function transformations_operation_TfFileSaveFromWholeString() {
+  return array(
+    'category' => t('Files and directories'),
+    'label' => t('Save string to file'),
+    'description' => t('This operation saves a string to a file'),
+  );
+}
+
+
+/**
+ * Implementation of [module]_operation_[class]().
+ */
+class TfFileSaveFromWholeString extends TfOperation {
+  /**
+   * Implementation of TfOperation::inputs().
+   */
+  protected function inputs() {
+    return array('contents', 'filepath');
+  }
+
+  /**
+   * Implementation of TfOperation::inputInfo().
+   */
+  protected function inputInfo($inputKey, $propertyKey) {
+    if ($inputKey == 'contents') {
+      switch ($propertyKey) {
+        case 'label':
+          return t('Text contents');
+
+        case 'description':
+          return t('The whole text contents that has been fetched from the file.');
+
+        case 'expectedType':
+          return 'php:type:string';
+      }
+    }
+    if ($inputKey == 'filepath') {
+      switch ($propertyKey) {
+        case 'label':
+          return t('File path');
+
+        case 'description':
+          return t('The path in the local file system where the file is located.');
+
+        case 'expectedType':
+          return 'php:type:string';
+      }
+    }
+  }
+
+  /**
+   * Implementation of TfOperation::outputs().
+   */
+  protected function outputs() {
+    return array();
+  }
+
+  /**
+   * Implementation of TfOperation::outputInfo().
+   */
+  protected function outputInfo($outputKey, $propertyKey) {}
+
+  /**
+   * Implementation of TfOperation::execute().
+   */
+  protected function execute(TfOutput $output) {
+    $string = $this->input('string')->data();
+    $filename = trim($this->input('filepath')->data());
+    $file = fopen($filename,'x');
+    if ($file) {
+      fwrite($file, $string);
+      fclose($file);
+    }
+    else {
+      $output->errorMessage("Couldn't save a file " . $filename);
+    }
+  }
+}
Index: transformations.transformations.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/transformations/transformations/transformations.transformations.inc,v
retrieving revision 1.6
diff -u -r1.6 transformations.transformations.inc
--- transformations.transformations.inc	23 Jun 2009 19:21:34 -0000	1.6
+++ transformations.transformations.inc	7 Jul 2009 13:15:36 -0000
@@ -52,6 +52,9 @@
   $operations['TfTextLinesFromFile'] = array(
     'file' => 'operations.file.inc',
   );
+  $operations['TfFileSaveFromWholeString'] = array(
+    'file' => 'operations.file.inc',
+  );
   $operations['TfPHPEvaluate'] = array(
     'file' => 'operations.eval.inc',
   );
@@ -78,6 +81,9 @@
     'parent' => 'TfDumpData',
     'file' => 'operations.debug.inc',
   );
+  $operations['TfStringReplace'] = array(
+    'file' => 'operations.strings.inc',
+  );
 
   return $operations;
 }
Index: operations.strings.inc
===================================================================
RCS file: operations.strings.inc
diff -N operations.strings.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ operations.strings.inc	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,136 @@
+<?php
+// $Id: operations.file.inc,v 1.5 2009/06/23 19:15:19 jpetso Exp $
+
+/**
+ * Implementation of [module]_operation_[class]().
+ */
+function transformations_operation_TfStringReplace() {
+  return array(
+    'category' => t('Strings'),
+    'label' => t('String Replacement'),
+    'description' => t('Replaces one String by another just likes php str_place function.'),
+  );
+}
+
+
+/**
+ * Implementation of [module]_operation_[class]().
+ */
+class TfStringReplace extends TfOperation {
+  private $tokens;
+
+  /**
+   * Implementation of TfOperation::inputs().
+   */
+  public function initialize() {
+    $this->tokens = array();
+    parent::initialize();
+  }
+
+  public function initializeReplacements() {
+    $this->tokens = array();
+
+    if (!$this->isInputSet('tokenlist')) {
+      return;
+    }
+    foreach ($this->input('tokenlist') as $sourceKey => $outputName) {
+      $this->tokens[$sourceKey] = $outputName;
+    }
+  }
+
+  /**
+   * Overriding TfOperation::inputChanged().
+   */
+  protected function inputChanged($inputKey, $previousValue) {
+    parent::inputChanged($inputKey, $previousValue);
+
+    if ($inputKey == 'tokenlist') {
+      $this->initializeReplacements();
+      $this->updateInputSchema();
+    }
+  }
+
+  /**
+   * Implementation of TfOperation::inputs().
+   */
+  protected function inputs() {
+    $inputs = array('subject', 'tokenlist');
+
+    foreach ($this->tokens as $key => $value) {
+      $inputs[] = 't:' . $key;
+    }
+    return $inputs;
+  }
+
+  /**
+   * Implementation of TfOperation::inputInfo().
+   */
+  protected function inputInfo($inputKey, $propertyKey) {
+    if ($inputKey == 'subject') {
+      switch ($propertyKey) {
+        case 'label':
+          return t('Subject');
+
+        case 'expectedType':
+          return 'php:type:string';
+      }
+    }
+    elseif ($inputKey == 'tokenlist') {
+      switch ($propertyKey) {
+        case 'label':
+          return t('Tokenlist');
+          
+        case 'expectedType':
+          return 'transformations:list<php:type:string>';
+      }
+    }
+    else {
+      $token = substr($inputKey, 2);
+
+      switch ($propertyKey) {
+        case 'label':
+          return empty($this->tokens[$token])
+            ? t('(empty)')
+            : $this->tokens[$token];
+
+        case 'expectedType':
+          return 'php:type:string';
+      }
+    }
+  }
+
+  /**
+   * Implementation of TfOperation::outputs().
+   */
+  protected function outputs() {
+    return array('replacedSubject');
+  }
+
+  /**
+   * Implementation of TfOperation::outputInfo().
+   */
+  protected function outputInfo($outputKey, $propertyKey) {
+    if ($outputKey == 'replacedSubject') {
+      switch ($propertyKey) {
+        case 'label':
+          return t('Subject');
+
+        case 'expectedType':
+          return 'php:type:string';
+      }
+    }
+  }
+
+  /**
+   * Implementation of TfOperation::execute().
+   */
+  protected function execute(TfOutput $output) {
+    $subject  = $this->input('subject')->data();
+    $replacements = array();
+
+    foreach ($this->tokens as $key => $value) {
+      $replacements[$value] = $this->input('t:' . $key)->data();
+    }
+    $output->set('replacedSubject', strtr($subject, $replacements));
+  }
+}
