use of org.olat.core.util.Formatter in project OpenOLAT by OpenOLAT.
the class EPChangelogController method getItemBundlesForSubscriptionItems.
/**
* @param subscriptionItems
* @return
*/
private List<SubscriptionItemBundle> getItemBundlesForSubscriptionItems(List<SubscriptionListItem> subscriptionItems) {
List<SubscriptionItemBundle> bundles = new ArrayList<EPChangelogController.SubscriptionItemBundle>();
Formatter f = Formatter.getInstance(getTranslator().getLocale());
for (int i = 0; i < subscriptionItems.size(); i++) {
SubscriptionListItem listItem = subscriptionItems.get(i);
SubscriptionItemBundle bundle = new SubscriptionItemBundle();
bundle.setDateString(f.formatDate(listItem.getDate()));
String linkName = "subscrIL_" + i;
bundle.setLinkName(linkName);
String text = listItem.getDescription();
FormLink link = uifactory.addFormLink(linkName, text, null, flc, Link.NONTRANSLATED);
link.setUserObject(listItem.getUserObject());
bundle.setCssClass(listItem.getIconCssClass());
bundles.add(bundle);
}
return bundles;
}
use of org.olat.core.util.Formatter in project openolat by klemens.
the class SubscriptionListItem method getHTMLContent.
private String getHTMLContent(Locale locale) {
StringBuilder sb = new StringBuilder();
Translator trans = Util.createPackageTranslator(ContextualSubscriptionController.class, locale);
Formatter form = Formatter.getInstance(locale);
String datePart = trans.translate("subscription.listitem.dateprefix", new String[] { form.formatDateAndTime(date) });
sb.append("<li>");
if (iconCssClass != null) {
sb.append("<i class=\"o_icon o_icon-fw ");
sb.append(iconCssClass);
sb.append("\"></i>");
}
if (StringHelper.containsNonWhitespace(link)) {
sb.append("<a href=\"");
sb.append(link);
sb.append("\">");
}
if (StringHelper.containsNonWhitespace(description)) {
sb.append(new OWASPAntiSamyXSSFilter().filter(description.trim()));
}
if (StringHelper.containsNonWhitespace(link))
sb.append("</a>");
sb.append(" <span class='o_nowrap o_date'>").append(datePart.trim()).append("</span>");
sb.append("</li>");
return sb.toString();
}
use of org.olat.core.util.Formatter in project openolat by klemens.
the class SubscriptionListItem method getPlaintextContent.
private String getPlaintextContent(Locale locale) {
Translator trans = Util.createPackageTranslator(ContextualSubscriptionController.class, locale);
Formatter form = Formatter.getInstance(locale);
StringBuilder sb = new StringBuilder();
String datePart = trans.translate("subscription.listitem.dateprefix", new String[] { form.formatDateAndTime(date) });
sb.append("- ");
sb.append(description.trim());
sb.append(" ").append(datePart.trim());
if (StringHelper.containsNonWhitespace(link))
sb.append("\n").append(" ").append(link);
return sb.toString();
}
use of org.olat.core.util.Formatter in project openolat by klemens.
the class PortfolioResultDetailsController method initMapsForm.
protected void initMapsForm(FormItemContainer formLayout) {
Formatter formatter = Formatter.getInstance(getLocale());
int count = 0;
for (PortfolioStructureMap map : maps) {
MapElements mapElements = new MapElements();
if (map instanceof EPStructuredMap) {
EPStructuredMap structuredMap = (EPStructuredMap) map;
if (maps.size() > 1 || !structuredMap.getStructuredMapSource().equals(templateMap)) {
String templateTitle = structuredMap.getStructuredMapSource().getTitle();
uifactory.addStaticTextElement("map.template." + count, "map.template", templateTitle, formLayout);
}
String copyDate = "";
if (structuredMap.getCopyDate() != null) {
copyDate = formatter.formatDateAndTime(structuredMap.getCopyDate());
}
uifactory.addStaticTextElement("map.copyDate." + count, "map.copyDate", copyDate, formLayout);
String returnDate = "";
if (structuredMap.getReturnDate() != null) {
returnDate = formatter.formatDateAndTime(structuredMap.getReturnDate());
}
uifactory.addStaticTextElement("map.returnDate." + count, "map.returnDate", returnDate, formLayout);
String deadLine = "";
if (structuredMap.getDeadLine() != null) {
deadLine = formatter.formatDateAndTime(structuredMap.getDeadLine());
}
mapElements.deadlineEl = uifactory.addStaticTextElement("map.deadline." + count, "map.deadline", deadLine, formLayout);
}
FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons." + count, getTranslator());
buttonsCont.setRootForm(mainForm);
formLayout.add(buttonsCont);
if (map instanceof EPStructuredMap) {
mapElements.changeDeadlineLink = uifactory.addFormLink("map.deadline.change." + count, "map.deadline.change", null, buttonsCont, Link.BUTTON);
mapElements.changeDeadlineLink.setUserObject(map);
}
mapElements.openMapLink = uifactory.addFormLink("open.map." + count, "open.map", null, buttonsCont, Link.BUTTON);
mapElements.openMapLink.setUserObject(map);
count++;
if (count != maps.size()) {
uifactory.addSpacerElement("spacer-" + count, formLayout, false);
}
mapToElements.put(map, mapElements);
}
}
use of org.olat.core.util.Formatter in project openolat by klemens.
the class PortfolioResultDetailsController method initBindersForm.
protected void initBindersForm(FormItemContainer formLayout) {
Formatter formatter = Formatter.getInstance(getLocale());
int count = 0;
for (Binder binder : binders) {
MapElements mapElements = new MapElements();
if (binders.size() > 1 || !binder.getTemplate().equals(templateBinder)) {
String templateTitle = binder.getTemplate().getTitle();
uifactory.addStaticTextElement("map.template." + count, "map.template", templateTitle, formLayout);
}
String copyDate = "";
if (binder.getCopyDate() != null) {
copyDate = formatter.formatDateAndTime(binder.getCopyDate());
}
uifactory.addStaticTextElement("map.copyDate." + count, "map.copyDate", copyDate, formLayout);
String returnDate = "";
if (binder.getReturnDate() != null) {
returnDate = formatter.formatDateAndTime(binder.getReturnDate());
}
uifactory.addStaticTextElement("map.returnDate." + count, "map.returnDate", returnDate, formLayout);
FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons." + count, getTranslator());
buttonsCont.setRootForm(mainForm);
formLayout.add(buttonsCont);
mapElements.openMapLink = uifactory.addFormLink("open.binder." + count, "open.binder", "open.map", null, buttonsCont, Link.BUTTON);
mapElements.openMapLink.setUserObject(binder);
count++;
if (count != binders.size()) {
uifactory.addSpacerElement("spacer-" + count, formLayout, false);
}
binderToElements.put(binder, mapElements);
}
}
Aggregations