<?php
if (!defined('ADMIN_FILE')) die("Illegal File Access");
function edittemplate($tid) {
	global $prefix, $xtype, $db, $admin_file;
	if (isset($tid) && $tid) {
		$trow = $db->sql_fetchrow($db->sql_query("SELECT id, title, type, templateCategory, templatePictures, templateCSS FROM $prefix"._magazin_template_types." WHERE id=$tid"));
		$optype = 'save';
		$navtitle = ""._GALEDITTEMPLATE." &gt;&gt; ".$trow[title]."";
		$navtitle2 = ""._GALEDITTEMPLATE."";
	} else {
		$trow = $db->sql_fetchrow($db->sql_query("SELECT id, type, templateCategory, templatePictures, templateCSS FROM $prefix"._magazin_template_types." WHERE id=$xtype"));
		$optype = 'create';
		$navtitle = ""._GALCREATETEMPLATE."";
		$navtitle2 = ""._GALCREATETEMPLATE."";
	}
	$trow[templateCategory] = stripslashes($trow[templateCategory]);
	$trow[templatePictures] = stripslashes($trow[templatePictures]);
	$trow[templateCSS] = stripslashes($trow[templateCSS]);
	if($trow[type] == 1) {
		$cattext = ""._GALTEMPLMAIN."";
		$catdesc = ""._GALTEMPLMAINDESC."";
	} else {
		$cattext = ""._GALTEMPLCAT."";
		$catdesc = ""._GALTEMPLCATDESC."";
	}
	head();
	navigationAdmin("<b><a href=\"".$admin_file.".php?op=magazin\">"._GALCONFIG."</a></b> &gt;&gt; <b><a href=\"".$admin_file.".php?op=magazin&do=edittemplate\">"._GALEDITALLTEMPLATES."</a></b> &gt;&gt; <b>$navtitle</b>");
	OpenTable();
	echo "<center><font class=\"option\"><b>$navtitle2</b></font><br>";
	echo "<form method=\"post\" action=\"".$admin_file.".php?op=magazin\"><input type=\"hidden\" name=\"do\" value=\"edittemplate\"><input type=\"hidden\" name=\"type\" value=\"$optype\"><input type=\"hidden\" name=\"xtype\" value=\"$trow[type]\"><input type=\"hidden\" name=\"templateid\" value=\"$tid\">";
	echo "<table border=\"0\"><tr><td>"._GALTEMPLATENAMEDESC.":</td><td><input type=\"text\" width=\"50\" name=\"xtemplatename\" value=\"$trow[title]\" style=\"width:300px\"></td></tr><tr><td>$cattext:<br>$catdesc</td><td><textarea name=\"xtemplateCat\" cols=\"50\" rows=\"30\" wrap=\"soft\" style=\"width:300px\">$trow[templateCategory]</textarea></td></tr>";
	if ($trow[type] != 1) {
		echo "<tr><tr><td>"._GALTEMPLPIC.":<br>"._GALTEMPLPICDESC."</td><td><textarea name=\"xtemplatePic\" cols=\"50\" rows=\"30\" wrap=\"soft\" style=\"width:300px\">$trow[templatePictures]</textarea></td></tr>";
	}
	echo "<tr><td>"._GALTEMPLCSS.":<br>"._GALTEMPLCSSDESC."</td><td><textarea name=\"xtemplateCSS\" cols=\"50\" rows=\"30\" wrap=\"soft\" style=\"width:300px\">$trow[templateCSS]</textarea></td></tr></table><br>";
	echo "<center><input type=\"submit\" name=\"save\" value=\""._GALSAVECHANGES."\"> <input type=\"reset\" name=\"reset\" value=\""._GALCATDELETE."\"></center></form>";
	CloseTable();
	foot();
}
?>