--- /dev/null
+<%--\r
+/**\r
+ * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.\r
+ *\r
+ * This library is free software; you can redistribute it and/or modify it under\r
+ * the terms of the GNU Lesser General Public License as published by the Free\r
+ * Software Foundation; either version 2.1 of the License, or (at your option)\r
+ * any later version.\r
+ *\r
+ * This library is distributed in the hope that it will be useful, but WITHOUT\r
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS\r
+ * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more\r
+ * details.\r
+ */\r
+--%>\r
+\r
+<%@ include file="/html/taglib/init.jsp" %>\r
+\r
+<%\r
+String portletId = portletDisplay.getRootPortletId();\r
+\r
+String mainPath = themeDisplay.getPathMain();\r
+\r
+String doAsUserId = themeDisplay.getDoAsUserId();\r
+\r
+if (Validator.isNull(doAsUserId)) {\r
+ doAsUserId = Encryptor.encrypt(company.getKeyObj(), String.valueOf(themeDisplay.getUserId()));\r
+}\r
+\r
+long doAsGroupId = themeDisplay.getDoAsGroupId();\r
+\r
+StringBundler configParamsSB = new StringBundler();\r
+\r
+Map<String, String> configParams = (Map<String, String>)request.getAttribute("liferay-ui:input-editor:configParams");\r
+\r
+if (configParams != null) {\r
+ for (Map.Entry<String, String> configParam : configParams.entrySet()) {\r
+ configParamsSB.append(StringPool.AMPERSAND);\r
+ configParamsSB.append(configParam.getKey());\r
+ configParamsSB.append(StringPool.EQUAL);\r
+ configParamsSB.append(HttpUtil.encodeURL(configParam.getValue()));\r
+ }\r
+}\r
+\r
+String cssClass = GetterUtil.getString((String)request.getAttribute("liferay-ui:input-editor:cssClass"));\r
+String cssClasses = GetterUtil.getString((String)request.getAttribute("liferay-ui:input-editor:cssClasses"));\r
+String editorImpl = (String)request.getAttribute("liferay-ui:input-editor:editorImpl");\r
+String initMethod = (String)request.getAttribute("liferay-ui:input-editor:initMethod");\r
+String name = namespace + GetterUtil.getString((String)request.getAttribute("liferay-ui:input-editor:name"));\r
+\r
+String onChangeMethod = (String)request.getAttribute("liferay-ui:input-editor:onChangeMethod");\r
+\r
+if (Validator.isNotNull(onChangeMethod)) {\r
+ onChangeMethod = namespace + onChangeMethod;\r
+}\r
+\r
+boolean skipEditorLoading = GetterUtil.getBoolean((String)request.getAttribute("liferay-ui:input-editor:skipEditorLoading"));\r
+String toolbarSet = (String)request.getAttribute("liferay-ui:input-editor:toolbarSet");\r
+\r
+// To upgrade FCKEditor, download the latest version and unzip it to fckeditor.\r
+// Add custom configuration to fckeditor/fckconfig.jsp. Copy\r
+// fckeditor/editor/filemanager/browser/default to\r
+// fckeditor/editor/filemanager/browser/liferay. Modify browser.html,\r
+// frmresourceslist.html, frmresourcetype.html, and frmupload.html.\r
+\r
+%>\r
+\r
+<c:if test="<%= !skipEditorLoading %>">\r
+ <liferay-util:html-top outputKey="js_editor_fckeditor">\r
+\r
+ <%\r
+ long javaScriptLastModified = ServletContextUtil.getLastModified(application, "/html/js/", true);\r
+ %>\r
+\r
+ <script src="<%= HtmlUtil.escape(PortalUtil.getStaticResourceURL(request, themeDisplay.getCDNHost() + themeDisplay.getPathJavaScript() + "/editor/fckeditor/fckeditor.js", javaScriptLastModified)) %>" type="text/javascript"></script>\r
+\r
+ <script type="text/javascript">\r
+ Liferay.namespace('EDITORS')['<%= editorImpl %>'] = true;\r
+ </script>\r
+ </liferay-util:html-top>\r
+</c:if>\r
+\r
+<aui:script>\r
+ window['<%= name %>'] = {\r
+ destroy: function() {\r
+ var fckEditor = FCKeditorAPI.GetInstance('<%= name %>');\r
+\r
+ if (fckEditor) {\r
+ var configEl = document.getElementById('<%= name %>__Config');\r
+ var frameEl = document.getElementById('<%= name %>__Frame');\r
+\r
+ if (configEl) {\r
+ configEl.parentNode.removeChild(configEl);\r
+ }\r
+\r
+ if (frameEl) {\r
+ frameEl.parentNode.removeChild(frameEl);\r
+ }\r
+\r
+ delete FCKeditorAPI.__Instances['<%= name %>'];\r
+ }\r
+\r
+ delete window['<%= name %>'];\r
+ },\r
+\r
+ focus: function() {\r
+ FCKeditorAPI.GetInstance('<%= name %>').Focus();\r
+ },\r
+\r
+ getHTML: function() {\r
+ return FCKeditorAPI.GetInstance('<%= name %>').GetXHTML();\r
+ },\r
+\r
+ getText: function() {\r
+ return FCKeditorAPI.GetInstance('<%= name %>').GetXHTML();\r
+ },\r
+\r
+ initFckArea: function() {\r
+ var textArea = document.getElementById('<%= name %>');\r
+\r
+ <c:if test="<%= Validator.isNotNull(initMethod) %>">\r
+ textArea.value = <%= HtmlUtil.escape(namespace + initMethod) %>();\r
+ </c:if>\r
+\r
+ var fckEditor = new FCKeditor('<%= name %>');\r
+\r
+ fckEditor.Config['CustomConfigurationsPath'] = '<%= PortalUtil.getPathContext() %>/html/js/editor/fckeditor/fckconfig.jsp?p_l_id=<%= plid %>&p_p_id=<%= HttpUtil.encodeURL(portletId) %>&p_main_path=<%= HttpUtil.encodeURL(mainPath) %>&doAsUserId=<%= HttpUtil.encodeURL(doAsUserId) %>&doAsGroupId=<%= HttpUtil.encodeURL(String.valueOf(doAsGroupId)) %>&cssPath=<%= HttpUtil.encodeURL(themeDisplay.getPathThemeCss()) %>&cssClasses=<%= HttpUtil.encodeURL(cssClasses) %>&languageId=<%= HttpUtil.encodeURL(LocaleUtil.toLanguageId(locale)) %><%= configParamsSB.toString() %>';\r
+\r
+ fckEditor.BasePath = '<%= PortalUtil.getPathContext() %>/html/js/editor/fckeditor/';\r
+ fckEditor.Width = '100%';\r
+ fckEditor.Height = '100%';\r
+ fckEditor.ToolbarSet = '<%= HtmlUtil.escape(toolbarSet) %>';\r
+\r
+ fckEditor.ReplaceTextarea();\r
+\r
+ // LEP-5707\r
+\r
+ var ua = navigator.userAgent, isFirefox2andBelow = false;\r
+ var agent = /(Firefox)\/(.+)/.exec(ua);\r
+\r
+ if (agent && agent.length && (agent.length == 3)) {\r
+ if (parseInt(agent[2]) && parseInt(agent[2]) < 3) {\r
+ isFirefox2andBelow = true;\r
+ }\r
+ }\r
+\r
+ if (isFirefox2andBelow) {\r
+ var fckInstanceName = fckEditor.InstanceName;\r
+ var fckIframe = document.getElementById(fckInstanceName + '___Frame');\r
+\r
+ var interval = setInterval(\r
+ function() {\r
+ var iframe = fckIframe.contentDocument.getElementsByTagName('iframe');\r
+\r
+ if (iframe.length) {\r
+ iframe = iframe[0];\r
+\r
+ iframe.onload = function(event) {\r
+ clearInterval(interval);\r
+ parent.stop();\r
+ };\r
+ }\r
+ },\r
+ 500);\r
+ }\r
+\r
+ <%\r
+ if (Validator.isNotNull(onChangeMethod)) {\r
+ %>\r
+\r
+ setInterval(\r
+ function() {\r
+ try {\r
+ window['<%= name %>'].onChangeCallback();\r
+ }\r
+ catch (e) {\r
+ }\r
+ },\r
+ 300\r
+ );\r
+\r
+ <%\r
+ }\r
+ %>\r
+\r
+ },\r
+\r
+ <%\r
+ if (Validator.isNotNull(onChangeMethod)) {\r
+ %>\r
+\r
+ onChangeCallback: function() {\r
+ var dirty = FCKeditorAPI.GetInstance('<%= name %>').IsDirty();\r
+\r
+ if (dirty) {\r
+ <%= HtmlUtil.escapeJS(onChangeMethod) %>(window['<%= name %>'].getText());\r
+\r
+ FCKeditorAPI.GetInstance('<%= name %>').ResetIsDirty();\r
+ }\r
+ },\r
+\r
+ <%\r
+ }\r
+ %>\r
+\r
+ setHTML: function(value) {\r
+ FCKeditorAPI.GetInstance('<%= name %>').SetHTML(value);\r
+ }\r
+ };\r
+\r
+ window['<%= name %>'].initFckArea();\r
+</aui:script>\r
+\r
+<div class="<%= cssClass %>">\r
+ <textarea id="<%= name %>" name="<%= name %>" style="display: none;"></textarea>\r
+</div>
\ No newline at end of file