Search in sources :

Example 16 with Formatter

use of org.olat.core.util.Formatter in project OpenOLAT by OpenOLAT.

the class ConfirmExtraTimeController method currentAssessmentModeMessage.

private void currentAssessmentModeMessage(FormLayoutContainer layoutCont) {
    Formatter formatter = Formatter.getInstance(getLocale());
    List<String> modes = new ArrayList<>();
    for (AssessmentMode assessmentMode : assessmentModes) {
        String title = assessmentMode.getName();
        String begin = formatter.formatDateAndTime(assessmentMode.getBegin());
        String end = formatter.formatDateAndTime(assessmentMode.getEnd());
        modes.add(translate("warning.assessment.mode.date", new String[] { title, begin, end }));
    }
    layoutCont.contextPut("assessmemtModeMessages", modes);
}
Also used : AssessmentMode(org.olat.course.assessment.AssessmentMode) Formatter(org.olat.core.util.Formatter) ArrayList(java.util.ArrayList)

Example 17 with Formatter

use of org.olat.core.util.Formatter in project OpenOLAT by OpenOLAT.

the class MemberInfoController method setMembershipCreation.

public void setMembershipCreation(Date date) {
    if (date != null) {
        Formatter formatter = Formatter.getInstance(getLocale());
        membershipCreationEl.setValue(formatter.formatDate(date));
    }
}
Also used : Formatter(org.olat.core.util.Formatter)

Example 18 with Formatter

use of org.olat.core.util.Formatter in project OpenOLAT by OpenOLAT.

the class MemberInfoController method initForm.

@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
    if (formLayout instanceof FormLayoutContainer) {
        FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
        Controller dpc = new DisplayPortraitController(ureq, getWindowControl(), identity, true, false);
        // auto dispose
        listenTo(dpc);
        layoutCont.put("image", dpc.getInitialComponent());
        layoutCont.contextPut("fullname", StringHelper.escapeHtml(userManager.getUserDisplayName(identity)));
    }
    // user properties
    FormLayoutContainer userPropertiesContainer = FormLayoutContainer.createDefaultFormLayout_6_6("userProperties", getTranslator());
    formLayout.add("userProperties", userPropertiesContainer);
    List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(getClass().getCanonicalName(), false);
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
        if (userPropertyHandler == null)
            continue;
        String propName = userPropertyHandler.getName();
        String value = userPropertyHandler.getUserProperty(identity.getUser(), getLocale());
        String key = userPropertyHandler.i18nFormElementLabelKey();
        if (value == null) {
            value = "";
        }
        uifactory.addStaticTextElement("up_" + propName, key, value, userPropertiesContainer);
    }
    // course informations
    FormLayoutContainer courseInfosContainer = FormLayoutContainer.createDefaultFormLayout_9_3("courseInfos", getTranslator());
    formLayout.add("courseInfos", courseInfosContainer);
    membershipCreationEl = uifactory.addStaticTextElement("firstTime", "course.membership.creation", "", courseInfosContainer);
    if (securityModule.isUserLastVisitVisible(ureq.getUserSession().getRoles())) {
        Formatter formatter = Formatter.getInstance(getLocale());
        String lastVisit = "";
        String numOfVisits = "0";
        if (courseInfos != null) {
            if (courseInfos.getRecentLaunch() != null) {
                lastVisit = formatter.formatDate(courseInfos.getRecentLaunch());
            }
            if (courseInfos.getVisit() >= 0) {
                numOfVisits = Integer.toString(courseInfos.getVisit());
            }
        }
        uifactory.addStaticTextElement("lastTime", "course.lastTime", lastVisit, courseInfosContainer);
        uifactory.addStaticTextElement("numOfVisits", "course.numOfVisits", numOfVisits, courseInfosContainer);
    }
    // links
    if (withLinks) {
        homeLink = uifactory.addFormLink("home", formLayout, Link.BUTTON);
        homeLink.setIconLeftCSS("o_icon o_icon_home");
        formLayout.add("home", homeLink);
        contactLink = uifactory.addFormLink("contact", formLayout, Link.BUTTON);
        contactLink.setIconLeftCSS("o_icon o_icon_mail");
        formLayout.add("contact", contactLink);
        if (repoEntryKey != null) {
            assessmentLink = uifactory.addFormLink("assessment", formLayout, Link.BUTTON);
            assessmentLink.setIconLeftCSS("o_icon o_icon_certificate");
            formLayout.add("assessment", assessmentLink);
        }
    }
}
Also used : DisplayPortraitController(org.olat.user.DisplayPortraitController) Formatter(org.olat.core.util.Formatter) FormLayoutContainer(org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer) DisplayPortraitController(org.olat.user.DisplayPortraitController) FormBasicController(org.olat.core.gui.components.form.flexible.impl.FormBasicController) Controller(org.olat.core.gui.control.Controller) UserPropertyHandler(org.olat.user.propertyhandlers.UserPropertyHandler)

