diff --git a/code/StaticSitePageTransformer.php b/code/StaticSitePageTransformer.php index 6979f36..efc39bc 100644 --- a/code/StaticSitePageTransformer.php +++ b/code/StaticSitePageTransformer.php @@ -3,6 +3,11 @@ class StaticSitePageTransformer implements ExternalContentTransformer { public function transform($item, $parentObject, $duplicateStrategy) { + if(Director::is_cli()) { + Debug::message("Parent: #$parentObject->ID, $parentObject->Title"); + Debug::message($item->AbsoluteURL); + } + // Sleep for 100ms to reduce load on the remote server usleep(100*1000); @@ -55,6 +60,11 @@ public function transform($item, $parentObject, $duplicateStrategy) { $page->write(); + if(Director::is_cli()) { + Debug::message("#$page->Title"); + Debug::message("#$page->ID child of #$page->ID"); + } + return new TransformResult($page, $item->stageChildren()); } diff --git a/code/tasks/ExternalContentImportContentTask.php b/code/tasks/ExternalContentImportContentTask.php new file mode 100644 index 0000000..3987544 --- /dev/null +++ b/code/tasks/ExternalContentImportContentTask.php @@ -0,0 +1,37 @@ +getVar('ID'); + if((!is_numeric($id) && !preg_match('/^[0-9]+_[0-9]+$/', $id)) || !$id) { + echo "

Specify ?ID=(number) or ?ID=(ID)_(Code)

\n"; + return; + } + + $includeSelected = false; + $includeChildren = true; + $duplicates = 'Duplicate'; + $selected = $id; + + $target = new Page; + $target->Title = "Import on " . date('Y-m-d H:i:s'); + $target->write(); + $targetType = 'SiteTree'; + + $from = ExternalContent::getDataObjectFor($selected); + if ($from instanceof ExternalContentSource) { + $selected = false; + } + + $importer = null; + $importer = $from->getContentImporter($targetType); + + if ($importer) { + $importer->import($from, $target, $includeSelected, $includeChildren, $duplicates); + } + } +}