/
ImportPageFeedsRoutine.php
57 lines (54 loc) · 2.05 KB
/
ImportPageFeedsRoutine.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
namespace Concrete\Core\Backup\ContentImporter\Importer\Routine;
use Concrete\Core\Feature\Feature;
use Concrete\Core\Page\Feed;
use Concrete\Core\Permission\Category;
class ImportPageFeedsRoutine extends AbstractRoutine
{
public function getHandle()
{
return 'page_feeds';
}
public function import(\SimpleXMLElement $sx)
{
if (isset($sx->pagefeeds)) {
foreach ($sx->pagefeeds->feed as $f) {
$feed = Feed::getByHandle((string) $f->handle);
$inspector = \Core::make('import/value_inspector');
if (!is_object($feed)) {
$feed = new \Concrete\Core\Entity\Page\Feed();
}
if ($f->parent) {
$result = $inspector->inspect((string) $f->parent);
$parent = $result->getReplacedValue();
$feed->setParentID($parent);
}
$feed->setTitle((string) $f->title);
$feed->setDescription((string) $f->description);
$feed->setHandle((string) $f->handle);
if ($f->descendents) {
$feed->setIncludeAllDescendents(true);
}
if ($f->aliases) {
$feed->setDisplayAliases(true);
}
if ($f->featured) {
$feed->setDisplayFeaturedOnly(true);
}
if ($f->pagetype) {
$result = $inspector->inspect((string) $f->pagetype);
$pagetype = $result->getReplacedValue();
$feed->setPageTypeID($pagetype);
}
$contentType = $f->contenttype;
$type = (string) $contentType['type'];
if ($type == 'description') {
$feed->displayShortDescriptionContent();
} elseif ($type == 'area') {
$feed->displayAreaContent((string) $contentType['handle']);
}
$feed->save();
}
}
}
}