<%
/**
 * 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.
 */
%>

<%
List<ColorScheme> colorSchemes = selTheme.getColorSchemes();

PluginPackage selPluginPackage = selTheme.getPluginPackage();
%>

<aui:input name="themeId" type="hidden" value="<%= selTheme.getThemeId() %>" />
<aui:input name="colorSchemeId" type="hidden" value="<%= selColorScheme.getColorSchemeId() %>" />

<div class="lfr-theme-list">
	<div class="float-container lfr-current-theme">
		<h3><liferay-ui:message key="current-theme" /></h3>

		<img alt="<%= selTheme.getName() %>" class="theme-screenshot" src="<%= selTheme.getContextPath() %><%= selTheme.getImagesPath() %>/thumbnail.png" title="<%= selTheme.getName() %>" />

		<div class="theme-details">
			<h4 class="theme-title"><%= selTheme.getName() %></h4>

			<dl>
				<c:if test="<%= Validator.isNotNull(selPluginPackage.getShortDescription()) %>">
					<dt>
						<liferay-ui:message key="description" />
					</dt>
					<dd>
						<%= selPluginPackage.getShortDescription() %>
					</dd>
				</c:if>

				<c:if test="<%= Validator.isNotNull(selPluginPackage.getAuthor()) %>">
					<dt>
						<liferay-ui:message key="author" />
					</dt>
					<dd>
						<a href="<%= selPluginPackage.getPageURL() %>"><%= selPluginPackage.getAuthor() %></a>
					</dd>
				</c:if>
			</dl>

			<c:if test="<%= !colorSchemes.isEmpty() %>">
				<liferay-ui:panel collapsible="<%= true %>" extended="<%= false %>" id="themeColorSchemesPanel" persistState="<%= true %>" title='<%= LanguageUtil.format(pageContext, "color-schemes-x", colorSchemes.size()) %>'>
					<ul class="lfr-component lfr-theme-list">

						<%
						Iterator<ColorScheme> itr = colorSchemes.iterator();

						while (itr.hasNext()) {
							ColorScheme curColorScheme = itr.next();

							String cssClass = StringPool.BLANK;

							if (selColorScheme.getColorSchemeId().equals(curColorScheme.getColorSchemeId())) {
								cssClass = "selected-color-scheme";
							}
						%>

							<li class="<%= cssClass %>">
								<a class="theme-entry" href="javascript:<portlet:namespace />updateLookAndFeel('<%= selTheme.getThemeId() %>', '<%= curColorScheme.getColorSchemeId() %>', '');">
									<span class="theme-title">
										<%= curColorScheme.getName() %>
									</span>

									<img alt="<%= curColorScheme.getName() %>" class="theme-thumbnail" src="<%= selTheme.getContextPath() %><%= curColorScheme.getColorSchemeThumbnailPath() %>/thumbnail.png" title="<%= curColorScheme.getName() %>" />
								</a>
							</li>

						<%
						}
						%>

					</ul>
				</liferay-ui:panel>
			</c:if>
		</div>
	</div>

	<div class="float-container lfr-available-themes">
		<h3>
			<span class="header-title">
				<%= LanguageUtil.format(pageContext, "available-themes-x", (themes.size() - 1)) %>
			</span>

			<c:if test="<%= permissionChecker.isOmniadmin() && PrefsPropsUtil.getBoolean(PropsKeys.AUTO_DEPLOY_ENABLED, PropsValues.AUTO_DEPLOY_ENABLED) %>">

				<%
				PortletURL installPluginsURL = ((RenderResponseImpl)renderResponse).createRenderURL(PortletKeys.PLUGIN_INSTALLER);

				installPluginsURL.setParameter("struts_action", "/plugin_installer/view");
				installPluginsURL.setParameter("backURL", currentURL);
				installPluginsURL.setParameter("tabs2", "theme-plugins");
				%>

				<span class="install-themes">
					<a href="<%= installPluginsURL %>"><liferay-ui:message key="install-more" /></a>
				</span>
			</c:if>
		</h3>

		<c:if test="<%= themes.size() > 1 %>">
			<ul class="lfr-component lfr-theme-list">

				<%
				Iterator<Theme> itr = themes.iterator();

				while (itr.hasNext()) {
					Theme curTheme = itr.next();

					if (!selTheme.getThemeId().equals(curTheme.getThemeId())) {
				%>

						<li>
							<a class="theme-entry" href="javascript:<portlet:namespace />updateLookAndFeel('<%= curTheme.getThemeId() %>', '');">
								<span class="theme-title">
									<%= curTheme.getName() %>
								</span>

								<img alt="<%= curTheme.getName() %>" class="theme-thumbnail" src="<%= curTheme.getContextPath() %><%= curTheme.getImagesPath() %>/thumbnail.png" title="<%= curTheme.getName() %>" />
							</a>
						</li>

				<%
					}
				}
				%>

			</ul>
		</c:if>
	</div>
</div>