<%
/**
 * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
%>

<table class="lfr-table">
<tr>
	<td>
		<liferay-ui:message key="enabled" />
	</td>
	<td>
		<liferay-ui:input-checkbox param="enabled" defaultValue="<%= PrefsPropsUtil.getBoolean(PropsKeys.AUTO_DEPLOY_ENABLED, PropsValues.AUTO_DEPLOY_ENABLED) %>" />
	</td>
</tr>
<tr>
	<td>
		<liferay-ui:message key="deploy-directory" />
	</td>
	<td>
		<input name="<portlet:namespace />deployDir" size="75" type="text" value="<%= PrefsPropsUtil.getString(PropsKeys.AUTO_DEPLOY_DEPLOY_DIR, PropsValues.AUTO_DEPLOY_DEPLOY_DIR) %>" />
	</td>
</tr>
<tr>
	<td>
		<liferay-ui:message key="dest-directory" />
	</td>
	<td>
		<input name="<portlet:namespace />destDir" size="75" type="text" value="<%= PrefsPropsUtil.getString(PropsKeys.AUTO_DEPLOY_DEST_DIR, PropsValues.AUTO_DEPLOY_DEST_DIR) %>" />

		<liferay-ui:icon-help message='<%= LanguageUtil.format(pageContext, "plugins-will-be-deployed-to-x-if-this-field-is-left-blank", DeployUtil.getAutoDeployServerDestDir()) %>' />
	</td>
</tr>
<tr>
	<td>
		<liferay-ui:message key="interval" />
	</td>
	<td>
		<select name="<portlet:namespace />interval">
			<option value="0"><liferay-ui:message key="disable" /></option>

			<%
			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;
				}
			%>

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

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

		</select>
	</td>
</tr>
<tr>
	<td>
		<liferay-ui:message key="blacklist-threshold" />
	</td>
	<td>
		<select name="<portlet:namespace />blacklistThreshold">

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

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

				<option <%= (blacklistThreshold == i) ? "selected" : "" %> value="<%= i %>"><%= i %></option>

			<%
			}
			%>

		</select>
	</td>
</tr>

<c:if test="<%= !ServerDetector.isGlassfish() && !ServerDetector.isWebLogic() %>">
	<tr>
		<td>
			<liferay-ui:message key="unpack-war" />
		</td>
		<td>
			<liferay-ui:input-checkbox param="unpackWar" defaultValue="<%= PrefsPropsUtil.getBoolean(PropsKeys.AUTO_DEPLOY_UNPACK_WAR, PropsValues.AUTO_DEPLOY_UNPACK_WAR) %>" />
		</td>
	</tr>
</c:if>

<tr>
	<td>
		<liferay-ui:message key="custom-portlet-xml" />
	</td>
	<td>
		<liferay-ui:input-checkbox param="customPortletXml" defaultValue="<%= PrefsPropsUtil.getBoolean(PropsKeys.AUTO_DEPLOY_CUSTOM_PORTLET_XML, PropsValues.AUTO_DEPLOY_CUSTOM_PORTLET_XML) %>" />
	</td>
</tr>

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

<c:choose>
	<c:when test="<%= ServerDetector.isJBoss() %>">
		<tr>
			<td colspan="2">
				<br />
			</td>
		</tr>
		<tr>
			<td>
				<liferay-ui:message key="jboss-prefix" />
			</td>
			<td>
				<select name="<portlet:namespace />jbossPrefix">
					<option></option>

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

						<option <%= jbossPrefix == i ? "selected" : "" %> value="<%= i %>"><%= i %></option>

					<%
					}
					%>

				</select>
			</td>
		</tr>
	</c:when>
	<c:otherwise>
		<input name="<portlet:namespace />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() %>">
		<tr>
			<td colspan="2">
				<br />
			</td>
		</tr>
		<tr>
			<td>
				<liferay-ui:message key="tomcat-conf-dir" />
			</td>
			<td>
				<input name="<portlet:namespace />tomcatConfDir" size="75" type="text" value="<%= tomcatConfDir %>" />
			</td>
		</tr>
		<tr>
			<td>
				<liferay-ui:message key="tomcat-lib-dir" />
			</td>
			<td>
				<input name="<portlet:namespace />tomcatLibDir" size="75" type="text" value="<%= tomcatLibDir %>" />
			</td>
		</tr>
	</c:when>
	<c:otherwise>
		<input name="<portlet:namespace />tomcatConfDir" type="hidden" value="<%= tomcatConfDir %>" />
		<input name="<portlet:namespace />tomcatLibDir" type="hidden" value="<%= tomcatLibDir %>" />
	</c:otherwise>
</c:choose>

<tr>
	<td colspan="2">
		<br />
	</td>
</tr>
<tr>
	<td>
		<liferay-ui:message key="trusted-plugin-repositories" /><br />

		<span style="font-size: xx-small;">(<liferay-ui:message key="enter-one-url-per-line" />)</span>
	</td>
	<td>
		<textarea class="lfr-textarea" name="<portlet:namespace />pluginRepositoriesTrusted" wrap="soft"><%= PrefsPropsUtil.getString(PropsKeys.PLUGIN_REPOSITORIES_TRUSTED) %></textarea>
	</td>
</tr>
<tr>
	<td colspan="2">
		<br />
	</td>
</tr>
<tr>
	<td>
		<liferay-ui:message key="untrusted-plugin-repositories" /><br />

		<span style="font-size: xx-small;">(<liferay-ui:message key="enter-one-url-per-line" />)</span>
	</td>
	<td>
		<textarea class="lfr-textarea" name="<portlet:namespace />pluginRepositoriesUntrusted" wrap="soft"><%= PrefsPropsUtil.getString(PropsKeys.PLUGIN_REPOSITORIES_UNTRUSTED) %></textarea>
	</td>
</tr>
<tr>
	<td colspan="2">
		<br />
	</td>
</tr>
<tr>
	<td>
		<liferay-ui:message key="plugin-notifications-enabled" />
	</td>
	<td>
		<liferay-ui:input-checkbox param="pluginNotificationsEnabled" defaultValue="<%= PrefsPropsUtil.getBoolean(PropsKeys.PLUGIN_NOTIFICATIONS_ENABLED) %>" />
	</td>
</tr>
<tr>
	<td colspan="2">
		<br />
	</td>
</tr>
<tr>
	<td>
		<liferay-ui:message key="plugin-packages-with-updates-ignored" /><br />

		<span style="font-size: xx-small;">(<liferay-ui:message key="enter-one-plugin-package-id-per-line" />)</span>
	</td>
	<td>
		<textarea class="lfr-textarea" name="<portlet:namespace />pluginPackagesIgnored" wrap="soft"><%= GetterUtil.getString(PrefsPropsUtil.getString(PropsKeys.PLUGIN_NOTIFICATIONS_PACKAGES_IGNORED)) %></textarea>
	</td>
</tr>
<tr>
	<td colspan="2">
		<br />
	</td>
</tr>
</table>

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

<br />

<input type="button" value="<liferay-ui:message key="save" />" onClick="<portlet:namespace />saveDeployConfiguration();" />

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