Ejemplo n.º 1
0
 /** Cannot filters XSS out because it escapes the umlauts as well. */
 public String getQuery() {
   String query = searchQuery.getValue();
   searchQuery.setValue(null);
   // if (query != null) {
   // query = FilterFactory.filterXSS(query);
   // }
   return query;
 }
Ejemplo n.º 2
0
  @Override
  protected boolean validateFormLogic(final UserRequest ureq) {
    boolean isValidPageName = WikiInputValidation.validatePageName(searchQuery.getValue());

    if (isValidPageName) {
      return true;
    }

    searchQuery.setErrorKey("navigation.create.article.validation.error", null);
    searchQuery.showError(true);
    return false;
  }
  /**
   * org.olat.presentation.framework.control.Controller,
   * org.olat.presentation.framework.UserRequest)
   */
  @Override
  protected void initForm(
      final FormItemContainer formLayout, final Controller listener, final UserRequest ureq) {
    emailOrUsername =
        uifactory.addTextElement("emailOrUsername", "email.or.username", -1, null, formLayout);
    emailOrUsername.setMandatory(true);
    emailOrUsername.setNotEmptyCheck("email.or.username.maynotbeempty");

    final FormLayoutContainer buttonLayout =
        FormLayoutContainer.createButtonLayout("button_layout", getTranslator());
    this.flc.add(buttonLayout);
    uifactory.addFormSubmitButton("submit", buttonLayout);
    uifactory.addFormCancelButton("cancel", buttonLayout, ureq, getWindowControl());
  }
Ejemplo n.º 4
0
  /**
   * org.olat.presentation.framework.control.Controller,
   * org.olat.presentation.framework.UserRequest)
   */
  @SuppressWarnings("unused")
  @Override
  protected void initForm(
      final FormItemContainer formLayout, final Controller listener, final UserRequest ureq) {
    searchQuery = uifactory.addTextElement("search", null, 250, null, formLayout);
    searchQuery.setDisplaySize(40);
    searchQuery.setExampleKey("navigation.create.article.example", null);

    // it doesn't seem to work
    // String regExp = "[a-zA-Z0-9]*";
    // searchQuery.setRegexMatchCheck(regExp, "navigation.create.article.validation.error");

    final FormSubmit submit = new FormSubmit("subm", "navigation.create.article");
    formLayout.add(submit);
  }
Ejemplo n.º 5
0
  @Override
  protected void formOK(final UserRequest ureq) {
    // will catch an ENTER in text search-field
    final String searchText = searchFld.getValue();
    filterSettings.setTextFilter(searchText);
    fireEvent(ureq, new PortfolioFilterChangeEvent(filterSettings));

    fireEvent(ureq, Event.CHANGED_EVENT);
  }
  @Override
  protected void initForm(
      final FormItemContainer formLayout, final Controller listener, final UserRequest ureq) {

    idata =
        uifactory.addTextAreaElement(
            "addusers", "form.addusers", -1, 15, 40, true, " ", formLayout);
    idata.setExampleKey("form.names.example", null);
    uifactory.addFormSubmitButton("next", formLayout);
  }
  /**
   * Adds a mandatory and a read-only text field to the provided form.
   *
   * @param formItemsFactory
   * @param form
   */
  private void addTextFields(final FormItemContainer form) {
    // Mandatory text field
    final TextElement textField =
        uifactory.addTextElement("textField", "guidemo.form.text", 256, "", form);
    textField.setMandatory(true);
    textField.setNotEmptyCheck("guidemo.form.error.notempty");
    textField.setExampleKey("advanced_form.text_field.example", null);

    // Read-only text field
    final TextElement readOnly =
        uifactory.addTextElement("readOnly", "guidemo.form.readonly", 256, "forever", form);
    readOnly.setEnabled(false);
  }
 public String getLoginsString() {
   return idata.getValue();
 }
 public boolean validate() {
   return !idata.isEmpty("form.legende.mandatory");
 }
