/
PageTypeConfiguration.php
79 lines (68 loc) · 2.01 KB
/
PageTypeConfiguration.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
namespace Concrete\Core\Page\Type\PublishTarget\Configuration;
use Concrete\Core\Page\Page;
use Concrete\Core\Page\Type\Type;
use PageType;
class PageTypeConfiguration extends Configuration
{
protected $ptID;
protected $selectorFormFactor;
protected $startingPointPage;
public function setPageTypeID($ptID)
{
$this->ptID = $ptID;
}
public function getPageTypeID()
{
return $this->ptID;
}
public function getSelectorFormFactor()
{
return $this->selectorFormFactor;
}
public function setSelectorFormFactor($selectorFormFactor)
{
$this->selectorFormFactor = $selectorFormFactor;
}
public function getDefaultParentPageID()
{
$db = \Database::connection();
$ids = $db->GetCol('select cID from Pages where ptID = ? and cIsTemplate = 0 and cIsActive = 1', [$this->getPageTypeID()]);
if (count($ids) == 1) {
return $ids[0];
}
}
/**
* @return mixed
*/
public function getStartingPointPageID()
{
return $this->startingPointPage;
}
/**
* @param mixed $startingPointPage
*/
public function setStartingPointPageID($startingPointPage)
{
$this->startingPointPage = $startingPointPage;
}
public function export($cxml)
{
$target = parent::export($cxml);
if ($this->getStartingPointPageID()) {
$c = Page::getByID($this->getStartingPointPageID(), 'ACTIVE');
if (is_object($c) && !$c->isError()) {
$target->addAttribute('path', $c->getCollectionPath());
}
}
$ct = PageType::getByID($this->ptID);
if (is_object($ct)) {
$target->addAttribute('pagetype', $ct->getPageTypeHandle());
}
$target->addAttribute('form-factor', $this->getSelectorFormFactor());
}
public function canPublishPageTypeBeneathTarget(Type $pagetype, Page $page)
{
return $page->getPageTypeID() == $this->getPageTypeID();
}
}