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

<aui:fieldset>
	<aui:input name="enabled" type="checkbox" value="<%= PrefsPropsUtil.getBoolean(PropsKeys.AUTO_DEPLOY_ENABLED, PropsValues.AUTO_DEPLOY_ENABLED) %>" />

	<aui:input cssClass="lfr-input-text-container" label="deploy-directory" name="deployDir" size="75" type="text" value="<%= PrefsPropsUtil.getString(PropsKeys.AUTO_DEPLOY_DEPLOY_DIR, PropsValues.AUTO_DEPLOY_DEPLOY_DIR) %>" />

	<aui:input cssClass="lfr-input-text-container" helpMessage='<%= LanguageUtil.format(pageContext, "plugins-will-be-deployed-to-x-if-this-field-is-left-blank", DeployUtil.getAutoDeployServerDestDir()) %>' label="dest-directory" name="destDir" size="75" type="text" value="<%= PrefsPropsUtil.getString(PropsKeys.AUTO_DEPLOY_DEST_DIR, PropsValues.AUTO_DEPLOY_DEST_DIR) %>" />

	<aui:select name="interval">
		<aui:option label="disable" value="0" />

		<%
		long interval = PrefsPropsUtil.getLong(PropsKeys.AUTO_DEPLOY_INTERVAL, PropsValues.AUTO_DEPLOY_INTERVAL);

		for (int i = 0;;) {
			if (i < Time.MINUTE) {
				i += Time.SECOND * 5;
			}
			else {
				i += Time.MINUTE;
			}
		%>

			<aui:option label="<%= LanguageUtil.getTimeDescription(pageContext, i) %>" selected="<%= interval == i %>" value="<%= i %>" />

		<%
			if (i >= (Time.MINUTE * 5)) {
				break;
			}
		}
		%>

	</aui:select>

	<aui:select name="blacklistThreshold">

		<%
		int blacklistThreshold = PrefsPropsUtil.getInteger(PropsKeys.AUTO_DEPLOY_BLACKLIST_THRESHOLD, PropsValues.AUTO_DEPLOY_BLACKLIST_THRESHOLD);

		for (int i = 5; i <= 20; i = i + 5) {
		%>

			<aui:option label="<%= i %>" selected="<%= blacklistThreshold == i %>" />

		<%
		}
		%>

	</aui:select>

	<c:if test="<%= !ServerDetector.isGlassfish() && !ServerDetector.isWebLogic() %>">
		<aui:input name="unpackWar" type="checkbox" value="<%= PrefsPropsUtil.getBoolean(PropsKeys.AUTO_DEPLOY_UNPACK_WAR, PropsValues.AUTO_DEPLOY_UNPACK_WAR) %>" />
	</c:if>

	<aui:input name="customPortletXml" type="checkbox" value="<%= PrefsPropsUtil.getBoolean(PropsKeys.AUTO_DEPLOY_CUSTOM_PORTLET_XML, PropsValues.AUTO_DEPLOY_CUSTOM_PORTLET_XML) %>" />

	<%
	int jbossPrefix = GetterUtil.getInteger(PrefsPropsUtil.getString(PropsKeys.AUTO_DEPLOY_JBOSS_PREFIX, PropsValues.AUTO_DEPLOY_JBOSS_PREFIX));
	%>

	<c:choose>
		<c:when test="<%= ServerDetector.isJBoss() %>">
			<aui:select name="jbossPrefix" showEmptyOption="<%= true %>">

				<%
				for (int i = 1; i < 9; i++) {
				%>

					<aui:option label="<%= i %>" selected="<%= jbossPrefix == i %>" />

				<%
				}
				%>

			</aui:select>
		</c:when>
		<c:otherwise>
			<aui:input name="jbossPrefix" type="hidden" value="<%= jbossPrefix %>" />
		</c:otherwise>
	</c:choose>

	<%
	String tomcatConfDir = PrefsPropsUtil.getString(PropsKeys.AUTO_DEPLOY_TOMCAT_CONF_DIR, PropsValues.AUTO_DEPLOY_TOMCAT_CONF_DIR);
	String tomcatLibDir = PrefsPropsUtil.getString(PropsKeys.AUTO_DEPLOY_TOMCAT_LIB_DIR, PropsValues.AUTO_DEPLOY_TOMCAT_LIB_DIR);
	%>

	<c:choose>
		<c:when test="<%= ServerDetector.isTomcat() %>">
			<aui:input cssClass="lfr-input-text-container" name="tomcatConfDir" size="75" type="text" value="<%= tomcatConfDir %>" />

			<aui:input cssClass="lfr-input-text-container" name="tomcatLibDir" size="75" type="text" value="<%= tomcatLibDir %>" />
		</c:when>
		<c:otherwise>
			<aui:input name="tomcatConfDir" type="hidden" value="<%= tomcatConfDir %>" />

			<aui:input name="tomcatLibDir" type="hidden" value="<%= tomcatLibDir %>" />
		</c:otherwise>
	</c:choose>

	<aui:input cssClass="lfr-textarea-container" helpMessage="enter-one-url-per-line" label="trusted-plugin-repositories" name="pluginRepositoriesTrusted" type="textarea" value="<%= PrefsPropsUtil.getString(PropsKeys.PLUGIN_REPOSITORIES_TRUSTED) %>" />

	<aui:input cssClass="lfr-textarea-container" helpMessage="enter-one-url-per-line" label="untrusted-plugin-repositories" name="pluginRepositoriesUntrusted" type="textarea" value="<%= PrefsPropsUtil.getString(PropsKeys.PLUGIN_REPOSITORIES_UNTRUSTED) %>" />

	<aui:input name="pluginNotificationsEnabled" type="checkbox" value="<%= PrefsPropsUtil.getBoolean(PropsKeys.PLUGIN_NOTIFICATIONS_ENABLED) %>" />

	<aui:input cssClass="lfr-textarea-container" helpMessage="enter-one-plugin-package-id-per-line" label="plugin-packages-with-updates-ignored" name="pluginPackagesIgnored" type="textarea" value="<%= GetterUtil.getString(PrefsPropsUtil.getString(PropsKeys.PLUGIN_NOTIFICATIONS_PACKAGES_IGNORED)) %>" />
</aui:fieldset>

<liferay-util:include page="/html/portlet/plugin_installer/repository_report.jsp" />

<aui:button-row>
	<aui:button onClick='<%= renderResponse.getNamespace() + "saveDeployConfiguration();" %>' value="save" />
</aui:button-row>

<c:if test="<%= windowState.equals(WindowState.MAXIMIZED) %>">
	<aui:script>
		Liferay.Util.focusFormField(document.<portlet:namespace />fm.<portlet:namespace />deployDir);
	</aui:script>
</c:if>