private static String getContent(final WikiPage wikiPage) { try { final ParserInput input = new ParserInput(); input.setWikiUser(null); input.setAllowSectionEdit(false); input.setDepth(2); input.setContext(""); input.setLocale(Locale.ENGLISH); input.setTopicName("dummy"); input.setUserIpAddress("0.0.0.0"); input.setDataHandler(DUMMY_DATA_HANDLER); input.setVirtualWiki("/olat"); final AbstractParser parser = new JFlexParser(input); final ParserDocument parsedDoc = parser.parseHTML(wikiPage.getContent()); final String parsedContent = parsedDoc.getContent(); final String filteredContent = FilterFactory.getHtmlTagAndDescapingFilter().filter(parsedContent); return filteredContent; } catch (final Exception e) { e.printStackTrace(); log.error("", e); return wikiPage.getContent(); } }
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); } }
/** * Strips all HTML tags from the source string. * * @param source Source * @return Source without HTML tags. */ public static String filterHTMLTags(String source) { Filter htmlTagsFilter = FilterFactory.getHtmlTagsFilter(); return htmlTagsFilter.filter(source); }
public String filterHtml(String str) { if (str == null) { return ""; } return FilterFactory.getHtmlTagsFilter().filter(str); }
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"; } }