Created
November 23, 2013 02:15
-
-
Save ryanschuhler/7609927 to your computer and use it in GitHub Desktop.
An asset publisher view for translations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%-- | |
/** | |
* 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. | |
*/ | |
--%> | |
<%@ include file="/html/portlet/asset_publisher/init.jsp" %> | |
<% | |
List results = (List)request.getAttribute("view.jsp-results"); | |
int assetEntryIndex = ((Integer)request.getAttribute("view.jsp-assetEntryIndex")).intValue(); | |
AssetEntry assetEntry = (AssetEntry)request.getAttribute("view.jsp-assetEntry"); | |
AssetRendererFactory assetRendererFactory = (AssetRendererFactory)request.getAttribute("view.jsp-assetRendererFactory"); | |
AssetRenderer assetRenderer = (AssetRenderer)request.getAttribute("view.jsp-assetRenderer"); | |
String title = (String)request.getAttribute("view.jsp-title"); | |
if (Validator.isNull(title)) { | |
title = assetRenderer.getTitle(locale); | |
} | |
boolean show = ((Boolean)request.getAttribute("view.jsp-show")).booleanValue(); | |
request.setAttribute("view.jsp-showIconLabel", false); | |
PortletURL viewFullContentURL = renderResponse.createRenderURL(); | |
viewFullContentURL.setParameter("struts_action", "/asset_publisher/view_content"); | |
viewFullContentURL.setParameter("assetEntryId", String.valueOf(assetEntry.getEntryId())); | |
viewFullContentURL.setParameter("type", assetRendererFactory.getType()); | |
if (Validator.isNotNull(assetRenderer.getUrlTitle())) { | |
if (assetRenderer.getGroupId() != scopeGroupId) { | |
viewFullContentURL.setParameter("groupId", String.valueOf(assetRenderer.getGroupId())); | |
} | |
viewFullContentURL.setParameter("urlTitle", assetRenderer.getUrlTitle()); | |
} | |
String viewFullContentURLString = viewFullContentURL.toString(); | |
viewFullContentURLString = HttpUtil.setParameter(viewFullContentURLString, "redirect", currentURL); | |
String viewURL = viewInContext ? assetRenderer.getURLViewInContext(liferayPortletRequest, liferayPortletResponse, viewFullContentURLString) : viewFullContentURL.toString(); | |
viewURL = _checkViewURL(assetEntry, viewInContext, viewURL, currentURL, themeDisplay); | |
JournalArticleAssetRenderer journalArticleAssetRenderer = (JournalArticleAssetRenderer)assetRenderer; | |
JournalArticle journalArticle = journalArticleAssetRenderer.getArticle(); | |
Group controlPanelGroup = GroupLocalServiceUtil.getGroup(themeDisplay.getCompanyId(), GroupConstants.CONTROL_PANEL); | |
long controlPanelPlid = LayoutLocalServiceUtil.getDefaultPlid(controlPanelGroup.getGroupId(), true); | |
PortletURL translateURL = PortletURLFactoryUtil.create(request, PortletKeys.JOURNAL, controlPanelPlid, PortletRequest.RENDER_PHASE); | |
translateURL.setWindowState(WindowState.MAXIMIZED); | |
translateURL.setPortletMode(PortletMode.VIEW); | |
translateURL.setParameter("doAsGroupId", String.valueOf(scopeGroupId)); | |
translateURL.setParameter("refererPlid", String.valueOf(themeDisplay.getRefererPlid())); | |
translateURL.setParameter("struts_action", "/journal/edit_article"); | |
translateURL.setParameter("redirect", String.valueOf(themeDisplay.getURLCurrent())); | |
translateURL.setParameter("articleId", String.valueOf(journalArticle.getArticleId())); | |
translateURL.setParameter("groupId", String.valueOf(scopeGroupId)); | |
translateURL.setParameter("structureId", String.valueOf(journalArticle.getStructureId())); | |
translateURL.setParameter("toLanguageId", String.valueOf(locale)); | |
%> | |
<c:if test="<%= assetEntryIndex == 0 %>"> | |
<ul class="title-list"> | |
</c:if> | |
<li class="title-list <%= assetRendererFactory.getType() %>"> | |
<liferay-ui:icon | |
label="<%= true %>" | |
message="<%= HtmlUtil.escape(title) %>" | |
src="<%= assetRenderer.getIconPath(renderRequest) %>" | |
url="<%= viewURL %>" | |
/> | |
<% | |
for (AssetCategory assetCategory : assetEntry.getCategories()) { | |
String categoryName = "translate_" + locale; | |
if (Validator.equals(assetCategory.getName(), categoryName)) { | |
%> | |
<script type="text/javascript"> | |
AUI().use( | |
'aui-io-request', | |
function (A) { | |
A.io.request( | |
'data/content.html', | |
{ | |
on: { | |
success: function() { | |
var data = this.get('responseData'); | |
alert(data); | |
} | |
} | |
} | |
); | |
} | |
); | |
function removeCategory() { | |
console.log('Remove Category', '<%= assetCategory.getName() %>', 'email web team'); | |
} | |
</script> | |
<a class="btn" href="<%= translateURL %>"><liferay-ui:message key="translate" /></a> | |
<a class="btn" onclick="removeCategory();">Mark as Translated</a> | |
<% | |
} | |
} | |
%> | |
<liferay-util:include page="/html/portlet/asset_publisher/asset_actions.jsp" /> | |
<div class="asset-metadata"> | |
<%@ include file="/html/portlet/asset_publisher/asset_metadata.jspf" %> | |
</div> | |
</li> | |
<c:if test="<%= (assetEntryIndex + 1) == results.size() %>"> | |
</ul> | |
</c:if> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment