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