use of org.olat.core.util.Formatter in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
the class RichTextConfiguration method setInsertDateTimeEnabled.
/**
* Enable / disable the date and time insert plugin
*
* @param insertDateTimeEnabled
* true: plugin enabled; false: plugin disabled
* @param locale
* the locale used to format the date and time
* @param row
* The row where to place the plugin buttons
*/
private void setInsertDateTimeEnabled(boolean insertDateTimeEnabled, Locale locale) {
if (insertDateTimeEnabled) {
// use date format defined in org.olat.core package
Formatter formatter = Formatter.getInstance(locale);
String dateFormat = formatter.getSimpleDatePatternForDate();
setQuotedConfigValue("insertdatetime_dateformat", dateFormat);
setNonQuotedConfigValue("insertdatetime_formats", "['" + dateFormat + "','%H:%M:%S']");
}
}
use of org.olat.core.util.Formatter in project OpenOLAT by OpenOLAT.
the class MailListController method reloadModel.
private void reloadModel() {
List<DBMailLight> mails;
if (outbox) {
if (StringHelper.containsNonWhitespace(metaId)) {
mails = mailManager.getEmailsByMetaId(metaId);
} else {
mails = mailManager.getOutbox(getIdentity(), 0, -1, true);
}
// strip meta emails
Set<String> metaIds = new HashSet<>();
for (Iterator<DBMailLight> it = mails.iterator(); it.hasNext(); ) {
DBMailLight mail = it.next();
if (StringHelper.containsNonWhitespace(mail.getMetaId())) {
if (metaIds.contains(mail.getMetaId())) {
it.remove();
} else {
metaIds.add(mail.getMetaId());
}
}
}
} else {
mails = mailManager.getInbox(getIdentity(), null, Boolean.TRUE, null, 0, -1);
}
// extract contexts
Map<String, String> bpToContexts = new HashMap<>();
for (DBMailLight mail : mails) {
String businessPath = mail.getContext().getBusinessPath();
if (StringHelper.containsNonWhitespace(businessPath) && !bpToContexts.containsKey(businessPath)) {
String contextName = contextResolver.getName(businessPath, getLocale());
if (StringHelper.containsNonWhitespace(contextName)) {
bpToContexts.put(businessPath, contextName);
}
}
}
if (!bpToContexts.isEmpty()) {
List<ShortName> filters = new ArrayList<>();
Map<String, MailContextShortName> uniqueNames = new HashMap<>();
ShortName allContextFilter = new MailContextShortName("-");
filters.add(allContextFilter);
for (Map.Entry<String, String> entry : bpToContexts.entrySet()) {
String businessPath = entry.getKey();
String contextName = entry.getValue();
if (!uniqueNames.containsKey(contextName)) {
MailContextShortName cxt = new MailContextShortName(contextName, new HashSet<String>());
filters.add(cxt);
uniqueNames.put(contextName, cxt);
}
uniqueNames.get(contextName).getBusinessPaths().add(businessPath);
}
tableCtr.setFilters(filters, allContextFilter);
}
Formatter formatter = Formatter.getInstance(getLocale());
MailDataModel dataModel = new MailDataModel(mails, bpToContexts, getIdentity(), getTranslator(), formatter, outbox);
tableCtr.setTableDataModel(dataModel);
}
use of org.olat.core.util.Formatter in project OpenOLAT by OpenOLAT.
the class CertificatePDFFormWorker method fillCertificationInfos.
private void fillCertificationInfos(PDAcroForm acroForm) throws IOException {
Formatter format = Formatter.getInstance(locale);
if (dateCertification == null) {
fillField("dateCertification", "", acroForm);
} else {
String formattedDateCertification = format.formatDate(dateCertification);
fillField("dateCertification", formattedDateCertification, acroForm);
String formattedDateCertificationLong = format.formatDateLong(dateCertification);
fillField("dateCertificationLong", formattedDateCertificationLong, acroForm);
}
if (dateFirstCertification == null) {
fillField("dateFirstCertification", "", acroForm);
} else {
String formattedDateFirstCertification = format.formatDate(dateFirstCertification);
fillField("dateFirstCertification", formattedDateFirstCertification, acroForm);
String formattedDateFirstCertificationLong = format.formatDate(dateFirstCertification);
fillField("dateFirstCertificationLong", formattedDateFirstCertificationLong, acroForm);
}
if (dateNextRecertification == null) {
fillField("dateNextRecertification", "", acroForm);
} else {
String formattedDateNextRecertification = format.formatDate(dateNextRecertification);
fillField("dateNextRecertification", formattedDateNextRecertification, acroForm);
String formattedDateNextRecertificationLong = format.formatDateLong(dateNextRecertification);
fillField("dateNextRecertificationLong", formattedDateNextRecertificationLong, acroForm);
}
}
use of org.olat.core.util.Formatter in project OpenOLAT by OpenOLAT.
the class CertificatePhantomWorker method fillCertificationInfos.
private void fillCertificationInfos(VelocityContext context) {
Formatter format = Formatter.getInstance(locale);
context.put("dateFormatter", format);
if (dateCertification == null) {
context.put("dateCertification", "");
} else {
String formattedDateCertification = format.formatDate(dateCertification);
context.put("dateCertification", formattedDateCertification);
String formattedDateCertificationLong = format.formatDateLong(dateCertification);
context.put("dateCertificationLong", formattedDateCertificationLong);
context.put("dateCertificationRaw", dateCertification);
}
if (dateFirstCertification == null) {
context.put("dateFirstCertification", "");
} else {
String formattedDateFirstCertification = format.formatDate(dateFirstCertification);
context.put("dateFirstCertification", formattedDateFirstCertification);
String formattedDateFirstCertificationLong = format.formatDate(dateFirstCertification);
context.put("dateFirstCertificationLong", formattedDateFirstCertificationLong);
context.put("dateFirstCertificationRaw", dateFirstCertification);
}
if (dateNextRecertification == null) {
context.put("dateNextRecertification", "");
} else {
String formattedDateNextRecertification = format.formatDate(dateNextRecertification);
context.put("dateNextRecertification", formattedDateNextRecertification);
String formattedDateNextRecertificationLong = format.formatDateLong(dateNextRecertification);
context.put("dateNextRecertificationLong", formattedDateNextRecertificationLong);
context.put("dateNextRecertificationRaw", dateNextRecertification);
}
}
Aggregations