if (!scheduled.isEmpty()) {
page.writeStart("h2").writeHtml("Scheduled").writeEnd();
page.writeStart("ul", "class", "links pageThumbnails");
for (Draft d : scheduled) {
Schedule s = d.getSchedule();
String sn = s.getName();
page.writeStart("li",
"class", d.equals(selected) ? "selected" : null,
"data-preview-url", "/_preview?_cms.db.previewId=" + d.getId());
page.writeStart("a", "href", page.objectUrl(null, d));
if (ObjectUtils.isBlank(sn)) {
page.writeHtml(page.formatUserDateTime(s.getTriggerDate()));
page.writeHtml(" by ");
page.writeObjectLabel(s.getTriggerUser());
} else {
page.writeHtml(sn);
}
page.writeEnd();
page.writeEnd();
}
page.writeEnd();
}
if (!drafts.isEmpty()) {
page.writeStart("h2").writeHtml("Drafts").writeEnd();
page.writeStart("ul", "class", "links pageThumbnails");
for (Draft d : drafts) {
Content.ObjectModification dcd = d.as(Content.ObjectModification.class);
page.writeStart("li",
"class", d.equals(selected) ? "selected" : null,
"data-preview-url", "/_preview?_cms.db.previewId=" + d.getId());
page.writeStart("a", "href", page.objectUrl(null, d));
page.writeHtml(page.formatUserDateTime(dcd.getUpdateDate()));
page.writeHtml(" by ");
page.writeObjectLabel(dcd.getUpdateUser());
page.writeEnd();
page.writeEnd();
}
page.writeEnd();
}
if (!namedHistories.isEmpty()) {
page.writeStart("h2").writeHtml("Named Past").writeEnd();
page.writeStart("ul", "class", "links pageThumbnails");
for (History h : namedHistories) {
page.writeStart("li",
"class", h.equals(selected) ? "selected" : null,
"data-preview-url", "/_preview?_cms.db.previewId=" + h.getId());
page.writeStart("a", "href", page.objectUrl(null, h));
page.writeObjectLabel(h);
page.writeEnd();
page.writeEnd();
}
page.writeEnd();
}
if (!histories.isEmpty()) {
page.writeStart("h2").writeHtml("Past").writeEnd();
if (historiesResult.hasNext()) {
page.writeStart("p");
page.writeStart("a",
"class", "icon icon-action-search",
"target", "_top",
"href", page.cmsUrl("/searchAdvancedFull",
Search.SELECTED_TYPE_PARAMETER, ObjectType.getInstance(History.class).getId(),
Search.ADVANCED_QUERY_PARAMETER, "objectId = " + state.getId()));
page.writeHtml("View All ");
page.writeHtml(historiesResult.getCount());
page.writeHtml(" Past Revisions");
page.writeEnd();
page.writeEnd();
page.writeStart("h2");
page.writeHtml("Past 10");
page.writeEnd();
}
page.writeStart("ul", "class", "links pageThumbnails");
for (History h : histories) {
Map<String, Object> originals = h.getObjectOriginals();
page.writeStart("li",
"class", h.equals(selected) ? "selected" : null,
"data-preview-url", "/_preview?_cms.db.previewId=" + h.getId());
if (ObjectUtils.to(boolean.class, originals.get("cms.content.draft"))) {
page.writeStart("span", "class", "visibilityLabel");
page.writeHtml("Draft");
page.writeEnd();
} else {
String workflowState = ObjectUtils.to(String.class, originals.get("cms.workflow.currentState"));
if (workflowState != null) {
Workflow workflow = Query.
from(Workflow.class).
where("contentTypes = ?", h.getState().get("objectType")).
first();
if (workflow != null) {
for (WorkflowState s : workflow.getStates()) {
if (workflowState.equals(s.getName())) {
workflowState = s.getDisplayName();
break;
}
}
}