Author: mcantelon
Date: Thu Jan  5 17:11:52 2012
New Revision: 10579

Log:
Added setting of currentColumn in import object so we can have generic field 
handlers that use name of column as data.

Modified:
   trunk/lib/QubitFlatfileImport.class.php
   trunk/lib/task/csvImportTask.class.php

Modified: trunk/lib/QubitFlatfileImport.class.php
==============================================================================
--- trunk/lib/QubitFlatfileImport.class.php     Thu Jan  5 16:55:01 2012        
(r10578)
+++ trunk/lib/QubitFlatfileImport.class.php     Thu Jan  5 17:11:52 2012        
(r10579)
@@ -208,6 +208,9 @@
     // process import columns that don't produce child data
     $this->forEachRowColumn($row, function(&$self, $index, $columnName, $value)
     {
+      // stash current column name so handlers can use it if need be
+      $self->status['currentColumn'] = $columnName;
+
       // if column maps to an attribute, set the attribute
       if (isset($self->columnMap) && isset($self->columnMap[$columnName]))
       {
@@ -253,6 +256,8 @@
   {
     $this->forEachRowColumn($row, function(&$self, $index, $columnName, $value)
     {
+      // stash current column name so handlers can use it if need be
+      $self->status['currentColumn'] = $columnName;
 
       // if column maps to a property, set the property
       if (isset($self->propertyMap) && isset($self->propertyMap[$columnName]) 
&& trim($value))

Modified: trunk/lib/task/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/csvImportTask.class.php      Thu Jan  5 16:55:01 2012        
(r10578)
+++ trunk/lib/task/csvImportTask.class.php      Thu Jan  5 17:11:52 2012        
(r10579)
@@ -359,7 +359,8 @@
                   'datesOfCreation'     => 'date'
                 )
                 as $statusVar => $eventProperty
-              ) {
+              )
+              {
                 $eventData[$eventProperty] = $self->rowStatusVars[$statusVar];
               }
 
@@ -404,6 +405,14 @@
       $self->informationObject->setLevelOfDescriptionByName($data);
     });
 
+    $relatedActorHandler = function(&$self, $data)
+    {
+      print 'Working with '. $self->status['currentColumn'] ."\n";
+    };
+
+    $import->addColumnHandler('relatedActorCommissionedBy', 
$relatedActorHandler);
+    $import->addColumnHandler('relatedActorPhotographer', 
$relatedActorHandler);
+
     $import->addColumnHandler('radGeneralMaterialDesignation', 
function(&$self, $data)
     {
       if ($data)

-- 
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