Location: PHPKode > projects > XaJaQ > xajaq/include/php/forms.inc.php
<?php

/* 
	forms.inc.php is part of XaJaQ, see http://xajaq.sourceforge.net/
	
	Copyright 2005-2007 Dennis Toddenroth

	Licensed under the Apache License, Version 2.0 (the "License");
	you may not use this file except in compliance with the License.
	You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the License for the specific language governing permissions and
	limitations under the License.
*/

function saveDialog($currentFile ) {
	return "<form name=\"Formular\" action=\"?\"
		method=\"post\" onsubmit=\"return setSerialContainer( ); \">
		<input type=\"hidden\" name=\"SERIAL_CONTAINER\" id=\"SERIAL_CONTAINER\" />
		<input type=\"submit\" value=\"save\" /> 
		this session as 
		<input 
			type=\"text\" 
			name=\"SAVENAME\" 
			size=\"64\" 
			maxlength=\"64\" 
			value=\"$currentFile\" /></form> ";
}

function hash2dropdown($title, $hash, $isHash = false ) {
	$dropdown = "<tr><td><p>$title</p></td><td><p><select name=\"$title\" >\n";
	foreach ($hash as $key => $value ) {
		$return = ($isHash ) ? $key : $value;
		$dropdown .= "<option value=\"$return\">$value</option>\n";
	}
	$dropdown .= "</select></p></td></tr>\n";
	return $dropdown;
}

function createDialog($themes, $resolutions, $defaultDbHost = "localhost", $defaultDbUsername = "", $defaultDbPassword = "" ) {
	$dbDrivers = array(
		"mysql" => "MySQL", 
		"pgsql" => "PostgreSQL", 
		"oci" => "Oracle", 
	);
	?>
	<form name="Formular" action="?" method="post" >
		<table>
		<?php echo hash2dropdown("driver", $dbDrivers, true )?>
		<tr><td><p>host</p></td><td><p>
		<input 
			type="text" 
			name="host" 
			size="64" 
			maxlength="64" 
			value="<?php echo $defaultDbHost; ?>" 
		/>
		</p></td></tr>
		<tr><td><p>username</p></td><td><p>
		<input 
			type="text" 
			name="username" 
			size="64" 
			maxlength="64" 
			value="<?php echo $defaultDbUsername; ?>" 
		/>
		</p></td></tr>
		<tr><td><p>password</p></td><td><p>
		<input 
			type="password" 
			name="password" 
			size="64" 
			maxlength="64" 
			value="<?php echo $defaultDbPassword; ?>" 
		/>
		</p></td></tr>
		<tr><td><p>database</p></td><td><p>
		<input 
			type="text" 
			name="database" 
			size="64" 
			maxlength="64" 
			value="" 
		/>
		</p></td></tr>
		<?php echo hash2dropdown("resolution", $resolutions )?>
		<?php echo hash2dropdown("theme", array_keys($themes ) )?>
		<tr><td/><td><p>
		<input type="submit" value="create new session" />
		</p></td></tr>
		</table>
	</form>
	<?php 
}

?>
Return current item: XaJaQ