isModifiedOnDraft()) {
$modifiedLabel = '' . _t(__CLASS__ . '.Modified', 'Modified') . '';
}
if (!$record->isPublished()) {
/**
* @var DBDatetime $lastEdited
*/
$lastEdited = $record->dbObject('LastEdited');
return ' ' . _t(
__CLASS__ . '.Draft',
'Saved as Draft on {date}',
'State for when a post is saved.',
[
'date' => $lastEdited->FormatFromSettings(),
]
);
}
/**
* @var DBDatetime $publishDate
*/
$publishDate = $record->dbObject('PublishDate');
if (strtotime($record->PublishDate) > time()) {
return ' ' . _t(
__CLASS__ . '.Timer',
'Publish at {date}',
'State for when a post is published.',
[
'date' => $publishDate->FormatFromSettings(),
]
) . $modifiedLabel;
}
return ' ' . _t(
__CLASS__ . '.Published',
'Published on {date}',
'State for when a post is published.',
[
'date' => $publishDate->FormatFromSettings(),
]
) . $modifiedLabel;
}
}
return '';
}
/**
* {@inheritdoc}
*/
public function getColumnAttributes($gridField, $record, $columnName)
{
if ($columnName == 'State') {
if ($record instanceof BlogPost) {
$published = $record->isPublished();
if (!$published) {
$class = 'gridfield-icon draft';
} elseif (strtotime($record->PublishDate) > time()) {
$class = 'gridfield-icon timer';
} else {
$class = 'gridfield-icon published';
}
return [
'class' => $class,
];
}
}
return [];
}
}