<commit_before><?php
// Software Inc Furniture XML Generator
// Author: Demannu

// XML Skeleton(Only the bare minimum should be in here)
$xmlSkeleton = <<<XML
<Root>
	<Models>
		<Model>
			<File></File>
			<Position></Position>
			<Rotation></Rotation>
			<Scale></Scale>
		</Model>
	</Models>
	<Furniture>
		<Category></Category>
		<Cost></Cost>
		<ButtonDescription></ButtonDescription>
		<UnlockYear></UnlockYear>
		<PrimaryColorName></PrimaryColorName>
		<ColorPrimaryDefault></ColorPrimaryDefault>
	</Furniture>
</Root>
XML;

$baseFurnitureTypes = array(
	"Office" => array(
		"Table",
		"Glass Table",
		"2m End Table",
		"3m End Table",
		"Cheap Chair",
		"Office Chair",
		"Old Computer",
		"90s Computer",
		"Laptop",
		"Modern Computer",
		"HoloComputer",
		"Cubicle Wall",
		"TV",
		"Bookshelf",
		"Phone",
		"Drawing Tablet",
		"Calculator",
		"Inbox",
	),
	"Reception" => array(
		"Waiting Chairs",
		"Couch",
		"Reception Desk",
	),
	"Outdoor" => array(
		"Bench",
		"Outdoor Lamp",
		"Small tree",
		"Small pine tree",
	),
	"Temperature" => array(
		"Small Heater",
		"Ceiling Fan",
		"Radiator",
		"Ventilation",
		"Central Heating",
		"AC Unit",
		"Industrial ventilation",
	),
	"Lighting" => array(
		"Lamp",
		"Wall Lamp",
		"Desk Lamp",
		"Floor Lamp",
		"Fluroescent lamp",
	),
	"Needs" => array(
		"Vending Machine",
		"Fridge",
		"Stove",
		"Serving Tray",
		"Instant Coffee",
		"Coffee",
		"Espresso Machine",
		"Toilet",
		"Watercooler",
	),
	"Decoration" => array(
		"Painting",
		"Floor Plant",
		"Table Plant",
		"Table Cactus",
		"Big Plant",
		"Clock",
	),
	"Server" => array(
		"Samll Server",
		"Medium Server",
		"Tower Server",
		"Server Rack",
	)
);

// In Place (outputs) <option value="$a">$a</option> in categories.
function _html_generate_options($groups) {
	foreach ($groups as $label => $options) {
		echo "<optgroup label=\"$label\">";
		foreach ($options as $option) {
			echo "<option value=\"$option\">$option</option>";
		}
		echo "</optgroup>";
	}
}

// Read the POST data and act on the inputs
if (!$_POST){
	// Form not submitted
} else {
	// Build XML to Download
	$xml=new SimpleXMLElement($xmlSkeleton);
	foreach($_POST as $k => $v){
		switch ($k) {
			// Ignore unknown input for now
			case $v == "": 
				continue;
			// <Root>
			case "Base":
			case "UpgradeFrom":
			case "Thumbnail":
				$xml->addAttribute($k, $v);
				break;
			// <Models><Model>
			case "File":
			case "Position":
			case "Rotation":
			case "Scale":
				$xml->Models->Model->$k = $v;
				break;
			// <Furniture>
			case "Category":
			case "Cost":
			case "ButtonDescription":
			case "UnlockYear":
			case "PrimaryColorName":
			case "SecondaryColorName":
			case "TertiaryColorName":
			case "ColorPrimaryEnabled":
			case "ColorSecondaryEnabled":
			case "ColorTertiaryEnabled":
			case "ForceColorSecondary":
			case "ForceColorTertiary":
			case "Wattage":
			case "FunctionCategory":
			case "ComputerPower":
			case "Lighting":
			case "Coffee":
			case "Wait":
			case "Water":
			case "Noisiness":
			case "Comfort":
			case "Environment":
			case "BasementValid":
			case "OnlyExteriorWalls":
			case "WallFurn":
			case "IsSnapping":
			case "CanAssign":
			case "ValidIndoors":
			case "ValidOutdoors":
			case "ValidOnFence":
			case "ForceAccessible":
			case "ITFix":
			case "TemperatureController":
			case "EqualizeTemperature":
			case "AlwaysOn":
				$xml->Furniture->$k = $v; // $k, input name; $v, input value
				break;
			case "AuraValues":
			case "RoleBuffs":
				$v = str_replace(',', "\n", $v);
				$xml->Furniture->$k = $v; // $k, input name; $v, input value
				break;
			case "ColorPrimaryDefault":
			case "ColorSecondaryDefault":
			case "ColorTertiaryDefault":
				$v = explode(",", $v);
				$colors = '';
				foreach ($v as $color) {
					$colorx = ($color / 255);
					$colorx = round($colorx, 3);
					$colors .= $colorx . "\n";
				};
				$colors .= "1";
				$xml->Furniture->$k = $colors;
				break;
			// Add AutoBounds = True
			case "submit":
				$xml->addAttribute("AutoBounds", "True");
				continue;
			default:
				break;
		}
	}
	// Take SimpleXML, make it human-readable
	$dom = new DOMDocument('1.0');
	$dom->preserveWhiteSpace = false;
	$dom->formatOutput = true;
	$dom->loadXML($xml->asXML());
	// Set download headers
	header('Content-Description: File Transfer');
	header('Content-Type: application/xml');
	header('Content-Disposition: attachment; filename="' . $_POST["File"] . '.xml"');
	header('Content-Length: ' . strlen($xml->asXML()));
	ob_clean();
	flush();
	// Send XML file to browser
	echo $dom->saveXML();
	exit;
}

