Source of file ContentChangesetItem.php
Size: 2,115 Bytes - Last Modified: 2021-12-23T10:25:22+00:00
/var/www/docs.ssmods.com/process/src/code/dataobjects/ContentChangesetItem.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 | <?php /** * Object that represents an item in a content changeset * * @author Marcus Nyeholt <marcus@silverstripe.com.au> */ class ContentChangesetItem extends DataObject implements CMSPreviewable { public static $db = array( 'OtherID' => 'Int', 'OtherClass' => 'Varchar(32)', 'OtherContentID' => 'Varchar(64)', 'ContentVersion' => 'Int', // the version of the item at the point of publication 'ChangeType' => 'Varchar', ); public static $has_one = array( 'Changeset' => 'ContentChangeset', ); public static $summary_fields = array( 'DisplayLabel' => 'Title', 'getRealItem.LastEdited' => 'Last Edited', 'objectChangeType' => 'Change Type', 'ContentVersion' => 'Published Version', 'getRealItem.Version' => 'Current Version', ); public function getRealItem() { if (!$this->OtherClass || !$this->OtherID) { return $this; } $item = DataObject::get_by_id($this->OtherClass, $this->OtherID); if (!$item) { $item = ArrayData::create(array( 'ID' => $this->OtherID, 'ClassName' => $this->OtherClass, 'Title' => 'deleted', 'LastEdited' => 'deleted', 'getChangeType' => 'deleted', 'Version' => 'deleted' )); } return $item; } public function objectChangeType() { if (!$this->ChangeType) { return $this->getRealItem()->getChangeType(); } return $this->ChangeType; } public function DisplayLabel() { $item = $this->getRealItem(); if ($item) { return sprintf('%s (%s #%s)', $item->Title, $item->ClassName, $item->ID); } return 'missing'; } public function CMSEditLink() { $item = $this->getRealItem(); if ($item instanceof CMSPreviewable) { return $item->CMSEditLink(); } } public function Link() { $item = $this->getRealItem(); if ($item instanceof CMSPreviewable) { return $item->Link(); } } public function canView($member = null) { return $this->Changeset()->canView($member); } public function canEdit($member = null) { return $this->Changeset()->canEdit($member); } public function canDelete($member = null) { return $this->Changeset()->canDelete($member); } } |