Use simply 'group' instead of 'security group' for consistency in alert about no...
[silverstripe-elijah.git] / code / BulkLoader.php
blobf90e359cc5e5e2578264623c4f53e59cd7e8f34d
1 <?php
3 abstract class BulkLoader extends ViewableData {
4 /**
5 * Override this on subclasses to give the specific functions names
6 */
7 static $title = null;
9 /**
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
13 function Title() {
14 if($title = $this->stat('title')) return $title;
15 else return $this->class;
18 /**
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) {
26 // TODO
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
37 * going to do
38 *----------------------------------------------------------------------------------------
42 /**
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();
48 /**
49 * Process a single record from the CSV file.
50 * @param record An map of the CSV data, keyed by the header field
51 * @param preview
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
56 * been made
58 abstract function processRecord($record, $preview = false);
60 /*----------------------------------------------------------------------------------------
61 * Next, we have a library of helper functions (Brian to build as necessary)
62 *----------------------------------------------------------------------------------------