?><!DOCTYPE html>
<title> Software Inc. XML Generator </title>

	<!-- Custom CSS -->
	<style>
	body {
		padding-top: 70px;
		background-color: #d6d8cd;
	}
	optgroup {
		align: center;
		font-size:150%;
		color: white;
		background-color: black;
	}
	</style>

	<!-- Bootstrap -->
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="<KEY>" crossorigin="anonymous">
	<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
	<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
	<!--[if lt IE 9]>
		<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
		<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
	<![endif]-->
</head>
<commit_msg>Fixed styling of select boxes<commit_after><?php
// Software Inc Furniture XML Generator
// Author: Demannu

// XML Skeleton(Only the bare minimum should be in here)
$xmlSkeleton = <<<XML
<Root>
	<Models>
		<Model>
			<File></File>
			<Position></Position>
			<Rotation></Rotation>
			<Scale></Scale>
		</Model>
	</Models>
	<Furniture>
		<Category></Category>
		<Cost></Cost>
		<ButtonDescription></ButtonDescription>
		<UnlockYear></UnlockYear>
		<PrimaryColorName></PrimaryColorName>
		<ColorPrimaryDefault></ColorPrimaryDefault>
	</Furniture>
</Root>
XML;

$baseFurnitureTypes = array(
	"Office" => array(
		"Table",
		"Glass Table",
		"2m End Table",
		"3m End Table",
		"Cheap Chair",
		"Office Chair",
		"Old Computer",
		"90s Computer",
		"Laptop",
		"Modern Computer",
		"HoloComputer",
		"Cubicle Wall",
		"TV",
		"Bookshelf",
		"Phone",
		"Drawing Tablet",
		"Calculator",
		"Inbox",
	),
	"Reception" => array(
		"Waiting Chairs",
		"Couch",
		"Reception Desk",
	),
	"Outdoor" => array(
		"Bench",
		"Outdoor Lamp",
		"Small tree",
		"Small pine tree",
	),
	"Temperature" => array(
		"Small Heater",
		"Ceiling Fan",
		"Radiator",
		"Ventilation",
		"Central Heating",
		"AC Unit",
		"Industrial ventilation",
	),
	"Lighting" => array(
		"Lamp",
		"Wall Lamp",
		"Desk Lamp",
		"Floor Lamp",
		"Fluroescent lamp",
	),
	"Needs" => array(
		"Vending Machine",
		"Fridge",
		"Stove",
		"Serving Tray",
		"Instant Coffee",
		"Coffee",
		"Espresso Machine",
		"Toilet",
		"Watercooler",
	),
	"Decoration" => array(
		"Painting",
		"Floor Plant",
		"Table Plant",
		"Table Cactus",
		"Big Plant",
		"Clock",
	),
	"Server" => array(
		"Samll Server",
		"Medium Server",
		"Tower Server",
		"Server Rack",
	)
);

