Author: mcantelon
Date: Tue Feb 21 11:19:20 2012
New Revision: 10953

Log:
Added helper function to QubitFlatfile for amalgamting multiple columns into 
one.

Modified:
   trunk/lib/QubitFlatfileImport.class.php

Modified: trunk/lib/QubitFlatfileImport.class.php
==============================================================================
--- trunk/lib/QubitFlatfileImport.class.php     Tue Feb 21 11:15:18 2012        
(r10952)
+++ trunk/lib/QubitFlatfileImport.class.php     Tue Feb 21 11:19:20 2012        
(r10953)
@@ -312,6 +312,43 @@
   }
 
   /**
+   * Combine column text, using optional pre-column prefixes
+   *
+   * @param array $prefixesAndColumns  array, optional keys specifying prefix
+   * @param string $destinationColumn  optional destination column for result
+   *
+   * @return string  combined column text
+   */
+  public function amalgamateColumns($prefixesAndColumns, $destinationColumn = 
FALSE)
+  {
+    $output = '';
+
+    foreach($prefixesAndColumns as $prefix => $column)
+    {
+      $columnValue = $this->columnValue($column);
+
+      if ($columnValue)
+      {
+        // numeric keys are considered prefixes
+        $prepend = (!is_numeric($prefix)) ? $prefix : '';
+
+        $output = $this->appendWithLineBreakIfNeeded(
+          $output,
+          $prepend . $columnValue
+        );
+      }
+    }
+
+    // optional direct setting of column
+    if ($destinationColumn)
+    {
+      $this->columnValue($destinationColumn, $output);
+    }
+
+    return $output;
+  }
+
+  /**
    * Convert human readable (e.g. 'This string') strings to camelCase
    * representation (e.g. 'thisString')
    *

-- 
You received this message because you are subscribed to the Google Groups 
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/qubit-commits?hl=en.

Reply via email to