3 abstract class BulkLoader
extends ViewableData
{
5 * Override this on subclasses to give the specific functions names
10 * Return a human-readable name for this object.
11 * It defaults to the class name can be overridden by setting the static variable $title
14 if($title = $this->stat('title')) return $title;
15 else return $this->class;
19 * Process every record in the file
20 * @param filename The name of the CSV file to process
21 * @param preview If true, we'll just output a summary of changes but not actually do anything
23 * @returns A DataObjectSet containing a list of all the reuslst
25 function processAll($filename, $preview = false) {
27 // Get the first record out of the CSV and store it as headers
28 // Get each record out of the CSV
29 // Remap the record so that it's keyed by headers
30 // Pass it to $this->processRecord, and get the results
31 // Put the results inside an ArrayData and push that onto a DataObjectSet for returning
35 /*----------------------------------------------------------------------------------------
36 * Next, we have some abstract functions that let subclasses say what kind of batch operation they're
38 *----------------------------------------------------------------------------------------
43 * Return a FieldSet containing all the options for this form; this
44 * doesn't include the actual upload field itself
46 abstract function getOptionFields();
49 * Process a single record from the CSV file.
50 * @param record An map of the CSV data, keyed by the header field
53 * @returns A 2 value array.
54 * - The first element should be "add", "edit" or "", depending on the operation performed in response to this record
55 * - The second element is a free-text string that can optionally provide some more information about what changes have
58 abstract function processRecord($record, $preview = false);
60 /*----------------------------------------------------------------------------------------
61 * Next, we have a library of helper functions (Brian to build as necessary)
62 *----------------------------------------------------------------------------------------