Source of file PageTreeItem.php
Size: 2,092 Bytes - Last Modified: 2021-12-24T06:49:04+00:00
/var/www/docs.ssmods.com/process/src/code/MenuTree/PageTreeItem.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 | <?php /** * @property int $ID * @property string $URLSegment * @property string $Title * @property string $MenuTitle * @property bool $ShowInMenus * @property int $Sort * @property string $CanViewType * @property int $ParentID */ class PageTreeItem extends Page implements HiddenClass { private static $ancestorIDCache = array(); /** * * @var MenuItem */ public $Parent = null; /** * * @var ArrayList|MenuItem[] */ public $Children = array(); public function __construct($record = null, $isSingleton = false, $model = null) { parent::__construct($record, $isSingleton, $model); $this->Children = new PageTreeItemList(); } public function getChildren() { return $this->Children; } public function getChildNodes() { return $this->Children; } public function getParent() { return $this->Parent; } public function isOrphaned() { return $this->Parent == null; } public function getAncestorIDs() { if (!isset(static::$ancestorIDCache[$this->ID])) { static::$ancestorIDCache[$this->ID] = array(); $object = $this; while ($object = $object->Parent) { static::$ancestorIDCache[$this->ID][] = $object->ID; } } return static::$ancestorIDCache[$this->ID]; } public function isSection() { $isSection = $this->isCurrent(); $currentPage = Director::get_current_page(); $menuTree = PageMenuTree::Instance(); /* @var $currentMenuItems PageTreeItem */ $currentMenuItem = $menuTree->byID($currentPage->ID); if (!$isSection && $currentMenuItem) { $currentAncestors = $currentMenuItem->getAncestorIDs(); $isSection = in_array($this->ID, $currentAncestors); } return $isSection; } public function Parent() { return $this->Parent; } } |