**/
class GridFieldBlogPostState extends GridFieldSiteTreeState {
public function getColumnContent($gridField, $record, $columnName) {
if($columnName == "State") {
Requirements::css(BLOGGER_DIR . '/css/cms.css');
if($record->hasMethod("isPublished")) {
$modifiedLabel = "";
if($record->isModifiedOnStage) {
$modifiedLabel = "" . _t("GridFieldBlogPostState.Modified") . "";
}
$published = $record->isPublished();
if(!$published) {
return _t(
"GridFieldBlogPostState.Draft",
' Saved as Draft on {date}',
"State for when a post is saved.",
array(
"date" => $record->dbObject("LastEdited")->Nice()
)
);
} else if (strtotime($record->PublishDate) > time()) {
return _t(
"GridFieldBlogPostState.Timer",
' Publish at {date}',
"State for when a post is published.",
array(
"date" => $record->dbObject("PublishDate")->Nice()
)
) . $modifiedLabel;
} else {
return _t(
"GridFieldBlogPostState.Published",
' Published on {date}',
"State for when a post is published.",
array(
"date" => $record->dbObject("PublishDate")->Nice()
)
) . $modifiedLabel;
}
}
}
}
public function getColumnAttributes($gridField, $record, $columnName) {
if($columnName == "State") {
if($record->hasMethod("isPublished")) {
$published = $record->isPublished();
if(!$published) {
$class = "gridfield-icon draft";
} else if (strtotime($record->PublishDate) > time()) {
$class = "gridfield-icon timer";
} else {
$class = "gridfield-icon published";
}
return array("class" => $class);
}
}
return array();
}
}