hasMethod("isPublished")) {
$published = $record->isPublished();
if(!$published) {
return _t("GridFieldBlogPostState.Draft", ' Saved as Draft');
} 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()
)
);
} else {
return _t(
"GridFieldBlogPostState.Published",
' Published on {date}',
"State for when a post is published.",
array(
"date" => $record->dbObject("PublishDate")->Nice()
)
);
}
}
}
}
public function getColumnAttributes($gridField, $record, $columnName) {
if($columnName == "State") {
if($record->hasMethod("isPublished")) {
$published = $record->isPublished();
if(!$published) {
$class = "blog-icon draft";
} else if (strtotime($record->PublishDate) > time()) {
$class = "blog-icon timer";
} else {
$class = "blog-icon published";
}
return array("class" => $class);
}
}
return array();
}
public function getColumnMetaData($gridField, $columnName) {
switch($columnName) {
case 'State':
return array("title" => _t("GridFieldBlogPostState.StateTitle", "State", "Column title for state"));
}
}
}