本文整理汇总了Java中com.liferay.portal.kernel.util.HtmlUtil类的典型用法代码示例。如果您正苦于以下问题:Java HtmlUtil类的具体用法?Java HtmlUtil怎么用?Java HtmlUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HtmlUtil类属于com.liferay.portal.kernel.util包,在下文中一共展示了HtmlUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRedirectURL
import com.liferay.portal.kernel.util.HtmlUtil; //导入依赖的package包/类
/**
* Get redirect url.
*
* @return redirect url
* @throws PortalException
*/
public static String getRedirectURL(PortletRequest portletRequest)
throws PortalException {
StringBundler sb = new StringBundler();
sb.append(GSearchUtil.getCurrentLayoutFriendlyURL(portletRequest));
sb.append("?");
sb.append(GSearchWebKeys.KEYWORDS).append("=").append(
ParamUtil.getString(portletRequest, GSearchWebKeys.KEYWORDS));
sb.append("&").append(GSearchWebKeys.FILTER_SCOPE).append("=").append(
ParamUtil.getString(portletRequest, GSearchWebKeys.FILTER_SCOPE));
sb.append("&").append(GSearchWebKeys.FILTER_TIME).append("=").append(
ParamUtil.getString(portletRequest, GSearchWebKeys.FILTER_TIME));
sb.append("&").append(GSearchWebKeys.FILTER_TYPE).append("=").append(
ParamUtil.getString(portletRequest, GSearchWebKeys.FILTER_TYPE));
sb.append("&").append(GSearchWebKeys.SORT_FIELD).append("=").append(
ParamUtil.getString(portletRequest, GSearchWebKeys.SORT_FIELD));
sb.append("&").append(GSearchWebKeys.SORT_DIRECTION).append("=").append(
ParamUtil.getString(portletRequest, GSearchWebKeys.SORT_DIRECTION));
sb.append("&").append(GSearchWebKeys.START).append("=").append(
ParamUtil.getString(portletRequest, GSearchWebKeys.START));
return HtmlUtil.escapeURL(sb.toString());
}
示例2: getIconURL
import com.liferay.portal.kernel.util.HtmlUtil; //导入依赖的package包/类
public String getIconURL(long applicationId) throws Exception {
String result = "";
try {
// _log.debug("getIconURL(applicationId " + applicationId + ")");
Application application = applicationLocalService.getApplication(applicationId);
if (application.getLogoImageId() != 0) {
DLFileEntry fe = DLFileEntryLocalServiceUtil.getDLFileEntry(application.getLogoImageId());
result = "http://localhost/documents/10180/0/" +
HttpUtil.encodeURL(HtmlUtil.unescape(fe.getTitle())) +
StringPool.SLASH +
fe.getUuid() +
"?version=" + fe.getVersion() +
"&t=" + fe.getModifiedDate().getTime() +
"&imageThumbnail=1";
}
} catch (SystemException se) {
_log.error("applicationId: " + applicationId);
_log.error(se.getMessage());
} catch (PortalException pe) {
_log.error("applicationId: " + applicationId);
_log.error(pe.getMessage());
}
return result;
}
示例3: getExternIconURL
import com.liferay.portal.kernel.util.HtmlUtil; //导入依赖的package包/类
private String getExternIconURL(Application application) throws Exception {
String result = "";
try {
if (application.getLogoImageId() != 0) {
DLFileEntry fe = DLFileEntryLocalServiceUtil.getDLFileEntry(application.getLogoImageId());
result = "http://" + AppConstants.COMPANY_VIRTUAL_HOST + "/documents/10180/0/" +
HttpUtil.encodeURL(HtmlUtil.unescape(fe.getTitle())) +
StringPool.SLASH +
fe.getUuid() +
"?version=" + fe.getVersion() +
"&t=" + fe.getModifiedDate().getTime() +
"&imageThumbnail=1";
}
} catch (SystemException se) {
_log.error(se.getMessage());
} catch (PortalException pe) {
_log.error(pe.getMessage());
}
return result;
}
示例4: handleEmail
import com.liferay.portal.kernel.util.HtmlUtil; //导入依赖的package包/类
protected void handleEmail(
StringBundler sb, List<BBCodeItem> bbCodeItems, Stack<String> tags,
IntegerWrapper marker, BBCodeItem bbCodeItem) {
sb.append("<a href=\"");
String href = bbCodeItem.getAttribute();
if (href == null) {
href = extractData(
bbCodeItems, marker, "email", BBCodeParser.TYPE_DATA, false);
}
if (!href.startsWith("mailto:")) {
href = "mailto:" + href;
}
sb.append(HtmlUtil.escapeHREF(href));
sb.append("\">");
tags.push("</a>");
}
示例5: handleYoutube
import com.liferay.portal.kernel.util.HtmlUtil; //导入依赖的package包/类
protected void handleYoutube(
StringBundler sb, List<BBCodeItem> bbCodeItems, Stack<String> tags, IntegerWrapper marker) {
String videoId = extractData(
bbCodeItems, marker, "youtube", BBCodeParser.TYPE_DATA, true);
if (videoId.length() > 0) {
int videoHeight = GetterUtil.get(PropsUtil.get("forum.video.height"), 349);
int videoWidth = GetterUtil.get(PropsUtil.get("forum.video.width"), 560);
// Extrai o identificador do video, parar criar o embbed
for (Pattern p : YOUTUBE_PATTERNS) {
Matcher m = p.matcher(videoId);
if (m.find()) {
sb.append("<iframe ");
sb.append("width=\"").append(videoWidth).append("\" ");
sb.append("height=\"").append(videoHeight).append("\" ");
sb.append("src=\"http://www.youtube.com/embed/");
sb.append(HtmlUtil.escapeAttribute(m.group(1)));
sb.append("\" frameborder=\"0\" allowfullscreen></iframe>");
break;
}
}
}
}
示例6: handleURL
import com.liferay.portal.kernel.util.HtmlUtil; //导入依赖的package包/类
protected void handleURL(
StringBundler sb, List<BBCodeItem> bbCodeItems, Stack<String> tags,
IntegerWrapper marker, BBCodeItem bbCodeItem) {
sb.append("<a href=\"");
String href = bbCodeItem.getAttribute();
if (href == null) {
href = extractData(
bbCodeItems, marker, "url", BBCodeParser.TYPE_DATA, false);
}
Matcher matcher = _urlPattern.matcher(href);
if (matcher.matches()) {
sb.append(HtmlUtil.escapeHREF(href));
}
sb.append("\">");
tags.push("</a>");
}
示例7: getBody
import com.liferay.portal.kernel.util.HtmlUtil; //导入依赖的package包/类
@Override
protected String getBody(UserNotificationEvent userNotificationEvent,
ServiceContext serviceContext) throws Exception {
JSONObject jsonObject = JSONFactoryUtil.createJSONObject(userNotificationEvent.getPayload());
long siteRequestId = jsonObject.getLong("siteRequestId");
SiteRequest microsite = SiteRequestLocalServiceUtil.getSiteRequest(siteRequestId);
if (Validator.isNull(microsite)) {
UserNotificationEventLocalServiceUtil.deleteUserNotificationEvent(userNotificationEvent.getPrimaryKey());
return null;
}
long userId = jsonObject.getLong("userId");
String notificationType = jsonObject.getString("notificationType");
String title = getTitle(serviceContext, userId, notificationType);
return StringUtil.replace(
getBodyTemplate(),
new String[] { "[$TITLE$]", "[$NAME$]", "[$BODY_TEXT$]" },
new String[] { title, HtmlUtil.escape(StringUtil.shorten(microsite.getName(), 50)),
HtmlUtil.escape(StringUtil.shorten(microsite.getDescription(), 50)) });
}
示例8: getTitle
import com.liferay.portal.kernel.util.HtmlUtil; //导入依赖的package包/类
private String getTitle(ServiceContext serviceContext, long userId,
String notificationType) {
String title = "";
switch(notificationType) {
case MicroSiteConstants.REQUEST_STATUS_COMPLETE:
title = "site-request-completed-notification";
break;
case MicroSiteConstants.REQUEST_STATUS_PENDING:
title = "site-request-processing-notification";
break;
case MicroSiteConstants.REQUEST_STATUS_REJECTED:
title = "site-request-rejected-notification";
default:
break;
}
return serviceContext.translate(title, HtmlUtil.escape(PortalUtil.getUserName(userId, StringPool.BLANK)));
}
示例9: getStagedModelMessage
import com.liferay.portal.kernel.util.HtmlUtil; //导入依赖的package包/类
protected String getStagedModelMessage(Locale locale) {
StringBundler sb = new StringBundler(8);
sb.append("<strong>");
sb.append(LanguageUtil.get(locale, getStatusMessageKey()));
sb.append(StringPool.TRIPLE_PERIOD);
sb.append("</strong>");
sb.append(ResourceActionsUtil.getModelResource(locale, _stagedModelType));
sb.append("<em>");
sb.append(HtmlUtil.escape(_stagedModelName));
sb.append("</em>");
return sb.toString();
}
示例10: getTemplateVars
import com.liferay.portal.kernel.util.HtmlUtil; //导入依赖的package包/类
@Override
protected Map<String, Object> getTemplateVars() {
Map<String, Object> templateVars = new HashMap<>();
templateVars.put("exported", MapUtil.getBoolean(backgroundTask.getTaskContextMap(), "exported"));
templateVars.put("validated", MapUtil.getBoolean(backgroundTask.getTaskContextMap(), "validated"));
templateVars.put("htmlUtil", HtmlUtil.getHtml());
return templateVars;
}
示例11: updateAsset
import com.liferay.portal.kernel.util.HtmlUtil; //导入依赖的package包/类
@Override
public void updateAsset(long userId, TaskRecord taskRecord, long[] assetCategoryIds, String[] assetTagNames,
long[] assetLinkEntryIds, Double priority) throws PortalException {
// TODO
boolean visible = true;
// boolean visible = false;
// if (taskRecord.isApproved()) {
// visible = true;
// publishDate = taskRecord.getCreateDate();
// }
Date publishDate = null;
String summary = HtmlUtil.extractText(StringUtil.shorten(taskRecord.getWorkPackage(), 500));
String className = TaskRecord.class.getName();
long classPK = taskRecord.getTaskRecordId();
AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, taskRecord.getGroupId(),
taskRecord.getCreateDate(), taskRecord.getModifiedDate(), className, classPK, taskRecord.getUuid(), 0,
assetCategoryIds, assetTagNames, true, visible, null, null, publishDate, null, ContentTypes.TEXT_HTML,
taskRecord.getWorkPackage(), taskRecord.getWorkPackage(), summary, null, null, 0, 0, priority);
assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), assetLinkEntryIds,
AssetLinkConstants.TYPE_RELATED);
}
示例12: updateAsset
import com.liferay.portal.kernel.util.HtmlUtil; //导入依赖的package包/类
@Override
public void updateAsset(long userId, Contact contact, long[] assetCategoryIds, String[] assetTagNames,
long[] assetLinkEntryIds, Double priority) throws PortalException {
// TODO
boolean visible = true;
// boolean visible = false;
// if (contact.isApproved()) {
// visible = true;
// publishDate = contact.getCreateDate();
// }
Date publishDate = contact.getCreateDate();
// TODO
String description = "TODO: contact description";
String summary = HtmlUtil.extractText(StringUtil.shorten(contact.getCard(), 500));
String className = Contact.class.getName();
long classPK = contact.getContactId();
AssetEntry assetEntry = assetEntryLocalService.updateEntry(userId, contact.getGroupId(),
contact.getCreateDate(), contact.getModifiedDate(), className, classPK, contact.getUuid(), 0,
assetCategoryIds, assetTagNames, true, visible, null, null, publishDate, null, ContentTypes.TEXT_HTML,
// contact.getName(),
"TODO: contact.getName()", description, summary, null, null, 0, 0, priority);
assetLinkLocalService.updateLinks(userId, assetEntry.getEntryId(), assetLinkEntryIds,
AssetLinkConstants.TYPE_RELATED);
// assetEntryLocalService.updateVisible(Contact.class.getName(),
// classPK, visible);
}
示例13: getDescription
import com.liferay.portal.kernel.util.HtmlUtil; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public String getDescription()
throws SearchException {
return HtmlUtil.stripHtml(getSummary().getContent());
}
示例14: getTitle
import com.liferay.portal.kernel.util.HtmlUtil; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public String getTitle()
throws NumberFormatException, PortalException {
String title = getSummary().getTitle();
if (Validator.isNull(title)) {
title = getAssetRenderer().getTitle(_locale);
}
return HtmlUtil.stripHtml(title);
}
示例15: updateAsset
import com.liferay.portal.kernel.util.HtmlUtil; //导入依赖的package包/类
@Override
public void updateAsset(long userId, Measurement measurement,
long[] assetCategoryIds, String[] assetTagNames, Double priority)
throws PortalException {
// TODO
boolean visible = true;
// boolean visible = false;
// if (measurement.isApproved()) {
// visible = true;
// publishDate = measurement.getCreateDate();
// }
Date publishDate = null;
String summary = HtmlUtil
.extractText(StringUtil.shorten(measurement.getData(), 500));
String className = Measurement.class.getName();
long classPK = measurement.getMeasurementId();
assetEntryLocalService.updateEntry(userId, measurement.getGroupId(),
measurement.getCreateDate(), measurement.getModifiedDate(),
className, classPK, measurement.getUuid(), 0, assetCategoryIds,
assetTagNames, true, visible, null, null, publishDate, null,
ContentTypes.TEXT_HTML, measurement.getName(),
measurement.getName(), summary, null, null, 0, 0, priority);
}