<%@ page import="com.atlassian.jira.util.BuildUtils"%>
<%@ taglib uri="webwork" prefix="webwork" %>
<%@ taglib uri="webwork" prefix="ui" %>
<%@ taglib uri="sitemesh-page" prefix="page" %>
<html>
<head>
	<title><webwork:text name="'setup.title'" /></title>
</head>
<body>
<table width="100%" border="0" cellpadding="4">
<tr>
<td width="80%" valign="top">
<page:applyDecorator name="jiraform">
	<page:param name="title"><webwork:text name="'setup.step1'" /></page:param>
	<page:param name="width">100%</page:param>
	<page:param name="description">
        <webwork:text name="'setup.globalproperties'" />
        <p>
        <webwork:text name="'setup.existingimport'">
            <webwork:param name="'value0'"><font color="990000"></webwork:param>
            <webwork:param name="'value1'"></font></webwork:param>
            <webwork:param name="'value2'"><a href="SetupImport!default.jspa"></webwork:param>
            <webwork:param name="'value3'"></a></webwork:param>
        </webwork:text>
    </page:param>
	<page:param name="action">Setup.jspa</page:param>

	<ui:textfield label="text('setup.applicationtitle.label')" name="'title'">
		<ui:param name="'size'">40</ui:param>
		<ui:param name="'description'">
			<webwork:text name="'setup.applicationtitle.desc'" />
		</ui:param>
		<ui:param name="'mandatory'" value="true" />
	</ui:textfield>

	<ui:select label="text('setup.mode.label')" name="'mode'"
		list="allowedModes" listKey="'key'" listValue="'value'">
		<ui:param name="'description'">
			<webwork:text name="'setup.mode.line1.desc'" />:<br>
			<webwork:text name="'setup.mode.line2.desc'" /><br>
			<webwork:text name="'setup.mode.line3.desc'" />.
		</ui:param>
		<ui:param name="'mandatory'" value="true" />
	</ui:select>

	<ui:textfield label="text('setup.baseurl.label')" name="'baseURL'">
        <ui:param name="'size'">40</ui:param>
		<ui:param name="'description'">
			<webwork:text name="'setup.baseurl.desc'" />
		</ui:param>
		<ui:param name="'mandatory'" value="true" />
	</ui:textfield>

	<ui:textfield label="text('setup.indexpath.label')" name="'indexPath'">
        <ui:param name="'size'">40</ui:param>
		<ui:param name="'description'">
            <webwork:text name="'setup.indexpath.desc'" />
		</ui:param>
		<ui:param name="'mandatory'" value="true" />
	</ui:textfield>

    <ui:textfield label="text('setup.attachmentpath.label')" name="'attachmentPath'">
        <ui:param name="'size'">40</ui:param>
		<ui:param name="'description'">
            <webwork:text name="'setup.attachmentpath.desc'" />
		</ui:param>
	</ui:textfield>

    <script language="javascript" type="text/javascript">
        window.onload = function()
        {
            togglebackuppath(document.jiraform.enableBackup_true.checked);
        }

        function togglebackuppath(enable)
        {
            var element = document.getElementById('backup_path');
            if (element)
            {
                if (enable == 'false' || enable == false)
                {
                    element.disabled = true;
                    element.value = '';
                }
                else
                {
                    element.disabled = false;
                }
            }
        }
    </script>
    <ui:radio label="'Enable Backups'" name="'enableBackup'" list="booleanList" listKey="'id'" listValue="'name'" value="enableBackup">
        <ui:param name="'inline'">true</ui:param>
        <ui:param name="'onclick'">togglebackuppath(this.value)</ui:param>
        <ui:param name="'description'">
            <webwork:text name="'setup.backuppath.line1.desc'" />
        </ui:param>
    </ui:radio>
        <tr align="top">
            <td align="right" bgcolor="fffff0">&nbsp;</td>
            <td bgcolor="ffffff" id="backup_warning"><strong><webwork:text name="'setup.backuppath.line2.desc'" /></strong></td>
        </tr>
    <ui:textfield label="text('setup.backuppath.label')" name="'backupPath'">
        <ui:param name="'size'">40</ui:param>
        <ui:param name="'cssId'">backup_path</ui:param>
        <ui:param name="'description'">
            <webwork:text name="'setup.backuppath.line3.desc'" />
		</ui:param>
    </ui:textfield>

    <tr>
		<td align="right" bgcolor="fffff0">&nbsp;</td>
		<td bgcolor="ffffff">&nbsp;</td>
	</tr>

	<tr>
		<td colspan="2" bgcolor="f0f0f0"><h3 class="formtitle"><webwork:text name="'setup.license.title'" /></h3></td>
	</tr>
    <tr>
        <td align="right" bgcolor="fffff0"><webwork:text name="'admin.server.id'"/>:</td>
		<td bgcolor="ffffff"><webwork:property value="/serverId"/></td>
    </tr>
    <ui:textarea label="text('setup.license.label')" name="'license'" cols="50" rows="6">
		<ui:param name="'description'">
			<webwork:text name="'setup.license.line1.desc'" /><br>
			<webwork:text name="'setup.license.line2.desc'">
                <webwork:param name="'value0'"><a target="_blank" href="<webwork:component name="'external.link.jira.license.view'" template="externallink.jsp" >
                    <webwork:param name="'value0'"><%= BuildUtils.getVersion() %></webwork:param>
                    <webwork:param name="'value1'"><%= BuildUtils.getCurrentBuildNumber() %></webwork:param>
                    <webwork:param name="'value2'"><%= BuildUtils.getEdition() %></webwork:param>
                    <webwork:param name="'value3'"><webwork:property value="/serverId"/></webwork:param>
                </webwork:component>"></webwork:param>
                <webwork:param name="'value1'"></a></webwork:param>
            </webwork:text><br>
		<ui:param name="'mandatory'" value="true" />
		</ui:param>
	</ui:textarea>
    <tr>
        <td bgcolor="ffffff" valign="top" colspan="2" align="center">
        <input type="submit" name="next" value="<webwork:property value="text('common.words.next')"/>&gt;&gt;" accesskey="<webwork:text name="'common.forms.submit.accesskey'"/>">
        <input type="hidden" name="language" value="<webwork:property value="language"/>"/>
        </td>
    </tr>