Ejemplo n.º 10
0
 /**
  * org.olat.presentation.framework.components.form.flexible.FormItem,
  * org.olat.presentation.framework.components.form.flexible.impl.FormEvent)
  */
 @SuppressWarnings("unused")
 @Override
 protected void formInnerEvent(
     final UserRequest ureq, final FormItem source, final FormEvent event) {
   if (source instanceof FormLink) {
     final FormLink link = (FormLink) source;
     if (link.getName().startsWith(TAG_CMP_IDENTIFIER)) {
       // a tag-Link got clicked, find out which
       final String selectedTag = (String) link.getUserObject();
       if (!selectedTagsList.contains(selectedTag)) {
         selectedTagsList.add(selectedTag);
         tagAllBtn.toggleOff();
         tagNoneBtn.toggleOff();
       } else {
         selectedTagsList.remove(selectedTag);
         if (selectedTagsList.isEmpty()) {
           tagAllBtn.toggleOn();
         }
       }
       filterSettings.setTagFilter(selectedTagsList);
       fireEvent(ureq, new PortfolioFilterChangeEvent(filterSettings));
     } else if (link.getName().startsWith(HANDLER_PREFIX)) {
       // a type-link got clicked
       final String selectedType = (String) link.getUserObject();
       if (!selectedTypeList.contains(selectedType)) {
         selectedTypeList.add(selectedType);
         typeAllBtn.toggleOff();
       } else {
         selectedTypeList.remove(selectedType);
         if (selectedTypeList.isEmpty()) {
           typeAllBtn.toggleOn();
         }
       }
       filterSettings.setTypeFilter(selectedTypeList);
       fireEvent(ureq, new PortfolioFilterChangeEvent(filterSettings));
     }
   }
   if (source == tagAllBtn) {
     resetTagLinks();
     tagNoneBtn.toggleOff();
     filterSettings.setTagFilter(selectedTagsList);
     fireEvent(ureq, new PortfolioFilterChangeEvent(filterSettings));
   } else if (source == tagNoneBtn) {
     resetTagLinks();
     tagAllBtn.toggleOff();
     filterSettings.setNoTagFilter();
     fireEvent(ureq, new PortfolioFilterChangeEvent(filterSettings));
   } else if (source == typeAllBtn) {
     resetTypeLinks();
     filterSettings.setTypeFilter(selectedTypeList);
     fireEvent(ureq, new PortfolioFilterChangeEvent(filterSettings));
   } else if (source == dateStart || source == dateEnd) {
     if (validateFormLogic(ureq)) {
       final List<Date> dateList = new ArrayList<Date>();
       final Date selStartDate = dateStart.getDate();
       final Date selEndDate = dateEnd.getDate();
       dateList.add(selStartDate);
       dateList.add(selEndDate);
       filterSettings.setDateFilter(dateList);
       fireEvent(ureq, new PortfolioFilterChangeEvent(filterSettings));
     }
   } else if (source == typeEditBtn) {
     popupTypesCallout(ureq);
   } else if (source == tagEditBtn) {
     popupTagsCallout(ureq);
   } else if (source == searchFld) {
     final String searchText = searchFld.getValue();
     filterSettings.setTextFilter(searchText);
     fireEvent(ureq, new PortfolioFilterChangeEvent(filterSettings));
   } else if (source == filterSave) {
     if (StringHelper.containsNonWhitespace(filterName.getValue())) {
       final String oldFilterName = filterSettings.getFilterName();
       filterSettings.setFilterName(filterName.getValue());
       filterSettings.setTextFilter(searchFld.getValue());
       if (filterSave.getUserObject() != null && filterName.getValue().equals(oldFilterName)) {
         // fake update, delete before adding again
         final String filterID = (String) filterSave.getUserObject();
         ePFMgr.deleteFilterFromUsersList(getIdentity(), filterID);
       }
       if (!filterName.getValue().equals(oldFilterName) && oldFilterName != null) {
         // set another id, to distinguish from old
         filterSettings.setFilterIdToUniqueId();
       }
       final List<EPFilterSettings> filterList = ePFMgr.getSavedFilterSettings(getIdentity());
       // create a new or insert existing again
       filterList.add(filterSettings);
       ePFMgr.setSavedFilterSettings(getIdentity(), filterList);
       toggleSaveUpdateFilterButtons(true);
       showInfo("filter.saved", filterSettings.getFilterName());
       updateUI(ureq, filterSettings);
     }
   } else if (source == filterDel) {
     if (filterDel.getUserObject() != null) {
       ePFMgr.deleteFilterFromUsersList(getIdentity(), (String) filterDel.getUserObject());
       // refresh ui
       filterName.setValue("");
       toggleSaveUpdateFilterButtons(false);
       showInfo("filter.deleted");
       updateUI(ureq, new EPFilterSettings());
     }
   } else if (source == filterName) {
     final String oldFilterName = filterSettings.getFilterName();
     if (filterSave.getUserObject() != null && !filterName.getValue().equals(oldFilterName)) {
       toggleSaveUpdateFilterButtons(false);
     } else if (filterName.getValue().equals(oldFilterName)) {
       toggleSaveUpdateFilterButtons(true);
     }
   } else if (source == filterSel) {
     if (filterSel.isOneSelected()) {
       final int filterIndex = filterSel.getSelected();
       if (filterIndex == 0) {
         final EPFilterSettings newSettings = new EPFilterSettings();
         updateUI(ureq, newSettings);
         fireEvent(ureq, new PortfolioFilterChangeEvent(newSettings));
       } else if (filterIndex > 0 && filterIndex - 1 < nonEmptyFilters.size()) {
         final EPFilterSettings newSettings = nonEmptyFilters.get(filterIndex - 1);
         if (!filterSettings.getFilterId().equals(newSettings.getFilterId())) {
           updateUI(ureq, newSettings);
           fireEvent(ureq, new PortfolioFilterChangeEvent(newSettings));
         }
       }
     }
   }
 }
