isModifiedOnStage) {
$modifiedLabel = '' . _t('GridFieldBlogPostState.Modified') . '';
}
if (!$record->isPublished()) {
/**
* @var SS_Datetime $lastEdited
*/
$lastEdited = $record->dbObject('LastEdited');
return _t(
'GridFieldBlogPostState.Draft',
' Saved as Draft on {date}',
'State for when a post is saved.',
array(
'date' => $lastEdited->Nice(),
)
);
}
/**
* @var SS_Datetime $publishDate
*/
$publishDate = $record->dbObject('PublishDate');
if (strtotime($record->PublishDate) > time()) {
return _t(
'GridFieldBlogPostState.Timer',
' Publish at {date}',
'State for when a post is published.',
array(
'date' => $publishDate->Nice(),
)
) . $modifiedLabel;
}
return _t(
'GridFieldBlogPostState.Published',
' Published on {date}',
'State for when a post is published.',
array(
'date' => $publishDate->Nice(),
)
) . $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 array(
'class' => $class,
);
}
}
return array();
}
}