{namespace i=TYPO3\CMS\Install\ViewHelpers}

<f:layout name="Step" />

<f:section name="Content">
	<f:render partial="Action/Step/StepCounter.html" arguments="{steps: steps}" />

	<h3>Select database</h3>

	<f:if condition="{isInitialInstallationInProgress}">
		<f:then>
			You have two options:
		</f:then>
	</f:if>

	<form method="post" id="stepInstaller-databaseSelect">
		<f:render partial="Action/Common/HiddenFormFields" arguments="{_all}" />
		<input type="hidden" value="execute" name="install[set]" />

		<fieldset>

			<f:if condition="{isInitialInstallationInProgress}">

				<f:then>
					<f:comment>
						First installation
					</f:comment>
					<ul>
						<li>
							<input
								id="t3-install-form-db-select-type-existing"
								type="radio"
								name="install[values][type]"
								value="existing"
								class="radio"
								checked="checked"
							/>
							<div>
								<label for="t3-install-step-database-existing">Use an existing empty database:</label>
								<select
									id="t3-install-step-database-existing"
									name="install[values][existing]"
									onfocus="document.getElementById('t3-install-form-db-select-type-existing').checked=true;"
								>
									<option value="">-- Select database --</option>
									<f:for each="{databaseList}" as="database">
										<f:if condition="{database.tables}">
											<f:then>
												<option value="{database.name}" disabled="disabled">{database.name} ({database.tables} Tables)</option>
											</f:then>
											<f:else>
												<option value="{database.name}">{database.name}</option>
											</f:else>
										</f:if>
									</f:for>
								</select>
							</div>
						</li>
						<li>
							<input
								id="t3-install-form-db-select-type-new"
								type="radio"
								name="install[values][type]"
								value="new"
								class="radio"
							/>
							<div>
								<label for="t3-install-step-database-new">OR create a new database:</label>
								<p>
									<em>Attention: The database user must have sufficient privileges to create the whole structure.</em>
									<br />
									Enter a name for your TYPO3 database.
								</p>
								<input
									id="t3-install-step-database-new"
									class="t3-install-form-input-text"
									type="text"
									name="install[values][new]"
									checked="checked"
									onfocus="document.getElementById('t3-install-form-db-select-type-new').checked=true;"
								/>
							</div>
						</li>
					</ul>
				</f:then>

				<f:else>
					<f:comment>
						Upgrading
					</f:comment>
					<input
						id="t3-install-form-db-select-type-existing"
						type="hidden"
						name="install[values][type]"
						value="existing"
					/>
					<div>
						<label for="t3-install-step-database-existing">Select an existing database:</label>
						<p>The database will not be altered in any way.</p>
						<select
							id="t3-install-step-database-existing"
							name="install[values][existing]"
							onfocus="document.getElementById('t3-install-form-db-select-type-existing').checked=true;"
						>
							<option value="">Select database</option>
							<f:for each="{databaseList}" as="database">
								<option value="{database}">{database}</option>
							</f:for>
						</select>
					</div>
				</f:else>

			</f:if>

		</fieldset>

		<button type="submit">
			Continue
		</button>
	</form>
</f:section>