public function testLinkNormalizationYear() { $data = array(array('Foo', '/2014/foo'), array('Bar', '/2015/bar')); $batch = new \PortlandLabs\Concrete5\MigrationTool\Entity\Import\Batch(); $collection = new \PortlandLabs\Concrete5\MigrationTool\Entity\Import\PageObjectCollection(); foreach ($data as $r) { $page = new \PortlandLabs\Concrete5\MigrationTool\Entity\Import\Page(); $page->setName($r[0]); $page->setOriginalPath($r[1]); $collection->getPages()->add($page); $batch->getObjectCollections()->add($collection); } $this->assertEquals(2, $batch->getObjectCollections()->get(0)->getPages()->count()); $target = new \PortlandLabs\Concrete5\MigrationTool\Batch\Processor\Target($batch); $processor = new \Concrete\Core\Foundation\Processor\Processor($target); $processor->registerTask(new \PortlandLabs\Concrete5\MigrationTool\Batch\Processor\Task\NormalizePagePathsTask()); $processor->process(); $pages = $batch->getPages(); // The normalization saves a batch_patch without the common bit, in this case without the string '/20' of the original path $this->assertEquals('4/foo', $pages[0]->getBatchPath()); $this->assertEquals('5/bar', $pages[1]->getBatchPath()); }
protected function parsePage($node) { $sanitizer = new PagePathSanitizer(); $originalPath = $sanitizer->sanitize((string) $node['path']); $page = new \PortlandLabs\Concrete5\MigrationTool\Entity\Import\Page(); $page->setName((string) html_entity_decode($node['name'])); $page->setPublicDate((string) $node['public-date']); $page->setOriginalPath($originalPath); if (isset($node['package'])) { $page->setPackage((string) $node['package']); } $page->setTemplate((string) $node['template']); $page->setType((string) $node['pagetype']); $page->setUser((string) $node['user']); $page->setDescription((string) html_entity_decode($node['description'])); // Parse attributes if ($node->attributes->attributekey) { $i = 0; foreach ($node->attributes->attributekey as $keyNode) { $attribute = $this->parseAttribute($keyNode); $pageAttribute = new PageAttribute(); $pageAttribute->setAttribute($attribute); $pageAttribute->setPage($page); $page->attributes->add($pageAttribute); ++$i; } } // Parse areas if ($node->area) { foreach ($node->area as $areaNode) { $area = $this->parseArea($areaNode); $area->setPage($page); $page->areas->add($area); } } return $page; }
private function createParentPages() { $pages = array(); $parentPages = array('posts' => 'Posts', 'pages' => 'Pages'); foreach ($parentPages as $parentPagePath => $parentPageName) { $page = new \PortlandLabs\Concrete5\MigrationTool\Entity\Import\Page(); $page->setName('Wordpress ' . $parentPageName . ' (Auto-generated)'); $page->setDescription('Auto-generated parent page to hold Wordpress ' . $parentPageName); $page->setPublicDate(date('Y-m-d H:i:s')); $page->setType('page'); $page->setOriginalPath('/' . $parentPagePath); $page->setBatchPath('/' . $parentPagePath); $page->setTemplate('blank'); $page->setUser('admin'); $pages[] = $page; } return $pages; }