Ejemplo n.º 11
0
  @SuppressWarnings("unused")
  protected void initOrUpdateForm(
      final FormItemContainer formLayout, final Controller listener, final UserRequest ureq) {
    // filter by tag
    if (formLayout.getFormComponent("tagLayout") == null) {
      tagFlc =
          FormLayoutContainer.createCustomFormLayout(
              "tagLayout", getTranslator(), this.velocity_root + "/filter-tags.html");
      formLayout.add(tagFlc);
      initTagFlc();
    } else {
      updateTagFlc();
    }

    // filter by type
    if (formLayout.getFormComponent("typeLayout") == null) {
      typeFlc =
          FormLayoutContainer.createCustomFormLayout(
              "typeLayout", getTranslator(), this.velocity_root + "/filter-types.html");
      formLayout.add(typeFlc);
      initOrUpdateTypeFlc(DEFAULT_TYPE_AMOUNT);
    } else {
      updateTypeFlc();
    }

    // filter by date
    if (formLayout.getFormComponent("dateLayout") == null) {
      final String page = this.velocity_root + "/filter_date.html";
      dateFlc = FormLayoutContainer.createCustomFormLayout("dateLayout", getTranslator(), page);
      formLayout.add(dateFlc);
      dateFlc.setLabel("filter.by.date", null);
      dateStart = uifactory.addDateChooser("filter.date.start", "", dateFlc);
      dateStart.addActionListener(this, FormEvent.ONCHANGE);
      dateEnd = uifactory.addDateChooser("filter.date.end", "", dateFlc);
      dateEnd.addActionListener(listener, FormEvent.ONCHANGE);
      dateStart.clearError();
      dateEnd.clearError();
    }

    if (filterSettings.getDateFilter().size() == 2) {
      dateStart.setDate(filterSettings.getDateFilter().get(0));
      dateEnd.setDate(filterSettings.getDateFilter().get(1));
    } else {
      dateStart.setDate(null);
      dateEnd.setDate(new Date());
    }

    // filter by fulltext
    final String searchText = filterSettings.getTextFilter();
    if (formLayout.getFormComponent("search") == null) {
      searchFld = uifactory.addTextElement("search", "filter.search", 20, searchText, formLayout);
      searchFld.addActionListener(listener, FormEvent.ONCHANGE);
    } else {
      searchFld.setValue(searchText);
    }

    // show filter list and save as new
    if (formLayout.getFormComponent("spacer") == null) {
      uifactory.addSpacerElement("spacer", formLayout, false);
    }

    // filter list
    initFilterList(formLayout);
    // filter save
    if (formLayout.getFormComponent("filterSaveLayout") == null) {
      filterFlc =
          FormLayoutContainer.createHorizontalFormLayout("filterSaveLayout", getTranslator());
      formLayout.add(filterFlc);
      filterFlc.setLabel("filter.save", null);
      filterName =
          uifactory.addTextElement(
              "filter.save.name", null, 30, filterSettings.getFilterName(), filterFlc);
      filterSave =
          uifactory.addFormLink(
              "filter.save.link", "filter.save.new", null, filterFlc, Link.BUTTON_XSMALL);
      filterDel =
          uifactory.addFormLink(
              "filter.del.link", "filter.del.link", null, filterFlc, Link.BUTTON_XSMALL);
    } else {
      filterName.setValue(filterSettings.getFilterName());
    }

    final boolean isExistingFilter = filterSettings.getFilterName() != null;
    toggleSaveUpdateFilterButtons(isExistingFilter);
  }
 /** @return The email address or username entered by the user */
 public String getEmailOrUsername() {
   return emailOrUsername.getValue();
 }
Ejemplo n.º 13
0
 @Override
 protected void formOK(final UserRequest ureq) {
   searchQuery.showError(false);
   fireEvent(ureq, Event.DONE_EVENT);
 }