List of usage examples for com.liferay.portal.kernel.util HtmlUtil stripHtml
public static String stripHtml(String text)
From source file:ca.efendi.datafeeds.web.asset.CJProductAssetRenderer.java
License:Apache License
@Override public String getSummary(final PortletRequest portletRequest, final PortletResponse portletResponse) { int abstractLength = AssetUtil.ASSET_ENTRY_ABSTRACT_LENGTH; if (portletRequest != null) { abstractLength = GetterUtil.getInteger(portletRequest.getAttribute(WebKeys.ASSET_ENTRY_ABSTRACT_LENGTH), AssetUtil.ASSET_ENTRY_ABSTRACT_LENGTH); }//from w w w .ja v a 2s .c o m String summary = _entry.getDescription(); if (Validator.isNull(summary)) { summary = HtmlUtil.stripHtml(StringUtil.shorten(_entry.getName(), abstractLength)); } return summary; }
From source file:com.liferay.blogs.service.impl.BlogsEntryLocalServiceImpl.java
License:Open Source License
protected void notifySubscribers(long userId, BlogsEntry entry, ServiceContext serviceContext, Map<String, Serializable> workflowContext) throws PortalException { String entryURL = (String) workflowContext.get(WorkflowConstants.CONTEXT_URL); if (!entry.isApproved() || Validator.isNull(entryURL)) { return;//from w ww . j a v a2 s . c o m } BlogsGroupServiceSettings blogsGroupServiceSettings = BlogsGroupServiceSettings .getInstance(entry.getGroupId()); boolean sendEmailEntryUpdated = GetterUtil.getBoolean(serviceContext.getAttribute("sendEmailEntryUpdated")); if (serviceContext.isCommandAdd() && blogsGroupServiceSettings.isEmailEntryAddedEnabled()) { } else if (sendEmailEntryUpdated && serviceContext.isCommandUpdate() && blogsGroupServiceSettings.isEmailEntryUpdatedEnabled()) { } else { return; } Group group = groupPersistence.findByPrimaryKey(entry.getGroupId()); String entryTitle = entry.getTitle(); String fromName = blogsGroupServiceSettings.getEmailFromName(); String fromAddress = blogsGroupServiceSettings.getEmailFromAddress(); LocalizedValuesMap subjectLocalizedValuesMap = null; LocalizedValuesMap bodyLocalizedValuesMap = null; if (serviceContext.isCommandUpdate()) { subjectLocalizedValuesMap = blogsGroupServiceSettings.getEmailEntryUpdatedSubject(); bodyLocalizedValuesMap = blogsGroupServiceSettings.getEmailEntryUpdatedBody(); } else { subjectLocalizedValuesMap = blogsGroupServiceSettings.getEmailEntryAddedSubject(); bodyLocalizedValuesMap = blogsGroupServiceSettings.getEmailEntryAddedBody(); } SubscriptionSender subscriptionSender = new GroupSubscriptionCheckSubscriptionSender( BlogsPermission.RESOURCE_NAME); subscriptionSender.setClassPK(entry.getEntryId()); subscriptionSender.setClassName(entry.getModelClassName()); subscriptionSender.setCompanyId(entry.getCompanyId()); subscriptionSender.setContextAttribute("[$BLOGS_ENTRY_CONTENT$]", StringUtil.shorten(HtmlUtil.stripHtml(entry.getContent()), 500), false); subscriptionSender.setContextAttributes("[$BLOGS_ENTRY_CREATE_DATE$]", Time.getSimpleDate(entry.getCreateDate(), "yyyy/MM/dd"), "[$BLOGS_ENTRY_DESCRIPTION$]", entry.getDescription(), "[$BLOGS_ENTRY_SITE_NAME$]", group.getDescriptiveName(serviceContext.getLocale()), "[$BLOGS_ENTRY_STATUS_BY_USER_NAME$]", entry.getStatusByUserName(), "[$BLOGS_ENTRY_TITLE$]", entryTitle, "[$BLOGS_ENTRY_UPDATE_COMMENT$]", HtmlUtil.replaceNewLine( GetterUtil.getString(serviceContext.getAttribute("emailEntryUpdatedComment"))), "[$BLOGS_ENTRY_URL$]", entryURL, "[$BLOGS_ENTRY_USER_PORTRAIT_URL$]", workflowContext.get(WorkflowConstants.CONTEXT_USER_PORTRAIT_URL), "[$BLOGS_ENTRY_USER_URL$]", workflowContext.get(WorkflowConstants.CONTEXT_USER_URL)); subscriptionSender.setContextCreatorUserPrefix("BLOGS_ENTRY"); subscriptionSender.setCreatorUserId(entry.getUserId()); subscriptionSender.setCurrentUserId(userId); subscriptionSender.setEntryTitle(entryTitle); subscriptionSender.setEntryURL(entryURL); subscriptionSender.setFrom(fromAddress, fromName); subscriptionSender.setHtmlFormat(true); if (bodyLocalizedValuesMap != null) { subscriptionSender.setLocalizedBodyMap(LocalizationUtil.getMap(bodyLocalizedValuesMap)); } if (subjectLocalizedValuesMap != null) { subscriptionSender.setLocalizedSubjectMap(LocalizationUtil.getMap(subjectLocalizedValuesMap)); } subscriptionSender.setMailId("blogs_entry", entry.getEntryId()); int notificationType = UserNotificationDefinition.NOTIFICATION_TYPE_ADD_ENTRY; if (serviceContext.isCommandUpdate()) { notificationType = UserNotificationDefinition.NOTIFICATION_TYPE_UPDATE_ENTRY; } subscriptionSender.setNotificationType(notificationType); String portletId = PortletProviderUtil.getPortletId(BlogsEntry.class.getName(), PortletProvider.Action.VIEW); subscriptionSender.setPortletId(portletId); subscriptionSender.setReplyToAddress(fromAddress); subscriptionSender.setScopeGroupId(entry.getGroupId()); subscriptionSender.setServiceContext(serviceContext); subscriptionSender.addPersistedSubscribers(BlogsEntry.class.getName(), entry.getGroupId()); subscriptionSender.addPersistedSubscribers(BlogsEntry.class.getName(), entry.getEntryId()); subscriptionSender.flushNotificationsAsync(); }
From source file:com.liferay.blogs.web.asset.BlogsEntryAssetRenderer.java
License:Open Source License
@Override public String getSummary(PortletRequest portletRequest, PortletResponse portletResponse) { int abstractLength = AssetUtil.ASSET_ENTRY_ABSTRACT_LENGTH; if (portletRequest != null) { abstractLength = GetterUtil.getInteger(portletRequest.getAttribute(WebKeys.ASSET_ENTRY_ABSTRACT_LENGTH), AssetUtil.ASSET_ENTRY_ABSTRACT_LENGTH); }/*w w w . j a v a 2 s. c om*/ String summary = _entry.getDescription(); if (Validator.isNull(summary)) { summary = HtmlUtil.stripHtml(StringUtil.shorten(_entry.getContent(), abstractLength)); } return summary; }
From source file:com.liferay.blogs.web.internal.util.BlogsUtil.java
License:Open Source License
public static int getReadingTimeMinutes(String content) { String strippedContent = HtmlUtil.stripHtml(content); String[] words = StringUtil.split(strippedContent, StringPool.SPACE); if (words.length < 250) { return 1; }//from w w w . jav a 2 s. c o m return Math.round(words.length / 250F); }
From source file:com.liferay.calendar.asset.CalendarBookingAssetRenderer.java
License:Open Source License
@Override public String getSummary(PortletRequest portletRequest, PortletResponse portletResponse) { Locale locale = getLocale(portletRequest); String summary = _calendarBooking.getDescription(locale); return StringUtil.shorten(HtmlUtil.stripHtml(summary), 200); }
From source file:com.liferay.comment.web.internal.notifications.CommentUserNotificationHandler.java
License:Open Source License
@Override protected String getBodyContent(JSONObject jsonObject) { return HtmlUtil.stripHtml(super.getBodyContent(jsonObject)); }
From source file:com.liferay.journal.transformer.ContentTransformerListener.java
License:Open Source License
protected void replace(Element root, long articleGroupId) throws Exception { for (Element element : root.elements()) { List<Element> dynamicContentElements = element.elements("dynamic-content"); for (Element dynamicContentElement : dynamicContentElements) { String text = dynamicContentElement.getText(); text = HtmlUtil.stripComments(text); text = HtmlUtil.stripHtml(text); text = text.trim();//from ww w . j a va 2s . c o m // [@articleId;elementName@] if (Validator.isNotNull(text) && (text.length() >= 7) && text.startsWith("[@") && text.endsWith("@]")) { text = text.substring(2, text.length() - 2); int pos = text.indexOf(";"); if (pos != -1) { String articleId = text.substring(0, pos); String elementName = text.substring(pos + 1); JournalArticle article = JournalArticleLocalServiceUtil.getArticle(articleGroupId, articleId); dynamicContentElement.clearContent(); dynamicContentElement.addCDATA(getDynamicContent(article.getDocument(), elementName)); } } else if ((text != null) && text.startsWith("/image/journal/article?img_id")) { // Make sure to point images to the full path dynamicContentElement.setText("@cdn_host@@root_path@" + text); } } replace(element, articleGroupId); } }
From source file:com.liferay.journal.web.asset.JournalArticleAssetRenderer.java
License:Open Source License
@Override public String getSummary(PortletRequest portletRequest, PortletResponse portletResponse) { Locale locale = getLocale(portletRequest); String summary = _article.getDescription(locale); if (Validator.isNotNull(summary)) { return summary; }/*from w ww. j ava 2s .com*/ try { PortletRequestModel portletRequestModel = null; ThemeDisplay themeDisplay = null; if ((portletRequest != null) && (portletResponse != null)) { portletRequestModel = new PortletRequestModel(portletRequest, portletResponse); themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY); } JournalArticleDisplay articleDisplay = JournalArticleLocalServiceUtil.getArticleDisplay(_article, null, null, LanguageUtil.getLanguageId(locale), 1, portletRequestModel, themeDisplay); summary = HtmlUtil.stripHtml(articleDisplay.getContent()); } catch (Exception e) { } return summary; }
From source file:com.liferay.marketplace.app.manager.web.internal.util.MarketplaceAppManagerUtil.java
License:Open Source License
public static String getSearchContainerFieldText(Object object) { if (object == null) { return StringPool.BLANK; }/*www .j a v a2s . co m*/ String string = GetterUtil.getString(object); string = StringUtil.shorten(string, 400); string = HtmlUtil.stripHtml(string); string = HtmlUtil.escape(string); return string; }
From source file:com.liferay.message.boards.web.internal.trash.MBCategoryTrashRenderer.java
License:Open Source License
@Override public String getSummary(PortletRequest portletRequest, PortletResponse portletResponse) { return HtmlUtil.stripHtml(_category.getDescription()); }