diff --git a/_config.php b/_config.php index a918dae4..334c26d7 100644 --- a/_config.php +++ b/_config.php @@ -14,7 +14,6 @@ Director::addRules(50, array( 'admin/assets/$Action/$ID' => 'AssetAdmin', 'admin/comments/$Action' => 'CommentAdmin', 'admin/ReportField/$Action/$ID/$Type/$OtherID' => 'ReportField_Controller', - 'admin/bulkload/$Action/$ID/$OtherID' => 'BulkLoaderAdmin', 'admin/ImageEditor/$Action' => 'ImageEditor', 'admin/$Action/$ID/$OtherID' => 'CMSMain', 'unsubscribe/$Email/$MailingList' => 'Unsubscribe_Controller', diff --git a/code/BulkLoader.php b/code/BulkLoader.php deleted file mode 100755 index 9da995a4..00000000 --- a/code/BulkLoader.php +++ /dev/null @@ -1,78 +0,0 @@ -stat('title')) return $title; - else return $this->class; - } - - /** - * Process every record in the file - * @param filename The name of the CSV file to process - * @param preview If true, we'll just output a summary of changes but not actually do anything - * - * @returns A DataObjectSet containing a list of all the reuslst - */ - function processAll($filename, $preview = false) { - // TODO - // Get the first record out of the CSV and store it as headers - // Get each record out of the CSV - // Remap the record so that it's keyed by headers - // Pass it to $this->processRecord, and get the results - // Put the results inside an ArrayData and push that onto a DataObjectSet for returning - } - - - /*---------------------------------------------------------------------------------------- - * Next, we have some abstract functions that let subclasses say what kind of batch operation they're - * going to do - *---------------------------------------------------------------------------------------- - */ - - - /** - * Return a FieldSet containing all the options for this form; this - * doesn't include the actual upload field itself - */ - abstract function getOptionFields(); - - /** - * Process a single record from the CSV file. - * @param record An map of the CSV data, keyed by the header field - * @param preview - * - * @returns A 2 value array. - * - The first element should be "add", "edit" or "", depending on the operation performed in response to this record - * - The second element is a free-text string that can optionally provide some more information about what changes have - * been made - */ - abstract function processRecord($record, $preview = false); - - /*---------------------------------------------------------------------------------------- - * Next, we have a library of helper functions (Brian to build as necessary) - *---------------------------------------------------------------------------------------- - */ - -} - -?> \ No newline at end of file diff --git a/code/BulkLoaderAdmin.php b/code/BulkLoaderAdmin.php deleted file mode 100755 index bfd8f5e5..00000000 --- a/code/BulkLoaderAdmin.php +++ /dev/null @@ -1,135 +0,0 @@ - 'ADMIN', - 'process' => 'ADMIN', - ); - - /** - * Initialisation method called before accessing any functionality that BulkLoaderAdmin has to offer - */ - public function init() { - Requirements::javascript('cms/javascript/BulkLoaderAdmin.js'); - - parent::init(); - } - - /** - * Link function to tell us how to get back to this controller. - */ - public function Link($action = null) { - return "admin/bulkload/$action"; - } - - public function BulkLoaders() { - $items = ClassInfo::subclassesFor("BulkLoader"); - array_shift($items); - - foreach($items as $item) { - $itemObjects[] = new $item(); - } - - return new DataObjectSet($itemObjects); - } - - /** - * Return the form shown when we first click on a loader on the left. - * Provides all the options, a file upload, and an option to proceed - */ - public function getEditForm($className = null) { - if(is_subclass_of($className, 'BulkLoader')) { - $loader = new $className(); - - $fields = $loader->getOptionFields(); - if(!$fields) $fields = new FieldSet(); - - $fields->push(new FileField("File", _t('BulkLoaderAdmin.CSVFILE','CSV File'))); - $fields->push(new HiddenField('LoaderClass', '', $loader->class)); - - return new Form($this, "EditForm", - $fields, - new FieldSet( - new FormAction('preview', _t('BulkLoaderAdmin.PREVIEW',"Preview")) - ) - ); - - } - } - - public function preview() { - $className = $_REQUEST['LoaderClass']; - if(is_subclass_of($className, 'BulkLoader')) { - $loader = new $className(); - - $results = $loader->processAll($_FILES['File']['tmp_name'], false); - - return $this->customise(array( - "Message" => _t('BulkLoaderAdmin.PRESSCNT','Press continue to load this data in'), - "Results" => $results, - "ConfirmForm" => $this->getConfirmFormFor($loader, $file), - ))->renderWith("BulkLoaderAdmin_preview"); - } - } - - /** - * Generate a confirmation form for the given file/class - * Will copy the file to a suitable temporary location - * @param loader A BulkLoader object - * @param file The name of the temp file - */ - public function getConfirmFormFor($loader, $file) { - $tmpFile = tempnam(TEMP_FOLDER,'batch-upload-'); - copy($file,$tmpFile); - - return new Form($this, "ConfirmForm", new FieldSet( - new HiddenField("File", "", $tmpFile), - new HiddenField("LoaderClass", "", $loader->class) - ), new FieldSet( - new FormAction('process', _t('BulkLoaderAdmin.CONFIRMBULK','Confirm bulk load')) - )); - } - /** - * Stub to return the form back after pressing the button. - */ - public function ConfirmForm() { - $className = $_REQUEST['LoaderClass']; - return $this->getConfirmFormFor(new $className(), $_REQUEST['File']); - } - - /** - * Process the data and display the final "finished" message - */ - public function process() { - $className = $_REQUEST['LoaderClass']; - if(is_subclass_of($className, 'BulkLoader')) { - $loader = new $className(); - - $results = $loader->processAll($_REQUEST['Filename'], true); - - return $this->customise(array( - "Message" => _t('BulkLoaderAdmin.DATALOADED', 'This data has been loaded in'), - "Results" => $results, - "ConfirmForm" => " ", - ))->renderWith("BulkLoaderAdmin_preview"); - } - } - -} - -?> diff --git a/javascript/BulkLoaderAdmin.js b/javascript/BulkLoaderAdmin.js deleted file mode 100755 index c8e75178..00000000 --- a/javascript/BulkLoaderAdmin.js +++ /dev/null @@ -1,15 +0,0 @@ -/** - * Configuration for the left hand tree - */ -if(typeof SiteTreeHandlers == 'undefined') SiteTreeHandlers = {}; -SiteTreeHandlers.loadPage_url = 'admin/bulkload/getitem'; -SiteTreeHandlers.showRecord_url = 'admin/bulkload/show/';; - -Behaviour.register({ - '#Form_EditForm' : { - getPageFromServer: function (className) { - $('BulkLoaderIframe').src = 'admin/bulkload/iframe/' + className; - } - } - -}); \ No newline at end of file diff --git a/templates/BulkLoaderAdmin_iframe.ss b/templates/BulkLoaderAdmin_iframe.ss deleted file mode 100755 index 40443e04..00000000 --- a/templates/BulkLoaderAdmin_iframe.ss +++ /dev/null @@ -1 +0,0 @@ -$EditForm \ No newline at end of file diff --git a/templates/BulkLoaderAdmin_preview.ss b/templates/BulkLoaderAdmin_preview.ss deleted file mode 100755 index 45c5a5f5..00000000 --- a/templates/BulkLoaderAdmin_preview.ss +++ /dev/null @@ -1,10 +0,0 @@ -

$Message - -<% _t('RES','Results') %> - - -<% control Results %> -list changes here -<% end_control %> - -$ConfirmForm \ No newline at end of file diff --git a/templates/Includes/BulkLoaderAdmin_left.ss b/templates/Includes/BulkLoaderAdmin_left.ss deleted file mode 100755 index 84c5b27f..00000000 --- a/templates/Includes/BulkLoaderAdmin_left.ss +++ /dev/null @@ -1,20 +0,0 @@ -

<% _t('FUNCTIONS','Functions') %>
- -
-
- <% if BulkLoaders %> - - <% end_if %> -
-
diff --git a/templates/Includes/BulkLoaderAdmin_right.ss b/templates/Includes/BulkLoaderAdmin_right.ss deleted file mode 100755 index fc927115..00000000 --- a/templates/Includes/BulkLoaderAdmin_right.ss +++ /dev/null @@ -1,5 +0,0 @@ -
- -
- -