CmsTool cms = getCmsTool();
Area area = getArea();
String companyName = cms.getCompanyName();
String environment = cms.getEnvironment();
ToolUser user = getUser();
if (ObjectUtils.isBlank(companyName)) {
companyName = "Brightspot";
}
Site site = getSite();
StorageItem companyLogo = site != null ? site.getCmsLogo() : null;
if (companyLogo == null) {
companyLogo = cms.getCompanyLogo();
}
writeTag("!doctype html");
writeTag("html", "class", site != null ? site.getCmsCssClass() : null);
writeStart("head");
writeStart("title");
if (!ObjectUtils.isBlank(title)) {
writeHtml(title);
writeHtml(" | ");
} else if (area != null) {
writeObjectLabel(area);
writeHtml(" | ");
}
writeHtml("CMS | ");
writeHtml(companyName);
writeEnd();
writeElement("meta", "name", "robots", "content", "noindex");
writeStylesAndScripts();
writeEnd();
Schedule currentSchedule = getUser() != null ? getUser().getCurrentSchedule() : null;
String broadcastMessage = cms.getBroadcastMessage();
Date broadcastExpiration = cms.getBroadcastExpiration();
boolean hasBroadcast = !ObjectUtils.isBlank(broadcastMessage) &&
(broadcastExpiration == null ||
broadcastExpiration.after(new Date()));
writeTag("body", "class",
(currentSchedule != null || hasBroadcast ? "hasToolBroadcast " : "") +
(user != null ? "" : "noToolUser "));
if (currentSchedule != null || hasBroadcast) {
writeStart("div", "class", "toolBroadcast");
if (currentSchedule != null) {
writeHtml("All editorial changes will be scheduled for: ");
writeStart("a",
"href", cmsUrl("/scheduleEdit", "id", currentSchedule.getId()),
"target", "scheduleEdit");
writeHtml(getObjectLabel(currentSchedule));
writeEnd();
writeHtml(" - ");
writeStart("form",
"method", "post",
"style", "display: inline;",
"action", cmsUrl("/misc/updateUserSettings",
"action", "scheduleSet",
"returnUrl", url("")));
writeStart("button",
"class", "link icon icon-action-cancel");
writeHtml("Stop Scheduling");
writeEnd();
writeEnd();
}
if (hasBroadcast) {
writeHtml(" - ");
writeHtml(broadcastMessage);
}
writeEnd();
}
writeStart("div", "class", "toolHeader" + (!ObjectUtils.isBlank(environment) ? " toolHeader-hasEnvironment" : ""));
writeStart("h1", "class", "toolTitle");
writeStart("a", "href", cmsUrl("/"));
if (companyLogo != null) {
writeElement("img", "src", companyLogo.getPublicUrl(), "alt", companyName);
} else {
writeHtml(companyName);
}
writeEnd();
writeEnd();
if (!ObjectUtils.isBlank(environment)) {
writeStart("div", "class", "toolEnv");
writeHtml(environment);
writeEnd();
}
if (user != null) {
int nowHour = new DateTime().getHourOfDay();
writeStart("div", "class", "toolAvatar");
StorageItem avatar = user.getAvatar();
if (avatar != null) {
writeStart("a", "href", cmsUrl("/misc/settings.jsp"));
writeTag("img",
"src", ImageEditor.Static.resize(ImageEditor.Static.getDefault(), avatar, null, 50, 50).getPublicUrl());
writeEnd();
}
writeEnd();
writeStart("div", "class", "toolProfile");
writeHtml("Good ");
writeHtml(nowHour >= 2 && nowHour < 12 ? "Morning" : (nowHour >= 12 && nowHour < 18 ? "Afternoon" : "Evening"));
writeHtml(", ");
writeHtml(getObjectLabel(user));
writeStart("ul");
if (!Site.Static.findAll().isEmpty()) {
Site currentSite = user.getCurrentSite();
writeStart("li");
writeHtml("Site: ");
writeStart("a", "href", cmsUrl("/misc/sites.jsp"), "target", "misc");
writeHtml(currentSite != null ? currentSite.getLabel() : "Global");