Example 19 with Formatter

use of org.olat.core.util.Formatter in project OpenOLAT by OpenOLAT.

the class LecturesBlockSignaturePDFExport method create.

public void create(List<Identity> rows) throws IOException, TransformerException {
    addPage();
    String lectureBlockTitle = lectureBlock.getTitle();
    String resourceTitle = entry.getDisplayname();
    addMetadata(lectureBlockTitle, resourceTitle, teacher);
    String title = resourceTitle + " - " + lectureBlockTitle;
    title = translator.translate("attendance.list.to.sign.title", new String[] { title });
    addParagraph(title, 16, true, width);
    Formatter formatter = Formatter.getInstance(translator.getLocale());
    String dates = translator.translate("pdf.table.dates", new String[] { formatter.formatDate(lectureBlock.getStartDate()), formatter.formatTimeShort(lectureBlock.getStartDate()), formatter.formatTimeShort(lectureBlock.getEndDate()) });
    addParagraph(dates, 12, true, width);
    float cellMargin = 5.0f;
    float fontSize = 10.0f;
    String[] content = getRows(rows);
    int numOfRows = content.length;
    for (int offset = 0; offset < numOfRows; ) {
        offset += drawTable(content, offset, fontSize, cellMargin);
        closePage();
        if (offset < numOfRows) {
            addPage();
        }
    }
    addPageNumbers();
}
Also used : Formatter(org.olat.core.util.Formatter)

Example 20 with Formatter

use of org.olat.core.util.Formatter in project OpenOLAT by OpenOLAT.

the class LecturesBlockSignaturePDFExport method prepare.

@Override
public void prepare(HttpServletResponse hres) {
    try {
        Formatter formatter = Formatter.getInstance(translator.getLocale());
        String filename = lectureBlock.getTitle() + "_" + formatter.formatDate(lectureBlock.getStartDate()) + "_" + formatter.formatTimeShort(lectureBlock.getStartDate()) + "-" + formatter.formatTimeShort(lectureBlock.getEndDate()) + ".pdf";
        hres.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + StringHelper.urlEncodeUTF8(filename));
        hres.setHeader("Content-Description", StringHelper.urlEncodeUTF8(filename));
        document.save(hres.getOutputStream());
    } catch (COSVisitorException | IOException e) {
        log.error("", e);
    }
}
Also used : COSVisitorException(org.apache.pdfbox.exceptions.COSVisitorException) Formatter(org.olat.core.util.Formatter) IOException(java.io.IOException)

Aggregations

Formatter (org.olat.core.util.Formatter)80 Date (java.util.Date)30 ArrayList (java.util.ArrayList)12 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)12 IOException (java.io.IOException)6 SubscriptionListItem (org.olat.core.commons.services.notifications.model.SubscriptionListItem)6 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)6 Identity (org.olat.core.id.Identity)6 Translator (org.olat.core.gui.translator.Translator)5 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)5 File (java.io.File)4 Calendar (java.util.Calendar)4 HashMap (java.util.HashMap)4 COSVisitorException (org.apache.pdfbox.exceptions.COSVisitorException)4 Row (org.olat.core.util.openxml.OpenXMLWorksheet.Row)4 OWASPAntiSamyXSSFilter (org.olat.core.util.filter.impl.OWASPAntiSamyXSSFilter)3 HashSet (java.util.HashSet)2 Map (java.util.Map)2 VelocityContext (org.apache.velocity.VelocityContext)2 Context (org.apache.velocity.context.Context)2