<?
if ($_GET['new']) {
	$title = $lang->get("Creating a new text file");
} else {
	$title = $lang->get("Editing a text file");
}

//template header
require_once($sys['root']."/system/templates/popup/header.inc");
?>
<script language="JavaScript1.2" type="text/javascript">
<?echo $js?>
</script>
<form action="?file=edittext&tabid=<?echo $str->fromHTML($_GET['tabid']);?>&action=<?if ($_GET['new']){echo "new";}else{echo "save";}?><?if ($_GET['new']){echo "&new=1";}?>" method="post" name="editform" onsubmit="if(!isLegalFilename(document.editform.filename.value)){alert('<?$lang->display("A file or folder name cannot contain any of the following characters: \ / : * ? < > | &quot");?>');return false}">

<table cellspacing="0" cellpadding="0" border="0" style="width:100%;height:100%;background-color:#F2F2F2">
<tr>
    <td background="images/popup/top-bg.gif" height="26">&nbsp;</td>
</tr>

<tr>
    <td style="padding:10px;" valign="top">
<!-- Popup Contents -->
	

<table border="0" cellpadding="0" height="300" cellspacing="0">
<?if ($_GET['new']) {?>
<tr>
	<td height="40" width="100" nowrap><b><?$lang->display("File name:");?></b> </td>
	<td><?echo $str->safeHTML(gluePath($sys['path'],"/"));?><input type="text" name="filename" value="<?echo $str->safeHTML($sys['filename']);?>" style="width:230px;margin-left:1px;"></td>
</tr>
<?} else {?>
<tr>
	<td height="40" width="100" nowrap><b><?$lang->display("Editing:");?></b> </td>
	<td><?echo $str->safeHTML(gluePath($sys['path'],"/", $sys['filename']));?></td>
</tr>
<input type="hidden" name="filename" value="<?echo $str->safeHTML($sys['filename']);?>">
<?}?>
<tr>
<td valign="top" width="100"> <b><?$lang->display("Contents:");?></b> </td>
<td valign="top">
<textarea name="fileContent" style="word-wrap:break-word;word-break:break-all;font-size:8pt;font-family:Verdana;height: 300px;width: 480px;"><?
if ($showTextFromFile) {
	echo $str->safeHTML(@file_get_contents($filepath));
} else {
	echo $str->safeHTML($str->fromHTML($_POST['fileContent']));
}
?></textarea>
</td>
</tr>
</table>



	</td>
</tr>
<tr>
    <td align="center">

<table border="0" cellspacing="0" cellpadding="4" style="position:relative;top:18px;z-index:1">
<tr>
	<td><?if ($permissions['unlimitedSpace'] || $quota->canAddToSpace()) {
$tpl->btn(
(($_GET['new'])?$lang->get("Create and save"):$lang->get("Update file")), 
"document.editform.submit();"
);
} else {
$tpl->btn(
(($_GET['new'])?$lang->get("Create and save"):$lang->get("Update file")), 
"msg('nospace')"
);
}
?></td>
	<td><?
$tpl->btn(
$lang->get("Close"), 
"self.close();window.close()",
"",
"",
"id=\"aiurea\""
)
?></td>
</tr>
</table>



	</td>
</tr>

<tr>
    <td background="images/popup/bottom-bg.gif" height="46">&nbsp;</td>
</tr>
</table>
<input type="hidden" name="path" value="<?echo $str->forURL($sys['path'])?>">
</form>

<?
//template footer
require_once($sys['root']."/system/templates/popup/footer.inc");
?>