/** * @param ureq * @param wControl * @param cancelbutton */ public ReadyToDeleteController(UserRequest ureq, WindowControl wControl) { super(ureq, wControl); Translator fallbackTrans = Util.createPackageTranslator(UserSearchController.class, ureq.getLocale()); setTranslator( Util.createPackageTranslator( ReadyToDeleteController.class, ureq.getLocale(), fallbackTrans)); // use the PropertyHandlerTranslator as tableCtr translator propertyHandlerTranslator = UserManager.getInstance().getPropertyHandlerTranslator(getTranslator()); myContent = createVelocityContainer("panel"); readyToDeletePanel = new Panel("readyToDeletePanel"); readyToDeletePanel.addListener(this); myContent.put("panel", readyToDeletePanel); Roles roles = ureq.getUserSession().getRoles(); isAdministrativeUser = CoreSpringFactory.getImpl(BaseSecurityModule.class).isUserAllowedAdminProps(roles); // (roles.isAuthor() || roles.isGroupManager() || roles.isUserManager() || roles.isOLATAdmin()); initializeTableController(ureq); initializeContent(); putInitialPanel(myContent); }
@Override @SuppressWarnings("unused") protected boolean validateFormLogic(UserRequest ureq) { boolean retVal = true; // datefields are valid // check complex rules involving checks over multiple elements Date fromDateVal = fromDate.getDate(); Date toDateVal = toDate.getDate(); if (!fromDate.hasError() && !toDate.hasError()) { // check valid dates // if both are set, check from < to if (fromDateVal != null && toDateVal != null) { /* * bugfix http://bugs.olat.org/jira/browse/OLAT-813 valid dates and not * empty, in easy mode we assume that Start and End date should * implement the meaning of * ----false---|S|-----|now|-TRUE---------|E|---false--->t ............. * Thus we check for Startdate < Enddate, error otherwise */ if (fromDateVal.after(toDateVal)) { fromDate.setTranslator( Util.createPackageTranslator( org.olat.course.condition.Condition.class, ureq.getLocale(), fromDate.getTranslator())); fromDate.setErrorKey("form.easy.error.bdateafteredate", null); retVal = false; } } else { if (fromDateVal == null && !fromDate.isEmpty()) { // not a correct begin date fromDate.setTranslator( Util.createPackageTranslator( org.olat.course.condition.Condition.class, ureq.getLocale(), fromDate.getTranslator())); fromDate.setErrorKey("form.easy.error.bdate", null); retVal = false; } if (toDateVal == null && !toDate.isEmpty()) { toDate.setTranslator( Util.createPackageTranslator( org.olat.course.condition.Condition.class, ureq.getLocale(), toDate.getTranslator())); toDate.setErrorKey("form.easy.error.edate", null); retVal = false; } } } return retVal; }
/** * @see org.olat.login.auth.AuthenticationController#init(org.olat.core.gui.UserRequest, * org.olat.core.gui.control.WindowControl) */ public OLATAuthenticationController(UserRequest ureq, WindowControl winControl) { // use fallback translator to registration module super( ureq, winControl, Util.createPackageTranslator(RegistrationManager.class, ureq.getLocale())); loginComp = createVelocityContainer("olat_log", "olatlogin"); if (userModule.isAnyPasswordChangeAllowed()) { pwLink = LinkFactory.createLink("_olat_login_change_pwd", "menu.pw", loginComp, this); pwLink.setElementCssClass("o_login_pwd"); } if (registrationModule.isSelfRegistrationEnabled() && registrationModule.isSelfRegistrationLoginEnabled()) { registerLink = LinkFactory.createLink("_olat_login_register", "menu.register", loginComp, this); registerLink.setElementCssClass("o_login_register"); registerLink.setTitle("menu.register.alt"); } // prepare login form loginForm = new OLATAuthentcationForm(ureq, winControl, "olat_login", getTranslator()); listenTo(loginForm); loginComp.put("loginForm", loginForm.getInitialComponent()); // Check if form is triggered by external loginworkflow that has been failed if (ureq.getParameterSet().contains(PARAM_LOGINERROR)) { showError(translate("login.error", WebappHelper.getMailConfig("mailReplyTo"))); } putInitialPanel(loginComp); }
public OverviewAuthoringController(UserRequest ureq, WindowControl wControl) { super(ureq, wControl); setTranslator( Util.createPackageTranslator(RepositoryManager.class, getLocale(), getTranslator())); isGuestonly = ureq.getUserSession().getRoles().isGuestOnly(); mainPanel = new MainPanel("authoringMainPanel"); mainPanel.setDomReplaceable(false); mainVC = createVelocityContainer("overview"); mainPanel.setContent(mainVC); segmentView = SegmentViewFactory.createSegmentView("segments", mainVC, this); segmentView.setReselect(true); if (!isGuestonly) { favoriteLink = LinkFactory.createLink("search.mark", mainVC, this); segmentView.addSegment(favoriteLink, false); } myEntriesLink = LinkFactory.createLink("search.my", mainVC, this); segmentView.addSegment(myEntriesLink, false); searchLink = LinkFactory.createLink("search.generic", mainVC, this); segmentView.addSegment(searchLink, false); putInitialPanel(mainPanel); }
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); }
public QTI12MetadataController(UserRequest ureq, WindowControl wControl, Item item) { super(ureq, wControl, "qti_metadatas"); setTranslator( Util.createPackageTranslator( ItemNodeTabbedFormController.class, getLocale(), getTranslator())); this.item = item; initForm(ureq); }
// constructor to be used like a normal FormBasicController public GroupSearchController(UserRequest ureq, WindowControl wControl) { super(ureq, wControl, LAYOUT_VERTICAL); businessGroupService = CoreSpringFactory.getImpl(BusinessGroupService.class); Translator pT = Util.createPackageTranslator( BusinessGroupFormController.class, ureq.getLocale(), getTranslator()); flc.setTranslator(pT); initForm(ureq); }
public FreeAccessConfigurationController( UserRequest ureq, WindowControl wControl, OfferAccess link, boolean edit) { super(ureq, wControl, edit); this.link = link; setTranslator( Util.createPackageTranslator( AccessConfigurationController.class, getLocale(), getTranslator())); initForm(ureq); }
public EducationalMetadataController( UserRequest ureq, WindowControl wControl, QuestionItem item, boolean edit) { super(ureq, wControl, "view"); setTranslator( Util.createPackageTranslator(QuestionsController.class, getLocale(), getTranslator())); this.edit = edit; initForm(ureq); setItem(item); }
public CcStep01Form( UserRequest ureq, WindowControl wControl, Form rootForm, StepsRunContext runContext, String customLayoutPageName) { super(ureq, wControl, rootForm, runContext, LAYOUT_VERTICAL, customLayoutPageName); translator = Util.createPackageTranslator(CourseCreationHelper.class, ureq.getLocale()); super.setTranslator(translator); initForm(ureq); }
public ConfirmCloseController( UserRequest ureq, WindowControl wControl, List<RepositoryEntry> rows) { super( ureq, wControl, "confirm_close", Util.createPackageTranslator(RepositoryService.class, ureq.getLocale())); numOfMembers = repositoryService.countMembers(rows, getIdentity()); this.rows = rows; initForm(ureq); }
/** * Constructor for a test run controller * * @param userCourseEnv * @param moduleConfiguration * @param secCallback * @param ureq * @param wControl * @param testCourseNode */ public IQRunController( UserCourseEnvironment userCourseEnv, ModuleConfiguration moduleConfiguration, IQSecurityCallback secCallback, UserRequest ureq, WindowControl wControl, IQTESTCourseNode testCourseNode, RepositoryEntry testEntry) { super(ureq, wControl, Util.createPackageTranslator(CourseNode.class, ureq.getLocale())); this.modConfig = moduleConfiguration; this.secCallback = secCallback; this.userCourseEnv = userCourseEnv; this.courseNode = testCourseNode; this.type = AssessmentInstance.QMD_ENTRY_TYPE_ASSESS; this.singleUserEventCenter = ureq.getUserSession().getSingleUserEventCenter(); this.referenceTestEntry = testEntry; this.userSession = ureq.getUserSession(); addLoggingResourceable(LoggingResourceable.wrap(courseNode)); myContent = createVelocityContainer("testrun"); mainPanel = putInitialPanel(myContent); if (!modConfig .get(IQEditController.CONFIG_KEY_TYPE) .equals(AssessmentInstance.QMD_ENTRY_TYPE_ASSESS)) { throw new OLATRuntimeException( "IQRunController launched with Test constructor but module configuration not configured as test", null); } init(ureq); exposeUserTestDataToVC(ureq); StringBuilder qtiChangelog = createChangelogMsg(ureq); // decide about changelog in VC if (qtiChangelog.length() > 0) { // there is some message myContent.contextPut("changeLog", qtiChangelog); } // if show results on test home page configured - show log Boolean showResultOnHomePage = testCourseNode .getModuleConfiguration() .getBooleanEntry(IQEditController.CONFIG_KEY_RESULT_ON_HOME_PAGE); myContent.contextPut("showChangelog", showResultOnHomePage); }
/** * @see * org.olat.repository.handlers.RepositoryHandler#readyToDelete(org.olat.core.id.OLATResourceable, * org.olat.core.gui.UserRequest, org.olat.core.gui.control.WindowControl) */ @Override public boolean readyToDelete( final OLATResourceable res, final UserRequest ureq, final WindowControl wControl) { final ReferenceManager refM = ReferenceManager.getInstance(); final String referencesSummary = refM.getReferencesToSummary(res, ureq.getLocale()); if (referencesSummary != null) { final Translator translator = Util.createPackageTranslator(RepositoryManager.class, ureq.getLocale()); wControl.setError( translator.translate( "details.delete.error.references", new String[] {referencesSummary})); return false; } return true; }
@Override public String createTitleInfo(Subscriber subscriber, Locale locale) { try { Long resId = subscriber.getPublisher().getResId(); String displayName = RepositoryManager.getInstance().lookupDisplayNameByOLATResourceableId(resId); Translator trans = Util.createPackageTranslator(AssessmentNotificationsHandler.class, locale); String title = trans.translate("notifications.title", new String[] {displayName}); return title; } catch (Exception e) { log.error( "Error while creating assessment notifications for subscriber: " + subscriber.getKey(), e); checkPublisher(subscriber.getPublisher()); return "-"; } }
// cluster_ok only in VM public static synchronized LocalizedXSLTransformer getInstance(final Locale locale) { LocalizedXSLTransformer instance = instanceHash.get(I18nManager.getInstance().getLocaleKey(locale)); if (instance == null) { final Translator trans = Util.createPackageTranslator(QTIResultDetailsController.class, locale); final LocalizedXSLTransformer newInstance = new LocalizedXSLTransformer(trans); instance = instanceHash.putIfAbsent( I18nManager.getInstance().getLocaleKey(locale), newInstance); // see javadoc of ConcurrentHashMap if (instance == null) { // newInstance was put into the map instance = newInstance; } } return instance; }
public JSRedirectWindowController(UserRequest ureq) { Translator trans = Util.createPackageTranslator(JSRedirectWindowController.class, ureq.getLocale()); VelocityContainer msg = new VelocityContainer("jsredirect", VELOCITY_ROOT + "/js_redirect.html", trans, this); String callbackUrl = Settings.getServerContextPathURI() + OAuthConstants.CALLBACK_PATH; msg.contextPut("callbackUrl", callbackUrl); Windows ws = Windows.getWindows(ureq); WindowBackOffice wbo = ws.getWindowManager() .createWindowBackOffice("jsredirectwindow", this, new WindowSettings()); Window w = wbo.getWindow(); msg.contextPut("theme", w.getGuiTheme()); w.setContentPane(msg); setWindow(w); }
/** * Constructor for a survey run controller * * @param userCourseEnv * @param moduleConfiguration * @param secCallback * @param ureq * @param wControl * @param surveyCourseNode */ public IQRunController( UserCourseEnvironment userCourseEnv, ModuleConfiguration moduleConfiguration, IQSecurityCallback secCallback, UserRequest ureq, WindowControl wControl, IQSURVCourseNode surveyCourseNode) { super(ureq, wControl, Util.createPackageTranslator(CourseNode.class, ureq.getLocale())); this.modConfig = moduleConfiguration; this.secCallback = secCallback; this.userCourseEnv = userCourseEnv; this.courseNode = surveyCourseNode; this.referenceTestEntry = surveyCourseNode.getReferencedRepositoryEntry(); this.type = AssessmentInstance.QMD_ENTRY_TYPE_SURVEY; this.singleUserEventCenter = ureq.getUserSession().getSingleUserEventCenter(); iqManager = CoreSpringFactory.getImpl(IQManager.class); addLoggingResourceable(LoggingResourceable.wrap(courseNode)); myContent = createVelocityContainer("surveyrun"); mainPanel = putInitialPanel(myContent); if (!modConfig .get(IQEditController.CONFIG_KEY_TYPE) .equals(AssessmentInstance.QMD_ENTRY_TYPE_SURVEY)) { throw new OLATRuntimeException( "IQRunController launched with Survey constructor but module configuration not configured as survey", null); } init(ureq); exposeUserQuestionnaireDataToVC(); StringBuilder qtiChangelog = createChangelogMsg(ureq); // decide about changelog in VC if (qtiChangelog.length() > 0) { // there is some message myContent.contextPut("changeLog", qtiChangelog); } // per default change log is not open myContent.contextPut("showChangelog", Boolean.FALSE); }
/** * @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, * org.olat.core.gui.components.Component, org.olat.core.gui.control.Event) */ public void event(UserRequest ureq, Component source, Event event) { if (source == showFileButton) { ICourse course = CourseFactory.loadCourse(ores); String personalFolderDir = CourseFactory.getPersonalDirectory(ureq.getIdentity()).getPath(); String targetDir = CourseFactory.getOrCreateDataExportDirectory(ureq.getIdentity(), course.getCourseTitle()) .getPath(); String relPath = ""; if (targetDir.startsWith(personalFolderDir)) { // that should always be the case relPath = targetDir.substring(personalFolderDir.length()).replace("\\", "/"); targetDir = targetDir.substring(0, personalFolderDir.length()); } VFSContainer targetFolder = new LocalFolderImpl(new File(targetDir)); FolderRunController bcrun = new FolderRunController(targetFolder, true, ureq, getWindowControl()); Component folderComponent = bcrun.getInitialComponent(); if (relPath.length() != 0) { if (!relPath.endsWith("/")) { relPath = relPath + "/"; } bcrun.activatePath(ureq, relPath); } String personalFolder = Util.createPackageTranslator(HomeMainController.class, ureq.getLocale(), null) .translate("menu.bc"); removeAsListenerAndDispose(cmc); cmc = new CloseableModalController( getWindowControl(), translate("close"), folderComponent, true, personalFolder); listenTo(cmc); cmc.activate(); } }
/** * @see * org.olat.core.commons.services.notifications.NotificationsHandler#createSubscriptionInfo(org.olat.core.commons.services.notifications.Subscriber, * java.util.Locale, java.util.Date) */ public SubscriptionInfo createSubscriptionInfo( final Subscriber subscriber, Locale locale, Date compareDate) { SubscriptionInfo si = null; Publisher p = subscriber.getPublisher(); if (!NotificationsUpgradeHelper.checkCourse(p)) { // course don't exist anymore NotificationsManager.getInstance().deactivate(p); return NotificationsManager.getInstance().getNoSubscriptionInfo(); } try { Date latestNews = p.getLatestNewsDate(); Identity identity = subscriber.getIdentity(); // do not try to create a subscription info if state is deleted - results in // exceptions, course // can't be loaded when already deleted if (NotificationsManager.getInstance().isPublisherValid(p) && compareDate.before(latestNews)) { Long courseId = new Long(p.getData()); final ICourse course = loadCourseFromId(courseId); if (course != null) { // course admins or users with the course right to have full access to // the assessment tool will have full access to user tests CourseGroupManager cgm = course.getCourseEnvironment().getCourseGroupManager(); final boolean hasFullAccess = (cgm.isIdentityCourseAdministrator(identity) ? true : cgm.hasRight(identity, CourseRights.RIGHT_ASSESSMENT)); final List<Identity> coachedUsers = new ArrayList<Identity>(); if (!hasFullAccess) { // initialize list of users, only when user has not full access List<BusinessGroup> coachedGroups = cgm.getOwnedBusinessGroups(identity); BusinessGroupService businessGroupService = CoreSpringFactory.getImpl(BusinessGroupService.class); List<Identity> coachedIdentites = businessGroupService.getMembers(coachedGroups, GroupRoles.participant.name()); coachedUsers.addAll(coachedIdentites); } List<AssessableCourseNode> testNodes = getCourseTestNodes(course); Translator translator = Util.createPackageTranslator(AssessmentNotificationsHandler.class, locale); for (AssessableCourseNode test : testNodes) { final CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager(); List<Property> scoreProperties = cpm.listCourseNodeProperties(test, null, null, AssessmentManager.SCORE); List<Property> attemptProperties = cpm.listCourseNodeProperties(test, null, null, AssessmentManager.ATTEMPTS); for (Property attemptProperty : attemptProperties) { Date modDate = attemptProperty.getLastModified(); Identity assessedIdentity = attemptProperty.getIdentity(); if (modDate.after(compareDate) && (hasFullAccess || PersistenceHelper.listContainsObjectByKey( coachedUsers, assessedIdentity))) { String score = null; for (Property scoreProperty : scoreProperties) { if (scoreProperty.getIdentity().equalsByPersistableKey(assessedIdentity)) { score = scoreProperty.getFloatValue().toString(); break; } } if (test instanceof ScormCourseNode) { ScormCourseNode scormTest = (ScormCourseNode) test; // check if completed or passed String status = ScormAssessmentManager.getInstance() .getLastLessonStatus( assessedIdentity.getName(), course.getCourseEnvironment(), scormTest); if (!"passed".equals(status) && !"completed".equals(status)) { continue; } } String desc; String type = translator.translate("notifications.entry." + test.getType()); if (score == null) { desc = translator.translate( "notifications.entry.attempt", new String[] { test.getShortTitle(), NotificationHelper.getFormatedName(assessedIdentity), type }); } else { desc = translator.translate( "notifications.entry", new String[] { test.getShortTitle(), NotificationHelper.getFormatedName(assessedIdentity), score, type }); } String urlToSend = null; String businessPath = null; if (p.getBusinessPath() != null) { businessPath = p.getBusinessPath() + "[assessmentTool:0][Identity:" + assessedIdentity.getKey() + "][CourseNode:" + test.getIdent() + "]"; urlToSend = BusinessControlFactory.getInstance() .getURLFromBusinessPathString(businessPath); } SubscriptionListItem subListItem = new SubscriptionListItem( desc, urlToSend, businessPath, modDate, CSS_CLASS_USER_ICON); if (si == null) { String title = translator.translate( "notifications.header", new String[] {course.getCourseTitle()}); String css = CourseNodeFactory.getInstance() .getCourseNodeConfigurationEvenForDisabledBB(test.getType()) .getIconCSSClass(); si = new SubscriptionInfo( subscriber.getKey(), p.getType(), new TitleItem(title, css), null); } si.addSubscriptionListItem(subListItem); } } } } } if (si == null) { si = NotificationsManager.getInstance().getNoSubscriptionInfo(); } return si; } catch (Exception e) { log.error("Error while creating assessment notifications", e); checkPublisher(p); return NotificationsManager.getInstance().getNoSubscriptionInfo(); } }
/** * @param name component name of form * @param quota the quota used to initialize the form or null if empty form is used */ public BGConfigQuotaController(UserRequest ureq, WindowControl wControl, Quota quota) { super(ureq, wControl); setTranslator(Util.createPackageTranslator(QuotaForm.class, getLocale(), getTranslator())); this.quota = quota; initForm(ureq); }
/** init string buffer */ protected ForumFormatter(Locale locale) { sb = new StringBuilder(4096); translator = Util.createPackageTranslator(Forum.class, locale); }
public String getLinkText(Locale locale) { Translator fallback = Util.createPackageTranslator(CourseNodeConfiguration.class, locale); Translator translator = Util.createPackageTranslator(this.getClass(), locale, fallback); return translator.translate("title_vc"); }
/** * @see * org.olat.core.gui.components.form.flexible.impl.FormBasicController#initForm(org.olat.core.gui.components.form.flexible.FormItemContainer, * org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest) */ @Override protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { // Create the business group name input text element if (bulkMode) { businessGroupName = uifactory.addTextElement( "create.form.title.bgnames", "create.form.title.bgnames", 10 * BusinessGroup.MAX_GROUP_NAME_LENGTH, "", formLayout); businessGroupName.setExampleKey("create.form.message.example.group", null); } else { businessGroupName = uifactory.addTextElement( "create.form.title.bgname", "create.form.title.bgname", BusinessGroup.MAX_GROUP_NAME_LENGTH, "", formLayout); businessGroupName.setNotLongerThanCheck( BusinessGroup.MAX_GROUP_NAME_LENGTH, "create.form.error.nameTooLong"); businessGroupName.setRegexMatchCheck( BusinessGroup.VALID_GROUPNAME_REGEXP, "create.form.error.illegalName"); } businessGroupName.setElementCssClass("o_sel_group_edit_title"); businessGroupName.setMandatory(true); businessGroupName.setEnabled( !BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.title)); formLayout.setElementCssClass("o_sel_group_edit_group_form"); // Create the business group description input rich text element businessGroupDescription = uifactory.addRichTextElementForStringDataMinimalistic( "create.form.title.description", "create.form.title.description", "", 10, -1, formLayout, getWindowControl()); businessGroupDescription.setEnabled( !BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.description)); if (businessGroup != null && !bulkMode) { // link to group direct jump in business path BusinessControlFactory bcf = BusinessControlFactory.getInstance(); List<ContextEntry> entries = bcf.createCEListFromString("[BusinessGroup:" + businessGroup.getKey() + "]"); String url = bcf.getAsURIString(entries, true); StaticTextElement urlEl = uifactory.addStaticTextElement("create.form.businesspath", url, formLayout); urlEl.setElementCssClass("o_sel_group_url"); // link to group visiting card bcf = BusinessControlFactory.getInstance(); entries = bcf.createCEListFromString("[GroupCard:" + businessGroup.getKey() + "]"); url = bcf.getAsURIString(entries, true); StaticTextElement cardEl = uifactory.addStaticTextElement("create.form.groupcard", url, formLayout); cardEl.setElementCssClass("o_sel_group_card_url"); } uifactory.addSpacerElement("myspacer", formLayout, true); // Minimum members input businessGroupMinimumMembers = uifactory.addTextElement( "create.form.title.min", "create.form.title.min", 5, "", formLayout); businessGroupMinimumMembers.setDisplaySize(6); businessGroupMinimumMembers.setVisible(false); // currently the minimum feature is not enabled businessGroupMinimumMembers.setElementCssClass("o_sel_group_edit_min_members"); // Maximum members input businessGroupMaximumMembers = uifactory.addTextElement( "create.form.title.max", "create.form.title.max", 5, "", formLayout); businessGroupMaximumMembers.setDisplaySize(6); businessGroupMaximumMembers.setElementCssClass("o_sel_group_edit_max_members"); // Checkboxes enableWaitingList = uifactory.addCheckboxesHorizontal( "create.form.enableWaitinglist", null, formLayout, waitingListKeys, waitingListValues); enableWaitingList.setElementCssClass("o_sel_group_edit_waiting_list"); enableAutoCloseRanks = uifactory.addCheckboxesHorizontal( "create.form.enableAutoCloseRanks", null, formLayout, autoCloseKeys, autoCloseValues); enableAutoCloseRanks.setElementCssClass("o_sel_group_edit_auto_close_ranks"); // Enable only if specification of min and max members is possible businessGroupMinimumMembers.setVisible(false); // currently the minimum feature is not enabled businessGroupMaximumMembers.setVisible(true); enableWaitingList.setVisible(true); enableAutoCloseRanks.setVisible(true); boolean managedSettings = BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.settings); businessGroupMinimumMembers.setEnabled(!managedSettings); businessGroupMaximumMembers.setEnabled(!managedSettings); enableWaitingList.setEnabled(!managedSettings); enableAutoCloseRanks.setEnabled(!managedSettings); if ((businessGroup != null) && (!bulkMode)) { businessGroupName.setValue(businessGroup.getName()); businessGroupDescription.setValue(businessGroup.getDescription()); Integer minimumMembers = businessGroup.getMinParticipants(); Integer maximumMembers = businessGroup.getMaxParticipants(); businessGroupMinimumMembers.setValue( minimumMembers == null || minimumMembers.intValue() <= 0 ? "" : minimumMembers.toString()); businessGroupMaximumMembers.setValue( maximumMembers == null || maximumMembers.intValue() < 0 ? "" : maximumMembers.toString()); if (businessGroup.getWaitingListEnabled() != null) { enableWaitingList.select( "create.form.enableWaitinglist", businessGroup.getWaitingListEnabled()); } if (businessGroup.getAutoCloseRanksEnabled() != null) { enableAutoCloseRanks.select( "create.form.enableAutoCloseRanks", businessGroup.getAutoCloseRanksEnabled()); } } if (!embbeded) { // Create submit and cancel buttons final FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("buttonLayout", getTranslator()); formLayout.add(buttonLayout); FormSubmit submit = uifactory.addFormSubmitButton("finish", buttonLayout); submit.setEnabled( !BusinessGroupManagedFlag.isManaged(businessGroup, BusinessGroupManagedFlag.details)); uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl()); } if ((businessGroup != null) && (!bulkMode)) { // managed group information boolean managed = StringHelper.containsNonWhitespace(businessGroup.getExternalId()) || businessGroup.getManagedFlags().length > 0; if (managed) { uifactory.addSpacerElement("managedspacer", formLayout, false); String extId = businessGroup.getExternalId() == null ? "" : businessGroup.getExternalId(); StaticTextElement externalIdEl = uifactory.addStaticTextElement("create.form.externalid", extId, formLayout); externalIdEl.setElementCssClass("o_sel_group_external_id"); FormLayoutContainer flagsFlc = FormLayoutContainer.createHorizontalFormLayout("flc_flags", getTranslator()); flagsFlc.setLabel("create.form.managedflags", null); formLayout.add(flagsFlc); String flags = businessGroup.getManagedFlagsString() == null ? "" : businessGroup.getManagedFlagsString().trim(); String flagsFormatted = null; if (flags.length() > 0) { // use translator from REST admin package to import managed flags context help strings Translator managedTrans = Util.createPackageTranslator(RestapiAdminController.class, ureq.getLocale()); StringBuffer flagList = new StringBuffer(); flagList.append("<p class=\"o_important\">"); flagList.append(translate("create.form.managedflags.intro")); flagList.append("</div>"); flagList.append("<ul>"); for (String flag : flags.split(",")) { flagList.append("<li>"); flagList.append(managedTrans.translate("managed.flags.group." + flag)); flagList.append("</li>"); } flagsFormatted = flagList.toString(); } else { flagsFormatted = flags; } StaticTextElement flagsEl = uifactory.addStaticTextElement("create.form.managedflags", flagsFormatted, flagsFlc); flagsEl.showLabel(false); flagsEl.setElementCssClass("o_sel_group_managed_flags"); } } }
/** * Test methods i18nManager inline translation tool and * InlineTranslationInterceptHandlerController */ @Test public void testInlineTranslationReplaceLocalizationMarkupWithHTML() { // enable inline translation markup i18nMgr.setMarkLocalizedStringsEnabled(null, true); Translator inlineTrans = Util.createPackageTranslator( InlineTranslationInterceptHandlerController.class, i18nMgr.getLocaleOrNull("de")); URLBuilder inlineTranslationURLBuilder = new jUnitURLBuilder(); String testBundle = "org.olat.core.util.i18n.junittestdata"; String testKey = "no.need.to.translate.this"; String rawtext1 = "Lorem impsum<b>nice stuff</b>"; String rawtext2 = "Holderadio <ul>lsdfsdf<y asdf blblb"; String combinedKey = testBundle + ":" + testKey; // test method that adds identifyers around the translation items String plainVanillaWrapped = i18nMgr.getLocalizedString( testBundle, testKey, null, i18nMgr.getLocaleOrNull("de"), false, false); String plainVanillaPlain = "just a test"; Pattern plainVanillaWrappedPattern = Pattern.compile( I18nManager.IDENT_PREFIX + combinedKey + ":([0-9]*?)" + I18nManager.IDENT_START_POSTFIX + plainVanillaPlain + I18nManager.IDENT_PREFIX + combinedKey + ":\\1" + I18nManager.IDENT_END_POSTFIX); Matcher m = plainVanillaWrappedPattern.matcher(plainVanillaWrapped); assertTrue(m.find()); // test find-replace translator identifyers with HTML markup StringOutput inlineTransLink = new StringOutput(); String[] args = (combinedKey + ":1000000001").split(":"); InlineTranslationInterceptHandlerController.buildInlineTranslationLink( args, inlineTransLink, inlineTrans, inlineTranslationURLBuilder); // Plain vanilla text String convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML( plainVanillaWrapped, inlineTranslationURLBuilder, inlineTrans); assertEquals( "<span class=\"b_translation_i18nitem\">" + inlineTransLink.toString() + plainVanillaPlain + "</span>", convertedToHTMLMarkup); // Simple link String linkOPEN = "<a href=\"http://www.olat.org/bla/blu:bli#bla\" title='funny title' class=\"b_css b_anothercss\">"; String linkCLOSE = "</a>"; String inlineSpanOPEN = "<span class=\"b_translation_i18nitem\">"; String inlineSpanCLOSE = "</span>"; String translatedWithinLink = linkOPEN + plainVanillaWrapped + linkCLOSE + rawtext1; convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML( translatedWithinLink, inlineTranslationURLBuilder, inlineTrans); String convertedWithinLinkExpected = inlineSpanOPEN + inlineTransLink.toString() + linkOPEN + plainVanillaPlain + linkCLOSE + inlineSpanCLOSE + rawtext1; assertEquals(convertedWithinLinkExpected, convertedToHTMLMarkup); // Simple link with span String linkSpanOPEN = "<span class=\"bluber\">"; String linkSpanCLOSE = "</span>"; String translatedWithinLinkAndSpan = rawtext2 + linkOPEN + linkSpanOPEN + plainVanillaWrapped + linkSpanCLOSE + linkCLOSE; convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML( translatedWithinLinkAndSpan, inlineTranslationURLBuilder, inlineTrans); String convertedWithinLinkAndSpanExpected = rawtext2 + inlineSpanOPEN + inlineTransLink.toString() + linkOPEN + linkSpanOPEN + plainVanillaPlain + linkSpanCLOSE + linkCLOSE + inlineSpanCLOSE; assertEquals(convertedWithinLinkAndSpanExpected, convertedToHTMLMarkup); // Muliple links String translatedWithinMultipleLinks = translatedWithinLink + translatedWithinLinkAndSpan + translatedWithinLinkAndSpan; convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML( translatedWithinMultipleLinks, inlineTranslationURLBuilder, inlineTrans); String convertedWithinMultipleLinksExpected = convertedWithinLinkExpected + convertedWithinLinkAndSpanExpected + convertedWithinLinkAndSpanExpected; assertEquals(convertedWithinMultipleLinksExpected, convertedToHTMLMarkup); // Input elements String inputOPEN = "<input type='submit' class=\"bluber\" value=\""; String inputCLOSE = "\" />"; String translatedWithinInput = inputOPEN + plainVanillaWrapped + inputCLOSE + rawtext1; convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML( translatedWithinInput, inlineTranslationURLBuilder, inlineTrans); String convertedWithinInputExpected = inlineSpanOPEN + inlineTransLink.toString() + inputOPEN + plainVanillaPlain + inputCLOSE + inlineSpanCLOSE + rawtext1; assertEquals(convertedWithinInputExpected, convertedToHTMLMarkup); // checkbox elements String checkboxOPEN = "<input type='submit' class=\"bluber\" type=\"checkbox\" value=\""; String checkboxCLOSE = "\" />"; String translatedWithinCheckbox = checkboxOPEN + plainVanillaWrapped + checkboxCLOSE + rawtext1; convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML( translatedWithinCheckbox, inlineTranslationURLBuilder, inlineTrans); String convertedWithinCheckboxExpected = checkboxOPEN + plainVanillaPlain + checkboxCLOSE + rawtext1; assertEquals(convertedWithinCheckboxExpected, convertedToHTMLMarkup); // Input and links mixed String translatedWithinMultipleLinksAndInput = translatedWithinLink + rawtext1 + translatedWithinInput + translatedWithinLinkAndSpan + rawtext2 + translatedWithinInput + translatedWithinLinkAndSpan; convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML( translatedWithinMultipleLinksAndInput, inlineTranslationURLBuilder, inlineTrans); String convertedWithinMultipleLinksAndInputExpected = convertedWithinLinkExpected + rawtext1 + convertedWithinInputExpected + convertedWithinLinkAndSpanExpected + rawtext2 + convertedWithinInputExpected + convertedWithinLinkAndSpanExpected; assertEquals(convertedWithinMultipleLinksAndInputExpected, convertedToHTMLMarkup); // Within element attribute String attributeOPEN = "<a href='sdfsdf' title=\""; String attributeCLOSE = "\" class=\"b_bluber\">hello world</a>"; String translatedWithinAttribute = attributeOPEN + plainVanillaWrapped + attributeCLOSE + rawtext1; convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML( translatedWithinAttribute, inlineTranslationURLBuilder, inlineTrans); String convertedWithinAttributeExpected = attributeOPEN + plainVanillaPlain + attributeCLOSE + rawtext1; assertEquals(convertedWithinAttributeExpected, convertedToHTMLMarkup); // Ultimate test String translatedUltimate = translatedWithinMultipleLinksAndInput + rawtext1 + translatedWithinAttribute + translatedWithinMultipleLinksAndInput + rawtext2 + translatedWithinInput + translatedWithinLinkAndSpan; convertedToHTMLMarkup = InlineTranslationInterceptHandlerController.replaceLocalizationMarkupWithHTML( translatedUltimate, inlineTranslationURLBuilder, inlineTrans); String convertedUltimateExpected = convertedWithinMultipleLinksAndInputExpected + rawtext1 + convertedWithinAttributeExpected + convertedWithinMultipleLinksAndInputExpected + rawtext2 + convertedWithinInputExpected + convertedWithinLinkAndSpanExpected; assertEquals(convertedUltimateExpected, convertedToHTMLMarkup); // don't do inline translation markup i18nMgr.setMarkLocalizedStringsEnabled(null, false); }
@Override public String getLinkText(final Locale locale) { final Translator fallback = Util.createPackageTranslator(CourseNodeConfiguration.class, locale); final Translator translator = Util.createPackageTranslator(this.getClass(), locale, fallback); return translator.translate("title_den"); }