</page:applyDecorator>
</td>
<td width="20%" valign="top">
<page:applyDecorator name="jirapanel">
    <page:param name="title">Choose Language</page:param>
    <page:param name="width">100%</page:param>
    <page:param name="description"> </page:param>

    <table align="center">
    <script language="JavaScript">
        function setLanguage(lang)
        {
            var form = document.forms['jiraform'];
            form.elements['language'].value = lang;
            form.submit();
        }
    </script>

    <tr>
    <webwork:iterator value="/jiraLocaleUtils/installedLocales" status="'status'">
        <td align="center">
            <webwork:if test="./toString == /applicationProperties/defaultLocale/toString">
                <img src="<%= request.getContextPath() %>/images/flags/<webwork:property value="./toString"/>.gif">
            </webwork:if>
            <webwork:else>
                <a href="javascript:setLanguage('<webwork:property value="./toString"/>');"><img border="0" src="<%= request.getContextPath() %>/images/flags/<webwork:property value="./toString"/>.gif"></a>
            </webwork:else>
            <br/>

            <webwork:if test="./toString == /applicationProperties/defaultLocale/toString">
                <b><webwork:property value="./displayLanguage"/> (Default)</b>
            </webwork:if>
            <webwork:else>
                <a href="javascript:setLanguage('<webwork:property value="./toString"/>');"><webwork:property value="./displayName"/></a>
            </webwork:else>
        </td>
        <webwork:if test="@status/even == true"> <!-- Display the flags in two columns -->
            </tr>
        </webwork:if>
    </webwork:iterator>

    </table>
</page:applyDecorator>
<webwork:if test="/unavailableLocales/empty == false">
<p>
    <page:applyDecorator name="jirapanel">
    <page:param name="title">Third Party Translations</page:param>
    <page:param name="width">100%</page:param>
    <page:param name="description"> </page:param>
        <table>
            <webwork:iterator value="/unavailableLocales" status="'status'">
                <td align="center">
                <webwork:if test="./toString == /applicationProperties/defaultLocale/toString">
                    <img src="<%= request.getContextPath() %>/images/flags/<webwork:property value="./toString"/>.gif">
                </webwork:if>
                <webwork:else>
                    <a href="SetupDisplayLocaleInfo!default.jspa?localeCode=<webwork:property value="./toString"/>"><img border=0 src="<%= request.getContextPath() %>/images/flags/<webwork:property value="./toString"/>.gif"></a>
                </webwork:else>
                <br/>

                <webwork:if test="./toString == /applicationProperties/defaultLocale/toString">
                    <b><webwork:property value="./displayLanguage"/> (<webwork:text name="'admin.common.words.default'"/>)</b>
                </webwork:if>
                <webwork:else>
                    <a href="SetupDisplayLocaleInfo!default.jspa?localeCode=<webwork:property value="./toString"/>"><webwork:property value="./displayName"/></a>
                </webwork:else>
            </td>
            <webwork:if test="@status/even == true"> <!-- Display the flags in two columns -->
                </tr>
            </webwork:if>
            </webwork:iterator>
        </table>
    </page:applyDecorator>
<p/>
</webwork:if>
</td>
</tr>
</table>
</body>
</html>
