/** * @param ores * @param title * @param wControl */ public DTabImpl( OLATResourceable ores, OLATResourceable initialOres, String title, WindowControl wOrigControl) { this.ores = ores; this.initialOres = initialOres; this.title = title; // Root the JumpInPath - typically all resources are opened in tabs StackedBusinessControl businessControl = new StackedBusinessControl(null, wOrigControl.getBusinessControl()); wControl = BusinessControlFactory.getInstance() .createBusinessWindowControl(businessControl, wOrigControl); String typeName = ores.getResourceableTypeName(); String shortTitle; if (title == null) { shortTitle = "???"; } else if (!title.startsWith(I18nManager.IDENT_PREFIX)) { // don't truncate titles when in inline translation mode (OLAT-3811) shortTitle = Formatter.truncate(title, 15); } else { shortTitle = title; } navElement = new DefaultNavElement(shortTitle, title, "b_resource_" + typeName.replace(".", "-")); }
public GoToMeetingController( UserRequest ureq, WindowControl wControl, GoToMeeting meeting, boolean administrator, boolean moderator, boolean readOnly) { super(ureq, wControl); this.readOnly = readOnly; this.moderator = moderator; this.administrator = administrator; mainVC = createVelocityContainer("meeting"); mainVC.contextPut("title", meeting.getName()); mainVC.contextPut("description", meeting.getDescription()); if (administrator || moderator) { startLink = LinkFactory.createButtonLarge("training.start", mainVC, this); startLink.setTarget("_blank"); } registerLink = LinkFactory.createButtonLarge("training.register", mainVC, this); confirmLink = LinkFactory.createButtonLarge("training.confirm", mainVC, this); confirmLink.setTarget("_blank"); joinLink = LinkFactory.createButtonLarge("training.join", mainVC, this); joinLink.setTarget("_blank"); openRecordingsLink = LinkFactory.createButton("recordings", mainVC, this); GoToError error = new GoToError(); this.meeting = meetingMgr.getMeeting(meeting, error); this.registrant = meetingMgr.getRegistrant(meeting, getIdentity()); if (error.hasError() && error.getError() != null) { mainVC.contextPut("errorMessage", translate(error.getError().i18nKey())); } List<GoToRecordingsG2T> recordings = meetingMgr.getRecordings(meeting, error); openRecordingsLink.setVisible(recordings != null && recordings.size() > 0); Date start = meeting.getStartDate(); Date end = meeting.getEndDate(); Formatter formatter = Formatter.getInstance(getLocale()); mainVC.contextPut("start", formatter.formatDateAndTime(start)); mainVC.contextPut("end", formatter.formatDateAndTime(end)); putInitialPanel(mainVC); updateButtons(); }
/** * @param ureq * @return */ private StringBuilder createChangelogMsg(UserRequest ureq) { /* * TODO:pb:is ImsRepositoryResolver the right place for getting the change log? */ // re could be null, but if we are here it should not be null! Roles userRoles = ureq.getUserSession().getRoles(); boolean showAll = userRoles.isAuthor() || userRoles.isOLATAdmin(); // get changelog Formatter formatter = Formatter.getInstance(ureq.getLocale()); ImsRepositoryResolver resolver = new ImsRepositoryResolver(referenceTestEntry); QTIChangeLogMessage[] qtiChangeLog = resolver.getDocumentChangeLog(); StringBuilder qtiChangelog = new StringBuilder(); if (qtiChangeLog.length > 0) { // there are resource changes Arrays.sort(qtiChangeLog); for (int i = qtiChangeLog.length - 1; i >= 0; i--) { // show latest change first if (!showAll && qtiChangeLog[i].isPublic()) { // logged in person is a normal user, hence public messages only Date msgDate = new Date(qtiChangeLog[i].getTimestmp()); qtiChangelog .append("\nChange date: ") .append(formatter.formatDateAndTime(msgDate)) .append("\n"); String msg = StringHelper.escapeHtml(qtiChangeLog[i].getLogMessage()); qtiChangelog.append(msg); qtiChangelog.append("\n********************************\n"); } else if (showAll) { // logged in person is an author, olat admin, owner, show all messages Date msgDate = new Date(qtiChangeLog[i].getTimestmp()); qtiChangelog .append("\nChange date: ") .append(formatter.formatDateAndTime(msgDate)) .append("\n"); String msg = StringHelper.escapeHtml(qtiChangeLog[i].getLogMessage()); qtiChangelog.append(msg); qtiChangelog.append("\n********************************\n"); } // else non public messages are not shown to normal user } } return qtiChangelog; }
private void exposeUserTestDataToVC(UserRequest ureq) { // config : show score info Object enableScoreInfoObject = modConfig.get(IQEditController.CONFIG_KEY_ENABLESCOREINFO); if (enableScoreInfoObject != null) { myContent.contextPut("enableScoreInfo", enableScoreInfoObject); } else { myContent.contextPut("enableScoreInfo", Boolean.TRUE); } // configuration data myContent.contextPut("attemptsConfig", modConfig.get(IQEditController.CONFIG_KEY_ATTEMPTS)); // user data Identity identity = userCourseEnv.getIdentityEnvironment().getIdentity(); if (courseNode instanceof PersistentAssessableCourseNode) { PersistentAssessableCourseNode acn = (PersistentAssessableCourseNode) courseNode; AssessmentEntry assessmentEntry = acn.getUserAssessmentEntry(userCourseEnv); if (assessmentEntry == null) { myContent.contextPut("blockAfterSuccess", Boolean.FALSE); myContent.contextPut("score", null); myContent.contextPut("hasPassedValue", Boolean.FALSE); myContent.contextPut("passed", Boolean.FALSE); myContent.contextPut("comment", null); myContent.contextPut("attempts", 0); } else { // block if test passed (and config set to check it) Boolean blockAfterSuccess = modConfig.getBooleanEntry(IQEditController.CONFIG_KEY_BLOCK_AFTER_SUCCESS); Boolean blocked = Boolean.FALSE; if (blockAfterSuccess != null && blockAfterSuccess.booleanValue()) { Boolean passed = assessmentEntry.getPassed(); if (passed != null && passed.booleanValue()) { blocked = Boolean.TRUE; } } myContent.contextPut("blockAfterSuccess", blocked); myContent.contextPut("score", AssessmentHelper.getRoundedScore(assessmentEntry.getScore())); myContent.contextPut( "hasPassedValue", (assessmentEntry.getPassed() == null ? Boolean.FALSE : Boolean.TRUE)); myContent.contextPut("passed", assessmentEntry.getPassed()); StringBuilder comment = Formatter.stripTabsAndReturns(assessmentEntry.getComment()); myContent.contextPut("comment", StringHelper.xssScan(comment)); myContent.contextPut("attempts", assessmentEntry.getAttempts()); } } UserNodeAuditManager am = userCourseEnv.getCourseEnvironment().getAuditManager(); myContent.contextPut("log", am.getUserNodeLog(courseNode, identity)); exposeResults(ureq); }
@Override public Object getValueAt(final int row, final int col) { final MediaFileElement entry = getEntryAt(row); switch (col) { case 0: final String filename = entry.getFilename(); if (filename.length() > 40) { if (filename.endsWith(WikiMainController.METADATA_SUFFIX)) { return entry.getFilename().substring(0, 40) + WikiMainController.METADATA_SUFFIX; } return entry.getFilename().substring(0, 40) + "..."; } return entry.getFilename(); case 1: final long identKey = entry.getCreatedBy(); if (identKey == 0) { return "---"; } return BaseSecurityManager.getInstance().loadIdentityByKey(identKey).getName(); case 2: return formatter.formatDateAndTime(new Date(entry.getCreationDate())); case 3: final long key = entry.getDeletedBy(); if (key == 0) { return "---"; } return BaseSecurityManager.getInstance().loadIdentityByKey(key).getName(); case 4: final long delDate = entry.getDeletionDate(); if (delDate == 0) { return "---"; } return formatter.formatDateAndTime(new Date(delDate)); default: return "ERROR"; } }
private void sendFeedback(List<BulkAssessmentFeedback> feedbacks) { if (task == null) { log.error("Haven't a task to know creator and modifiers of the task", null); return; } Identity creator = task.getCreator(); String language = creator.getUser().getPreferences().getLanguage(); Locale locale = I18nManager.getInstance().getLocaleOrDefault(language); Translator translator = Util.createPackageTranslator( BulkAssessmentOverviewController.class, locale, Util.createPackageTranslator(AssessmentManager.class, locale)); MailManager mailManager = CoreSpringFactory.getImpl(MailManager.class); TaskExecutorManager taskManager = CoreSpringFactory.getImpl(TaskExecutorManager.class); String feedbackStr = renderFeedback(feedbacks, translator); MailBundle mail = new MailBundle(); mail.setToId(creator); mail.setFrom(WebappHelper.getMailConfig("mailReplyTo")); List<Identity> modifiers = taskManager.getModifiers(task); if (modifiers.size() > 0) { ContactList cc = new ContactList("CC"); cc.addAllIdentites(modifiers); mail.setContactList(cc); } String businessPath = ""; ICourse course = CourseFactory.loadCourse(courseRes); CourseNode node = course.getRunStructure().getNode(courseNodeIdent); String courseTitle = course.getCourseTitle(); String nodeTitle = node.getShortTitle(); String numOfAssessedIds = Integer.toString(datas == null ? 0 : datas.getRowsSize()); String date = Formatter.getInstance(locale).formatDateAndTime(new Date()); mail.setContext(new MailContextImpl(courseRes, courseNodeIdent, businessPath)); String subject = translator.translate("confirmation.mail.subject", new String[] {courseTitle, nodeTitle}); String body = translator.translate( "confirmation.mail.body", new String[] {courseTitle, nodeTitle, feedbackStr, numOfAssessedIds, date}); mail.setContent(subject, body); mailManager.sendMessage(mail); }
/** * @see org.olat.course.nodes.GenericCourseNode#archiveNodeData(java.util.Locale, * org.olat.course.ICourse, java.io.File, java.lang.String) */ @Override public boolean archiveNodeData( final Locale locale, final ICourse course, final File exportDirectory, final String charset) { final String repoRef = (String) this.getModuleConfiguration().get("reporef"); final OLATResourceable ores = RepositoryManager.getInstance() .lookupRepositoryEntryBySoftkey(repoRef, true) .getOlatResource(); if (WikiManager.getInstance().getOrLoadWiki(ores).getAllPagesWithContent().size() > 0) { // OK, there is somthing to archive final VFSContainer exportContainer = new LocalFolderImpl(exportDirectory); VFSContainer wikiExportContainer = (VFSContainer) exportContainer.resolve(WikiManager.WIKI_RESOURCE_FOLDER_NAME); if (wikiExportContainer == null) { wikiExportContainer = exportContainer.createChildContainer(WikiManager.WIKI_RESOURCE_FOLDER_NAME); } final String exportDirName = getShortTitle() + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis())); final VFSContainer destination = wikiExportContainer.createChildContainer(exportDirName); if (destination == null) { Tracing.logError( "archiveNodeData: Could not create destination directory: wikiExportContainer=" + wikiExportContainer + ", exportDirName=" + exportDirName, getClass()); } final VFSContainer container = WikiManager.getInstance().getWikiContainer(ores, WikiManager.WIKI_RESOURCE_FOLDER_NAME); if (container != null) { // the container could be null if the wiki is an old empty one - so nothing to // archive final VFSContainer parent = container.getParentContainer(); final VFSLeaf wikiZip = WikiToZipUtils.getWikiAsZip(parent); destination.copyFrom(wikiZip); } return true; } // empty wiki, no need to archive return false; }
public AccessConfigurationController( UserRequest ureq, WindowControl wControl, OLATResource resource, String displayName, boolean allowPaymentMethod, boolean editable) { super(ureq, wControl, "access_configuration"); this.resource = resource; this.displayName = displayName; this.allowPaymentMethod = allowPaymentMethod; embbed = false; this.editable = editable; emptyConfigGrantsFullAccess = true; formatter = Formatter.getInstance(getLocale()); initForm(ureq); }
private void init(UserRequest ureq) { String artFulltextContent = ePFMgr.getArtefactFullTextContent(artefact); if (!readOnlyMode) { // prepare an edit link String fulltext = FilterFactory.getHtmlTagAndDescapingFilter().filter(artFulltextContent); fulltext = StringHelper.xssScan(fulltext); fulltext = Formatter.truncate(fulltext, 50); editBtn = LinkFactory.createCustomLink( "text.edit.link", "edit", fulltext, Link.NONTRANSLATED, vC, this); editBtn.setIconRightCSS("o_icon o_icon_inline_editable"); } else { // register a mapper to deliver uploaded media files final VFSContainer artefactFolder = ePFMgr.getArtefactContainer(artefact); String mapperBase = registerMapper(ureq, new VFSContainerMapper(artefactFolder)); Filter urlFilter = FilterFactory.getBaseURLToMediaRelativeURLFilter(mapperBase); String wrappedText = urlFilter.filter(artFulltextContent); vC.contextPut("text", wrappedText); } }
/** * Search in given text fragment for URL's and surround them with clickable HTML link objects. * * @param textFragment * @return text with clickable links */ public static String formatURLsAsLinks(String textFragment) { return Formatter.formatURLsAsLinks(textFragment); }
/** * Wrapp given html code with a wrapper an add code to transform latex formulas to nice visual * characters on the client side. The latex formulas must be within an HTML element that has the * class 'math' attached. * * @param htmlFragment A html element that might contain an element that has a class 'math' with * latex formulas * @return */ public static String formatLatexFormulas(String htmlFragment) { return Formatter.formatLatexFormulas(htmlFragment); }
public String formatBytes(long bytes) { return Formatter.formatBytes(bytes); }
public String formatDateAndTime(Date date) { Formatter f = Formatter.getInstance(renderer.getTranslator().getLocale()); return f.formatDateAndTime(date); }
/** * escapes " entities in \" * * @param in the string to convert * @deprecated please use escapeHtml. * @return the escaped string */ public String escapeDoubleQuotes(String in) { return Formatter.escapeDoubleQuotes(in).toString(); }
public MediaFilesTableModel(final List objects, final Translator trans) { super(objects); setLocale(trans.getLocale()); formatter = Formatter.getInstance(trans.getLocale()); }
public Object getValueAt(BGTableItem wrapped, int col) { switch (Cols.values()[col]) { case name: return wrapped; case description: String description = wrapped.getBusinessGroupDescription(); description = FilterFactory.getHtmlTagsFilter().filter(description); description = Formatter.truncate(description, 256); return description; case allowLeave: { Boolean allowed = wrapped.getAllowLeave(); if (allowed != null && allowed.booleanValue()) { // check managed groups if (BusinessGroupManagedFlag.isManaged( wrapped.getManagedFlags(), BusinessGroupManagedFlag.membersmanagement)) { return Boolean.FALSE; } } return allowed; } case allowDelete: { Boolean allowed = wrapped.getAllowDelete(); if (allowed != null && allowed.booleanValue()) { // check managed groups if (BusinessGroupManagedFlag.isManaged( wrapped.getManagedFlags(), BusinessGroupManagedFlag.delete)) { return Boolean.FALSE; } } return allowed; } case resources: return wrapped; case accessControl: return new Boolean(wrapped.isAccessControl()); case accessControlLaunch: return wrapped.getAccessLink(); case accessTypes: return wrapped.getAccessTypes(); case mark: return wrapped.getMarkLink(); case lastUsage: return wrapped.getBusinessGroupLastUsage(); case role: return wrapped.getMembership(); case firstTime: { BusinessGroupMembership membership = wrapped.getMembership(); return membership == null ? null : membership.getCreationDate(); } case lastTime: { BusinessGroupMembership membership = wrapped.getMembership(); return membership == null ? null : membership.getLastModified(); } case key: return wrapped.getBusinessGroupKey(); case freePlaces: { Integer maxParticipants = wrapped.getMaxParticipants(); if (maxParticipants != null && maxParticipants.intValue() >= 0) { long free = maxParticipants - (wrapped.getNumOfParticipants() + wrapped.getNumOfPendings()); return new GroupNumber(free); } return GroupNumber.INFINITE; } case participantsCount: { long count = wrapped.getNumOfParticipants() + wrapped.getNumOfPendings(); return count < 0 ? GroupNumber.ZERO : new GroupNumber(count); } case tutorsCount: { long count = wrapped.getNumOfOwners(); return count < 0 ? GroupNumber.ZERO : new GroupNumber(count); } case waitingListCount: { if (wrapped.isWaitingListEnabled()) { long count = wrapped.getNumWaiting(); return count < 0 ? GroupNumber.ZERO : new GroupNumber(count); } return GroupNumber.NONE; } case wrapper: return wrapped; case externalId: return wrapped.getBusinessGroupExternalId(); case unlink: { boolean managed = BusinessGroupManagedFlag.isManaged( wrapped.getManagedFlags(), BusinessGroupManagedFlag.resources); return managed ? Boolean.FALSE : Boolean.TRUE; } default: return "ERROR"; } }