liferay 6.2 站点内容发布与ueditor的集成- ueditor-hook

在portal-setup-wizard.properties里面加上如下配置。 editor.wysiwyg.portal-web.docroot.html.portlet.journal.configuration.jsp=ueditoreditor.wysiwyg.portal-web.docroot.html.portlet.journal.edit_article_content.jsp=ueditor 下载ueditor.jar 放到liferay tomcat 下的Root/web-info/lib/下 下载ueditorhook-hook-6.2.0.1.war 安装即可 重启liferay应用


下载地址http://download.youkuaiyun.com/detail/renyuanchunby/9784674


对于文章内容发布使用自定义结构包含html-text字段类型 默认为ckeditor解决办法

portal-ext.properties 中新增:editor.wysiwyg.default=ueditor

复制ueditor.jsp(修复在自定义结构包含html-text字段类型,ueditor值无法保存的bug

<%--
/**
 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */
--%>


<%@page import="com.liferay.portal.kernel.util.Validator"%>
<%@page import="com.liferay.portal.util.PortalUtil"%>
<%@ include file="/html/taglib/init.jsp" %>


<%
String portletId = portletDisplay.getRootPortletId();


String mainPath = themeDisplay.getPathMain();


String doAsUserId = themeDisplay.getDoAsUserId();


if (Validator.isNull(doAsUserId)) {
doAsUserId = Encryptor.encrypt(company.getKeyObj(), String.valueOf(themeDisplay.getUserId()));
}


long doAsGroupId = themeDisplay.getDoAsGroupId();


if (doAsGroupId == 0) {
doAsGroupId = (Long)request.getAttribute("liferay-ui:input-editor:groupId");
}


long userId = PortalUtil.getUserId(request);


String contentsLanguageId = (String)request.getAttribute("liferay-ui:input-editor:contentsLanguageId");
String cssClass = GetterUtil.getString((String)request.getAttribute("liferay-ui:input-editor:cssClass"));
String cssClasses = GetterUtil.getString((String)request.getAttribute("liferay-ui:input-editor:cssClasses"));
String editorImpl = (String)request.getAttribute("liferay-ui:input-editor:editorImpl");
String name = GetterUtil.getString((String)request.getAttribute("liferay-ui:input-editor:name"));
String editorValueId = name.substring(0,name.length()-6);
String id = GetterUtil.getString((String)request.getAttribute("liferay-ui:input-editor:id"));
String initMethod = (String)request.getAttribute("liferay-ui:input-editor:initMethod");
boolean inlineEdit = GetterUtil.getBoolean((String)request.getAttribute("liferay-ui:input-editor:inlineEdit"));
String inlineEditSaveURL = GetterUtil.getString((String)request.getAttribute("liferay-ui:input-editor:inlineEditSaveURL"));


String onBlurMethod = (String)request.getAttribute("liferay-ui:input-editor:onBlurMethod");


if (Validator.isNotNull(onBlurMethod)) {
onBlurMethod = namespace + onBlurMethod;
}


String onChangeMethod = (String)request.getAttribute("liferay-ui:input-editor:onChangeMethod");


if (Validator.isNotNull(onChangeMethod)) {
onChangeMethod = namespace + onChangeMethod;
}


String onFocusMethod = (String)request.getAttribute("liferay-ui:input-editor:onFocusMethod");


if (Validator.isNotNull(onFocusMethod)) {
onFocusMethod = namespace + onFocusMethod;
}
boolean resizable = GetterUtil.getBoolean((String)request.getAttribute("liferay-ui:input-editor:resizable"));
boolean skipEditorLoading = GetterUtil.getBoolean((String)request.getAttribute("liferay-ui:input-editor:skipEditorLoading"));
String toolbarSet = (String)request.getAttribute("liferay-ui:input-editor:toolbarSet");


if (!inlineEdit) {
name = namespace + name;
editorValueId = namespace + editorValueId;
}
%>
<c:if test="<%= !skipEditorLoading %>">
<liferay-util:html-top outputKey="js_editor_ueditor">


<%
long javaScriptLastModified = ServletContextUtil.getLastModified(application, "/html/js/", true);
%>


<script src="<%= HtmlUtil.escape(PortalUtil.getStaticResourceURL(request, themeDisplay.getCDNHost() + themeDisplay.getPathJavaScript() + "/editor/ueditor/ueditor.config.js", javaScriptLastModified)) %>" type="text/javascript"></script>
<script src="<%= HtmlUtil.escape(PortalUtil.getStaticResourceURL(request, themeDisplay.getCDNHost() + themeDisplay.getPathJavaScript() + "/editor/ueditor/ueditor.all.min.js", javaScriptLastModified)) %>" type="text/javascript"></script>
<script src="<%= HtmlUtil.escape(PortalUtil.getStaticResourceURL(request, themeDisplay.getCDNHost() + themeDisplay.getPathJavaScript() + "/editor/ueditor/lang/zh-cn/zh-cn.js", javaScriptLastModified)) %>" type="text/javascript"></script>
<script type="text/javascript">
Liferay.namespace('EDITORS')['<%= editorImpl %>'] = true;
</script>
<link rel='stylesheet' id='style-css' href='<%= HtmlUtil.escape(PortalUtil.getStaticResourceURL(request, themeDisplay.getCDNHost() + themeDisplay.getPathJavaScript() + "/editor/ueditor/themes/default/css/ueditor.min.css", javaScriptLastModified)) %>' type='text/css'/>
</liferay-util:html-top>
</c:if>
<div class="<%= HtmlUtil.escapeAttribute(cssClass) %>">
<textarea id="<%= name %>" name="<%= name %>" ></textarea>
</div>
<aui:script>
window['<%= name %>'] = {
   onChangeCallbackCounter: 0,
destroy: function() {
var ueEditor = UE.getEditor('<%= name %>');
if (ueEditor) {
ueEditor.destroy();
}
window['<%= name %>'] = null;
},


focus: function() {
  UE.getEditor('<%= name %>').focus();
},


getHTML: function() {
  var data;


if (!window['<%= name %>'].instanceReady && window['<%= HtmlUtil.escape(namespace + initMethod) %>']) {
data = <%= HtmlUtil.escape(namespace + initMethod) %>();
}
else {
data = UE.getEditor('<%= name %>').getContent();
}


return data;
},
init: function(value) {
if (typeof value != 'string') {
value = '';
}


window['<%= name %>'].setHTML(value);
},


initInstanceCallback: function() {
<c:if test="<%= Validator.isNotNull(initMethod) %>">
window['<%= name %>'].init(<%= HtmlUtil.escape(namespace + initMethod) %>());
</c:if>


var iframe = A.one('#<%= name %>_ifr');


if (iframe) {
var iframeWin = iframe.getDOM().contentWindow;


if (iframeWin) {
var iframeDoc = iframeWin.document.documentElement;


A.one(iframeDoc).addClass('aui');
}
}


window['<%= name %>'].instanceReady = true;
},




initUeditor: function() {
   var textArea = document.getElementById('<%= name %>');
<c:if test="<%= Validator.isNotNull(initMethod) %>">
textArea.value = window['<%= HtmlUtil.escapeJS(namespace + initMethod) %>']();
</c:if>
            var ue = UE.getEditor('<%= name %>');

           ue.ready(function() {
   ue.execCommand('serverparam', {
'groupId': '<%=doAsGroupId%>',
'folderId':'0',
'userId':'<%=userId%>'
 });
});
<%
if (Validator.isNotNull(onChangeMethod)) {
%>


setInterval(
function() {
try {
window['<%= name %>'].onChangeCallback();
}
catch (e) {
}
},
300
);


<%
}
%>


window['<%= name %>'].instanceReady = true;
},


instanceReady: false,


<%
if (Validator.isNotNull(onChangeMethod)) {
%>


onChangeCallback: function(tinyMCE) {


// This purposely ignores the first callback event because each call
// to setContent triggers an undo level which fires the callback
// when no changes have yet been made.


// setContent is not really the correct way of initializing this
// editor with content. The content should be placed statically
// (from the editor's perspective) within the textarea. This is a
// problem from the portal's perspective because it's passing the
// content via a javascript method (initMethod).


var onChangeCallbackCounter = window['<%= name %>'].onChangeCallbackCounter;


if (onChangeCallbackCounter > 0) {


<%= HtmlUtil.escapeJS(onChangeMethod) %>(window['<%= name %>'].getHTML());


}


onChangeCallbackCounter++;
},


<%
}
%>


setHTML: function(value) {
UE.getEditor('<%= name %>').setContent(value);
}
};


window['<%= name %>'].initUeditor();
</aui:script>


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值