// In Place (outputs) <option value="$a">$a</option> in categories.
function _html_generate_options($groups) {
	foreach ($groups as $label => $options) {
		echo "<optgroup label=\"$label\">";
		foreach ($options as $option) {
			echo "<option value=\"$option\">$option</option>";
		}
		echo "</optgroup>";
	}
}

// Read the POST data and act on the inputs
if (!$_POST){
	// Form not submitted
} else {
	// Build XML to Download
	$xml=new SimpleXMLElement($xmlSkeleton);
	foreach($_POST as $k => $v){
		switch ($k) {
			// Ignore unknown input for now
			case $v == "": 
				continue;
			// <Root>
			case "Base":
			case "UpgradeFrom":
			case "Thumbnail":
				$xml->addAttribute($k, $v);
				break;
			// <Models><Model>
			case "File":
			case "Position":
			case "Rotation":
			case "Scale":
				$xml->Models->Model->$k = $v;
				break;
			// <Furniture>
			case "Category":
			case "Cost":
			case "ButtonDescription":
			case "UnlockYear":
			case "PrimaryColorName":
			case "SecondaryColorName":
			case "TertiaryColorName":
			case "ColorPrimaryEnabled":
			case "ColorSecondaryEnabled":
			case "ColorTertiaryEnabled":
			case "ForceColorSecondary":
			case "ForceColorTertiary":
			case "Wattage":
			case "FunctionCategory":
			case "ComputerPower":
			case "Lighting":
			case "Coffee":
			case "Wait":
			case "Water":
			case "Noisiness":
			case "Comfort":
			case "Environment":
			case "BasementValid":
			case "OnlyExteriorWalls":
			case "WallFurn":
			case "IsSnapping":
			case "CanAssign":
			case "ValidIndoors":
			case "ValidOutdoors":
			case "ValidOnFence":
			case "ForceAccessible":
			case "ITFix":
			case "TemperatureController":
			case "EqualizeTemperature":
			case "AlwaysOn":
				$xml->Furniture->$k = $v; // $k, input name; $v, input value
				break;
			case "AuraValues":
			case "RoleBuffs":
				$v = str_replace(',', "\n", $v);
				$xml->Furniture->$k = $v; // $k, input name; $v, input value
				break;
			case "ColorPrimaryDefault":
			case "ColorSecondaryDefault":
			case "ColorTertiaryDefault":
				$v = explode(",", $v);
				$colors = '';
				foreach ($v as $color) {
					$colorx = ($color / 255);
					$colorx = round($colorx, 3);
					$colors .= $colorx . "\n";
				};
				$colors .= "1";
				$xml->Furniture->$k = $colors;
				break;
			// Add AutoBounds = True
			case "submit":
				$xml->addAttribute("AutoBounds", "True");
				continue;
			default:
				break;
		}
	}
	// Take SimpleXML, make it human-readable
	$dom = new DOMDocument('1.0');
	$dom->preserveWhiteSpace = false;
	$dom->formatOutput = true;
	$dom->loadXML($xml->asXML());
	// Set download headers
	header('Content-Description: File Transfer');
	header('Content-Type: application/xml');
	header('Content-Disposition: attachment; filename="' . $_POST["File"] . '.xml"');
	header('Content-Length: ' . strlen($xml->asXML()));
	ob_clean();
	flush();
	// Send XML file to browser
	echo $dom->saveXML();
	exit;
}

?><!DOCTYPE html>
<title> Software Inc. XML Generator </title>
	<!-- Custom CSS -->
	<style>
	body {
		padding-top: 70px;
		background-color: #d6d8cd;
	}
	select optgroup {
		background-color: black;
		color: white;
		
		font-size: 150%;
		line-height: 15px;
		letter-spacing: 2px;
	}
	select option {
		background-color: white;
		color: black;
	}
	</style>

	<!-- Bootstrap -->
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="<KEY>" crossorigin="anonymous">
	<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
	<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
	<!--[if lt IE 9]>
		<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
		<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
	<![endif]-->
{'fraction_non_alphanumeric': 0.18279864729001005, 'fraction_numerical': 0.006306553331505347, 'mean_word_length': 3.4606604158173666, 'pattern_counts': {'":': 98, '<': 122, '<?xml version=': 0, '>': 170, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 26}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2284430', 'n_tokens_mistral': 4590, 'n_tokens_neox': 3916, 'n_words': 955}