<?php
if (!defined('ADMIN_FILE')) {
	die("Illegal File Access");
}

function editmediatypes() {
	global $prefix, $db, $admin_file;
	include("header.php");
	navigationAdmin("<b><a href=\"".$admin_file.".php?op=album&do=showoptions\">"._GALCONFIG."</a></b> &gt;&gt; <b>"._GALEDITMEDIATYPE."</b>");
	OpenTable();
	echo "<center>"._GALMEDIATYPEDESC."</center>";
	CloseTable();
	OpenTable();
	echo "<center><font class=\"option\"><b>"._GALMEDIAADDTYPE."</b></font><br>";
	echo "<form method=\"POST\" action=\"".$admin_file.".php?op=album\"><input type=\"hidden\" name=\"do\" value=\"editmediatypes\"><input type=\"hidden\" name=\"type\" value=\"new\">";
	echo "<table border=\"0\" align=\"center\"><tr><td>"._GALMEDIACLASSTYPE.":</td><td><select name=\"class\" style=\"width=300px\">";
	$res = $db->sql_query("SELECT * FROM $prefix"._album_media_class."");
	while (list($id, $class) = $db->sql_fetchrow($res)) {
		echo "<option value=\"$id\">$class</option>";
	}
	echo '</select></td></tr><tr><td>'._GALMEDIADESCTYPE.':</td><td><input type="text" name="description" size="50" style="width=300px"></td></tr><tr><td>'._GALMEDIAEXTENSION.':</td><td><input type="text" name="extension" size="50" style="width=300px"></td></tr><tr><td>'._GALMEDIATHUMB.':</td><td><input type="text" name="thumbnail" size="50" style="width=300px"></td></tr><tr><td>'._GALMEDIATAG.':</td><td><textarea  name="code" rows="10" cols="50" style="width=300px"></textarea></td></tr></table><br><center><input type="submit" value="'._GALMEDIAADDTYPE.'" name="create"></center></form><br>';

	$sql = "SELECT * FROM $prefix"._album_media_types." ORDER BY filetype, description";
	$result = $db->sql_query($sql);

	echo "<center><font class=\"option\"><b>"._GALEDITMEDIATYPES."</b></font>";
	while ($row = $db->sql_fetchrow($result)) {
		$info = str_replace("<", "&lt;", $row[displaytag]);
		$info = str_replace(">", "&gt;", $info);
		$info = str_replace("\"", "&quot;", $info);
		$info = str_replace("\'", "&apos;", $info);
		echo '<form method="POST" action="'.$admin_file.'.php?op=album"><input type="hidden" name="do" value="editmediatypes"><input type="hidden" name="type" value="edit"><input type="hidden" name="oldext" value="'.$row[extension].'">';
		echo "<hr><table border=\"0\" align=\"center\"><tr><td>"._GALMEDIACLASSTYPE.":</td><td><select name=\"class\" style=\"width=300px\">";
		$res = $db->sql_query("SELECT * FROM $prefix"._album_media_class."");
		$sel_filetype[$row[filetype]] = ' selected';
		while (list($id, $class) = $db->sql_fetchrow($res)) {
			echo "<option value=\"$id\"$sel_filetype[$id]>$class</option>";
		}
		echo '</select></td></tr><tr><td>'._GALMEDIADESCTYPE.':</td><td><input type="text" name="description" size="50" value="'.$row[description].'" style="width=300px"></td></tr><tr><td>'._GALMEDIAEXTENSION.':</td><td><input type="text" name="extension" size="50" value="'.$row[extension].'" style="width=300px"></td></tr><tr><td>'._GALMEDIATHUMB.':</td><td><input type="text" name="thumbnail" size="50" value="'.$row[thumbnail].'" style="width=300px"></td></tr><tr><td>'._GALMEDIATAG.':</td><td><textarea  name="code" rows="10" cols="50" style="width=300px">'.$info.'</textarea></td></tr></table><br><center><input type="submit" value="'._SAVE.'" name="save"> <input type="submit" value="'._DELETE.'" name="delete"></center></form>';
	}
	CloseTable();
	include("footer.php");
}
?>