Author: mcantelon
Date: Thu Dec 29 14:12:50 2011
New Revision: 10471
Log:
Made a forEachRowColumn method to reduce redundancy in code.
Modified:
trunk/lib/task/csvImportTask.class.php
Modified: trunk/lib/task/csvImportTask.class.php
==============================================================================
--- trunk/lib/task/csvImportTask.class.php Thu Dec 29 13:57:10 2011
(r10470)
+++ trunk/lib/task/csvImportTask.class.php Thu Dec 29 14:12:50 2011
(r10471)
@@ -273,7 +273,8 @@
// determine what type of data should be in this column
$columnName = $this->columns[$index];
- $logic($index, $columnName);
+ // execute row logic
+ $logic(&$this, $index, $columnName, $row[$index]);
}
}
@@ -282,60 +283,48 @@
// execute row initialization logic
$this->executeClosurePropertyIfSet('rowInit');
- $this->forEachRowColumn($row, function($index, $columnName) {
-print 'C:'. $columnName;
- });
-exit();
- /*
- // process import columns, except those that produce child data
- for ($index = 0; $index < sizeof($row); $index++)
+ // process import columns that don't produce child data
+ $this->forEachRowColumn($row, function(&$self, $index, $columnName, $value)
{
-
- // determine what type of data should be in this column
- $columnName = $this->columns[$index];
-
// if column maps to an attribute, set the attribute
- if (isset($this->columnMap) && isset($this->columnMap[$columnName]))
+ if (isset($self->columnMap) && isset($self->columnMap[$columnName]))
{
- $this->informationObject->{$this->columnMap[$columnName]} =
$row[$index];
+ $self->informationObject->{$self->columnMap[$columnName]} = $value;
}
else if (
- isset($this->columns[$index])
- && isset($this->handlers[($this->columns[$index])])
+ isset($self->columns[$index])
+ && isset($self->handlers[($self->columns[$index])])
)
{
// otherwise, if column is data and a handler is set, use it
call_user_func_array(
- $this->handlers[$columnName],
- array(&$this, $row[$index])
+ $self->handlers[$columnName],
+ array(&$self, $value)
);
}
- }
- */
+ });
// execute row completion logic
$this->executeClosurePropertyIfSet('rowComplete');
// process import columns that produce child data
- for ($index = 0; $index < sizeof($row); $index++)
+ $this->forEachRowColumn($row, function(&$self, $index, $columnName, $value)
{
- // determine what type of data should be in this column
- $columnName = $this->columns[$index];
// if column maps to a property, set the property
- if (isset($this->propertyMap) && isset($this->propertyMap[$columnName]))
+ if (isset($self->propertyMap) && isset($self->propertyMap[$columnName]))
{
- $this->informationObject->addProperty(
- $this->propertyMap[$columnName],
- $row[$index]
+ $self->informationObject->addProperty(
+ $self->propertyMap[$columnName],
+ $value
);
}
- else if (isset($this->noteMap) && isset($this->noteMap[$columnName]))
+ else if (isset($self->noteMap) && isset($self->noteMap[$columnName]))
{
// otherwise, if maps to a note, create it
- $this->createNote($this->noteMap[$columnName], $row[$index]);
+ $self->createNote($self->noteMap[$columnName], $value);
}
- }
+ });
// increment number of completed rows
$this->status['rows']++;
--
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.