<%
/**
 * Copyright (c) 2000-2011 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.
 */
%>

<%
String entryClassName = entry.getClassName();
long entryClassPK = entry.getClassPK();

String scopeName = StringPool.BLANK;
String scopeClassName = StringPool.BLANK;

if (entryClassName.equals(Group.class.getName())) {
	Group group = GroupLocalServiceUtil.getGroup(entryClassPK);

	scopeName = group.getDescriptiveName();
	scopeClassName = "community";
}
else if (entryClassName.equals(Organization.class.getName())) {
	Organization organization = OrganizationLocalServiceUtil.getOrganization(entryClassPK);

	scopeName = organization.getName();
	scopeClassName = "organization";
}
else if (entryClassName.equals(Role.class.getName())) {
	Role role = RoleLocalServiceUtil.getRole(entryClassPK);

	scopeName = role.getTitle(locale);
	scopeClassName = "role";
}
else if (entryClassName.equals(User.class.getName())) {
	User curUser = UserLocalServiceUtil.getUser(entryClassPK);

	scopeName = curUser.getFullName();
	scopeClassName = "personal";
}
else if (entryClassName.equals(UserGroup.class.getName())) {
	UserGroup userGroup = UserGroupLocalServiceUtil.getUserGroup(entryClassPK);

	scopeName = userGroup.getName();
	scopeClassName = "user-group";
}
else {
	scopeName = LanguageUtil.get(locale, "general");
	scopeClassName = scopeName;
}

scopeName = HtmlUtil.escape(scopeName);
%>

<c:choose>
	<c:when test="<%= showScopeName %>">
		<c:choose>
			<c:when test="<%= scopeName.equals(scopeClassName) %>">
				<%= scopeName %>
			</c:when>
			<c:otherwise>
				<liferay-ui:message key="<%= scopeClassName %>" /> &raquo; <%= scopeName %>
			</c:otherwise>
		</c:choose>
	</c:when>
	<c:otherwise>
		<span class="entry-scope"><%= scopeName %></span>
	</c:otherwise>
</c:choose>