PageRenderTime 102ms CodeModel.GetById 9ms RepoModel.GetById 0ms app.codeStats 0ms

/portal-web/docroot/html/portlet/portlet_configuration/export_import.jsp

http://github.com/liferay/liferay-portal
JavaServer Pages | 248 lines | 186 code | 49 blank | 13 comment | 27 complexity | bb0c5f2e1268c3b18c088f78fa586ff0 MD5 | raw file
Possible License(s): LGPL-2.0
  1. <%--
  2. /**
  3. * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
  4. *
  5. * This library is free software; you can redistribute it and/or modify it under
  6. * the terms of the GNU Lesser General Public License as published by the Free
  7. * Software Foundation; either version 2.1 of the License, or (at your option)
  8. * any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful, but WITHOUT
  11. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  12. * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
  13. * details.
  14. */
  15. --%>
  16. <%@ include file="/html/portlet/portlet_configuration/init.jsp" %>
  17. <%
  18. String tabs2 = ParamUtil.getString(request, "tabs2", "export");
  19. String redirect = ParamUtil.getString(request, "redirect");
  20. String returnToFullPageURL = ParamUtil.getString(request, "returnToFullPageURL");
  21. String selPortletPrimaryKey = PortletPermissionUtil.getPrimaryKey(layout.getPlid(), selPortlet.getPortletId());
  22. PortletURL portletURL = renderResponse.createRenderURL();
  23. portletURL.setParameter("struts_action", "/portlet_configuration/export_import");
  24. portletURL.setParameter("redirect", redirect);
  25. portletURL.setParameter("returnToFullPageURL", returnToFullPageURL);
  26. portletURL.setParameter("portletResource", portletResource);
  27. boolean supportsLAR = Validator.isNotNull(selPortlet.getPortletDataHandlerClass());
  28. boolean supportsSetup = Validator.isNotNull(selPortlet.getConfigurationActionClass());
  29. boolean controlPanel = false;
  30. if (layout.isTypeControlPanel()) {
  31. Group scopeGroup = themeDisplay.getScopeGroup();
  32. if (scopeGroup.isLayout()) {
  33. layout = LayoutLocalServiceUtil.getLayout(scopeGroup.getClassPK());
  34. }
  35. else if (!scopeGroup.isCompany()) {
  36. long defaultPlid = LayoutLocalServiceUtil.getDefaultPlid(scopeGroupId);
  37. if (defaultPlid > 0) {
  38. layout = LayoutLocalServiceUtil.getLayout(defaultPlid);
  39. }
  40. }
  41. supportsSetup = false;
  42. controlPanel = true;
  43. }
  44. %>
  45. <c:choose>
  46. <c:when test="<%= supportsLAR || supportsSetup %>">
  47. <%
  48. String tabs2Names = "export,import";
  49. Group scopeGroup = themeDisplay.getScopeGroup();
  50. if (scopeGroup.isStagingGroup()) {
  51. tabs2Names += ",staging";
  52. }
  53. else if (scopeGroup.isLayout()) {
  54. Group parentScopeGroup = GroupServiceUtil.getGroup(scopeGroup.getParentGroupId());
  55. if (parentScopeGroup.isStagingGroup()) {
  56. tabs2Names += ",staging";
  57. }
  58. }
  59. %>
  60. <liferay-ui:tabs
  61. backURL="<%= redirect %>"
  62. names="<%= tabs2Names %>"
  63. param="tabs2"
  64. url="<%= portletURL.toString() %>"
  65. />
  66. <liferay-ui:error exception="<%= LARFileException.class %>" message="please-specify-a-lar-file-to-import" />
  67. <liferay-ui:error exception="<%= LARTypeException.class %>" message="please-import-a-lar-file-of-the-correct-type" />
  68. <liferay-ui:error exception="<%= LayoutImportException.class %>" message="an-unexpected-error-occurred-while-importing-your-file" />
  69. <liferay-ui:error exception="<%= LocaleException.class %>">
  70. <%
  71. LocaleException le = (LocaleException)errorException;
  72. %>
  73. <liferay-ui:message arguments="<%= new String[] {StringUtil.merge(le.getSourceAvailableLocales(), StringPool.COMMA_AND_SPACE), StringUtil.merge(le.getTargetAvailableLocales(), StringPool.COMMA_AND_SPACE)} %>" key="the-available-languages-in-the-lar-file-x-do-not-match-the-portal's-available-languages-x" />
  74. </liferay-ui:error>
  75. <liferay-ui:error exception="<%= NoSuchLayoutException.class %>" message="an-error-occurred-because-the-live-group-does-not-have-the-current-page" />
  76. <liferay-ui:error exception="<%= PortletIdException.class %>" message="please-import-a-lar-file-for-the-current-portlet" />
  77. <liferay-ui:error exception="<%= PortletDataException.class %>">
  78. <%
  79. PortletDataException pde = (PortletDataException)errorException;
  80. %>
  81. <c:if test="<%= pde.getType() == PortletDataException.FUTURE_END_DATE %>">
  82. <liferay-ui:message key="please-enter-a-valid-end-date-that-is-in-the-past" />
  83. </c:if>
  84. <c:if test="<%= pde.getType() == PortletDataException.FUTURE_START_DATE %>">
  85. <liferay-ui:message key="please-enter-a-valid-start-date-that-is-in-the-past" />
  86. </c:if>
  87. <c:if test="<%= pde.getType() == PortletDataException.START_DATE_AFTER_END_DATE %>">
  88. <liferay-ui:message key="please-enter-a-start-date-that-comes-before-the-end-date" />
  89. </c:if>
  90. </liferay-ui:error>
  91. <portlet:actionURL var="exportImportPagesURL">
  92. <portlet:param name="struts_action" value="/portlet_configuration/export_import" />
  93. </portlet:actionURL>
  94. <aui:form action="<%= exportImportPagesURL %>" method="post" name="fm">
  95. <aui:input name="tabs1" type="hidden" value="export_import" />
  96. <aui:input name="tabs2" type="hidden" value="<%= tabs2 %>" />
  97. <aui:input name="plid" type="hidden" value="<%= layout.getPlid() %>" />
  98. <aui:input name="groupId" type="hidden" value="<%= themeDisplay.getScopeGroupId() %>" />
  99. <aui:input name="portletResource" type="hidden" value="<%= portletResource %>" />
  100. <aui:input name="redirect" type="hidden" value="<%= currentURL %>" />
  101. <%
  102. String errorMessageKey = StringPool.BLANK;
  103. if (tabs2.equals("staging")) {
  104. Group stagingGroup = themeDisplay.getScopeGroup();
  105. Group liveGroup = stagingGroup.getLiveGroup();
  106. Layout targetLayout = null;
  107. if (!controlPanel) {
  108. if (liveGroup == null) {
  109. errorMessageKey = "this-portlet-is-placed-in-a-page-that-does-not-exist-in-the-live-site-publish-the-page-first";
  110. }
  111. else {
  112. try {
  113. if (stagingGroup.isLayout()) {
  114. targetLayout = LayoutLocalServiceUtil.getLayout(liveGroup.getClassPK());
  115. }
  116. else {
  117. targetLayout = LayoutLocalServiceUtil.getLayoutByUuidAndGroupId(layout.getUuid(), liveGroup.getGroupId());
  118. }
  119. }
  120. catch (NoSuchLayoutException nsle) {
  121. errorMessageKey = "this-portlet-is-placed-in-a-page-that-does-not-exist-in-the-live-site-publish-the-page-first";
  122. }
  123. if (targetLayout != null) {
  124. LayoutType layoutType = targetLayout.getLayoutType();
  125. if (!(layoutType instanceof LayoutTypePortlet) || !((LayoutTypePortlet)layoutType).hasPortletId(selPortlet.getPortletId())) {
  126. errorMessageKey = "this-portlet-has-not-been-added-to-the-live-page-publish-the-page-first";
  127. }
  128. }
  129. }
  130. }
  131. else if (stagingGroup.isLayout()) {
  132. if (liveGroup == null) {
  133. errorMessageKey = "a-portlet-is-placed-in-this-page-of-scope-that-does-not-exist-in-the-live-site-publish-the-page-first";
  134. }
  135. else {
  136. try {
  137. targetLayout = LayoutLocalServiceUtil.getLayout(liveGroup.getClassPK());
  138. }
  139. catch (NoSuchLayoutException nsle) {
  140. errorMessageKey = "a-portlet-is-placed-in-this-page-of-scope-that-does-not-exist-in-the-live-site-publish-the-page-first";
  141. }
  142. }
  143. }
  144. }
  145. %>
  146. <c:choose>
  147. <c:when test="<%= Validator.isNull(errorMessageKey) %>">
  148. <aui:fieldset>
  149. <%@ include file="/html/portlet/portlet_configuration/export_import_options.jspf" %>
  150. <aui:button-row>
  151. <c:choose>
  152. <c:when test='<%= tabs2.equals("export") %>'>
  153. <aui:button onClick='<%= renderResponse.getNamespace() + "exportData();" %>' value="export" />
  154. <aui:button href="<%= redirect %>" type="cancel" />
  155. </c:when>
  156. <c:when test='<%= tabs2.equals("import") %>'>
  157. <aui:button onClick='<%= renderResponse.getNamespace() + "importData();" %>' value="import" />
  158. <aui:button href="<%= redirect %>" type="cancel" />
  159. </c:when>
  160. <c:when test='<%= tabs2.equals("staging") %>'>
  161. <c:if test="<%= (themeDisplay.getURLPublishToLive() != null) || controlPanel %>">
  162. <aui:button onClick='<%= renderResponse.getNamespace() + "publishToLive();" %>' value="publish-to-live" />
  163. <aui:button onClick='<%= renderResponse.getNamespace() + "copyFromLive();" %>' value="copy-from-live" />
  164. </c:if>
  165. </c:when>
  166. </c:choose>
  167. </aui:button-row>
  168. </aui:fieldset>
  169. </c:when>
  170. <c:otherwise>
  171. <liferay-ui:message key="<%= errorMessageKey %>" />
  172. </c:otherwise>
  173. </c:choose>
  174. </aui:form>
  175. </c:when>
  176. <c:otherwise>
  177. <%= LanguageUtil.format(locale, "the-x-portlet-does-not-have-any-data-that-can-be-exported-or-does-not-include-support-for-it", HtmlUtil.escape(PortalUtil.getPortletTitle(selPortlet, application, locale))) %>
  178. </c:otherwise>
  179. </c:choose>
  180. <aui:script>
  181. function <portlet:namespace />copyFromLive() {
  182. if (confirm('<%= UnicodeLanguageUtil.get(pageContext, "are-you-sure-you-want-to-copy-from-live-and-update-the-existing-staging-portlet-information") %>')) {
  183. submitForm(document.<portlet:namespace />fm, '<portlet:actionURL><portlet:param name="struts_action" value="/portlet_configuration/export_import" /><portlet:param name="<%= Constants.CMD %>" value="copy_from_live" /></portlet:actionURL>');
  184. }
  185. }
  186. function <portlet:namespace />exportData() {
  187. document.<portlet:namespace />fm.encoding = "multipart/form-data";
  188. submitForm(document.<portlet:namespace />fm, '<portlet:actionURL windowState="<%= LiferayWindowState.EXCLUSIVE.toString() %>"><portlet:param name="struts_action" value="/portlet_configuration/export_import" /><portlet:param name="<%= Constants.CMD %>" value="<%= Constants.EXPORT %>" /></portlet:actionURL>&etag=0&strip=0', false);
  189. }
  190. function <portlet:namespace />importData() {
  191. document.<portlet:namespace />fm.encoding = "multipart/form-data";
  192. submitForm(document.<portlet:namespace />fm, '<portlet:actionURL><portlet:param name="struts_action" value="/portlet_configuration/export_import" /><portlet:param name="<%= Constants.CMD %>" value="<%= Constants.IMPORT %>" /></portlet:actionURL>');
  193. }
  194. function <portlet:namespace />publishToLive() {
  195. if (confirm('<%= UnicodeLanguageUtil.get(pageContext, "are-you-sure-you-want-to-publish-to-live-and-update-the-existing-portlet-data") %>')) {
  196. submitForm(document.<portlet:namespace />fm, '<portlet:actionURL><portlet:param name="struts_action" value="/portlet_configuration/export_import" /><portlet:param name="<%= Constants.CMD %>" value="publish_to_live" /></portlet:actionURL>');
  197. }
  198. }
  199. </aui:script>