<html>
{assign var="tab" value=$smarty.request.tab|default:"list"}
{assign var="fsId" value=$smarty.request.fsId}
{assign var="pgLayout" value="dont_use_any"}
{if !$acm->checkAccess('edit', '_fs', $fsId)}
	{message type="error" value="You do not have access to edit the specified page."}
	<head>
		<title>File System Manager - Access Denied</title>
		<link rel="stylesheet" href="{$skinFolder}edit.css">
	</head>
	<body bgcolor="#DDDDDD" background="{$skinFolder}img/editBg.gif">
		{include file="file:./pages/edit/pageMessages.tpl"}
	</body>
	</html>
{else}
{* include_php file="spade/handle.fileSystem.php" *}
{* CHECK AND STORE ALL ACCESS RIGHTS RELATED TO THE PAGE EDITOR *}
{assign var="addAccess" value=$acm->checkAccess('add', '_toc', $tocId)}
{assign var="deleteAccess" value=$acm->checkAccess('delete', '_toc', $tocId)}
{assign var="changeAccess" value=$acm->checkAccess('changeAccess', '_toc', $tocId)}
{assign var="viewAccess" value=$acm->checkAccess('viewAccess', '_toc', $tocId)}

<head>
	<title>File System Manager - {$aEditPage.title}</title>
	<link rel="stylesheet" href="{$skinFolder}edit.css">
{if $isIE AND $modules.spadeEditor}
	<script language="JavaScript" src="{$modules.spadeEditor}"></script>
{/if}
</head>
<body bgcolor="#DDDDDD" background="{$skinFolder}img/editBg.gif">
	<script language="JavaScript">
		var popupError = 'There was an error opening the popup window.\n\nYou must disable any popup blocking software\nin order for this feature to work properly.';
		{literal}
		function gotoTab(newTab) {
			var dF = document.fileSystemForm;
			if (dF.isChanged.value || dF.editPageAction.value != '') {
				dF.editPageAction.value = 'store';
				dF.tab.value = newTab;
				dF.submit();
				return false;
			}
			return true;
		}
		
		function saveChanges() {
			{/literal}
			var df = document.editPageForm;
			{if $smarty.request.tab eq "history"}
			var inDanger = (historyCount - parseInt(df.historyLimit.value){if $aEditPage.isContentChanged} + 1{/if});
			{elseif $smarty.request.tab eq "content"}
			var inDanger = parseInt(historyCount) - {$aEditPage.historyLimit} + ((df.isContentChanged.value != '') ? 1 : 0);
			{else}
			var inDanger = historyCount - {$aEditPage.historyLimit}{if $aEditPage.isContentChanged} + 1{/if};
			{/if}
			{if $smarty.request.tab eq "content"}
			var isChanged = (df.isContentChanged.value != '');
			{else}
			var isChanged = '{$aEditPage.isContentChanged}';
			{/if}

			{if $changeVersion OR $historySettings}if ((inDanger > 0 && confirm('The current specified history limit is less than the number of versions\ncurrently stored in the history' + ((isChanged) ? ' (plus the new version you are saving)' : '') + '.\n\nThe ' + ((inDanger > 1) ? inDanger+' oldest versions' : 'oldest version') + ' will be deleted.\n\nIf you would like to save ' + ((inDanger > 1) ? 'these versions' : 'this version') + ', or manually select\nthe version(s) to delete, click Cancel and do so now.\n\nIf you would like to continue and automatically delete\n'+((inDanger > 1) ? 'these '+inDanger+' versions' : 'the oldest version') + ', click OK.')) || inDanger <= 0){/if}{literal} {
			df.editPageAction.value='save'; 
			df.submit();
			}
		}
		{/literal}
	</script>
<form name="editPageForm" method="post" action="index.php" style="margin:0px;">
<input type="hidden" name="no_expire" value="true">
<input type="hidden" name="no_expire_keep_alive" value="tocId tab">
<input type="hidden" name="editPageAction" value="">
<input type="hidden" name="pg" value="edit/main">
<input type="hidden" name="tocId" value="{$tocId}">
<input type="hidden" name="tab" value="{$tab}">
<input type="hidden" name="isChanged" value="">
<input type="hidden" name="isPreview" value="">
<input type="hidden" name="preferredPreviewHeight" value="{$s.preferredPreviewHeight}">
<input type="hidden" name="preferredPreviewWidth" value="{$s.preferredPreviewWidth}">
<input type="hidden" name="preferredEditorHeight" value="{$s.preferredEditorHeight}">
<input type="hidden" name="preferredEditorWidth" value="{$s.preferredEditorWidth}">
<table width="100%">
	<tr>
		<td nowrap><a href="http://spade.onai.net" target="_blank"><img src="./img/logos/spade.gif" style="margin-bottom:8px;" border="0"></a> &nbsp; <a href="http://www.onai.net" target="_blank"><img src="./img/logos/onai.gif" style="margin-bottom:8px;" border="0"></a></td>
		<td width="100%" align="center">&nbsp;</td>
	</tr>
</table>
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="border:#000000 1px solid;">
	<tr>
		<td background="{$skinFolder}img/fade_gray.gif" bgcolor="#B0BEC0" valign="bottom" style="background-repeat:repeat-x;">
			<span style="padding:3px 3px 0px 3px;"><img src="./img/blank.gif" width="1" height="20" alt="" border="0">
			<a href="?pg=edit/main&tab=content&tocId={$tocId}" class="tab{if $tab eq "content"}_on{/if}" onclick="return gotoTab('content');">&nbsp;Page&nbsp;Content&nbsp;</a>| 
			<a href="?pg=edit/main&tab=toc&tocId={$tocId}" class="tab{if $tab eq "toc"}_on{/if}" onclick="return gotoTab('toc');">&nbsp;Page&nbsp;Settings&nbsp;</a>| 
			{if $changeVersion OR $historySettings}<a href="?pg=edit/main&tab=history&tocId={$tocId}" class="tab{if $tab eq "history"}_on{/if}" onclick="return gotoTab('history');">&nbsp;Page&nbsp;History&nbsp;</a>| {/if}
			{if $viewAccess}<a href="?pg=edit/main&tab=access&tocId={$tocId}" class="tab{if $tab eq "access"}_on{/if}" onclick="return gotoTab('access');">&nbsp;Access&nbsp;Control&nbsp;</a>|{/if}
			{if $searchSettings}<a href="?pg=edit/main&tab=search&tocId={$tocId}" class="tab{if $tab eq "search"}_on{/if}" onclick="return gotoTab('search');">&nbsp;Search&nbsp;Engine&nbsp;</a>| {/if}
			<a href="?pg=edit/main&tab=jump&tocId={$tocId}" class="tab{if $tab eq "jump"}_on{/if}" onclick="return gotoTab('jump');">&nbsp;Jump&nbsp;To..&nbsp;</a>| 
		</span></td>
	</tr>
	<tr>
		<td bgcolor="#FFFFFF">
			<div style="margin:10px;">
			<noscript>
				<div style="color:#FF0000;" align="center">JavaScript must be enabled for this feature to work properly.<br />You may be able to continue with some features, but enabling JavaScript is highly recommended.</div>
			</noscript>
			{include file="file:./pages/edit/pageMessages.tpl"}
			{include file="file:./pages/edit/`$tab`.tpl"}
			<hr noshade size="1">
			<h2>Current Page Summary</h2>
			
			{if $aEditPage.isChanged}<div style="color:#FF0000;">* Not Saved *</div>{/if}
			<strong>Page Name:</strong> {$aEditPage.name|default:"Unknown"} &nbsp; <!--small>(<a href="?pg=edit/main&tab=toc">edit</a>)</small--><br>
			<strong>Page Title:</strong> {$aEditPage.title|default:"Unknown"} &nbsp; <!--small>(<a href="?pg=edit/main&tab=toc">edit</a>)</small--><br>
			<strong>Last Updated:</strong> {$aEditPage.dateModified|date_format2:"n/j/Y h:i:s A"}<br>
			<strong>Last Updated By:</strong> {$aEditPage.username|default:"Unknown"}<br>
			<strong>Page Version#:</strong> {$aEditPage.version|default:"Unknown"}<br>
			</div></td>
	</tr>
</table>
{if $deleteAccess}<input class="btn" type="button" name="deletePage" value="Delete This Page"
		{if $aEditPage.parentId eq "0"}onClick="alert('You cannot delete a page whose parent is \'root\'.\n(Pages whose Parent ID is 0 are \'root pages\'.)\n\nIf you would like to delete this page, it must be\nmoved beyond the first-teir level.\n\nIf this page is your only first-teir page, you must\nmove another page to the root, move this page\nbelow the root, then delete it.');"{else}onClick="if (confirm('Are you sure you want to permanently delete this page and\nall of its backups?{if $aEditPage.childrenCount gt "0"}\n\nWARNING: This command will also delete all decendents of\nthis page within the Table of Contents (TOC).\n\nDecendents are defined as pages whose Parent ID points\nto this page. If you are unsure of which pages are\nchildren of this page, check the TOC or, AS RECOMMENDED,\nhide this page in the TOC (Page Settings tab).{/if}')) {literal}{ document.editPageForm.editPageAction.value='delete'; document.editPageForm.submit(); }"{/literal}{/if}>
{/if}
{if $addAccess}<input class="btn" type="button" name="addSubPage" value="Add New Sub Page" onClick="if ({if $aEditPage.isChanged}1{else}isChanged.value != ''{/if}) {literal}{ if (confirm('You have not saved your changes to the current page.\nWould you like to save changes and continue?')) { document.editPageForm.editPageAction.value='newsub'; document.editPageForm.submit(); } } else { document.editPageForm.editPageAction.value='newsub'; document.editPageForm.submit(); }"{/literal}>{/if}

<script language="JavaScript">
{if $smarty.request.isPreview}
previewEditPage();
{/if}

{literal}
function on_change() {
	var df = document.forms['editPageForm'];
	df.isChanged.value = 1;
	df.btnSave.style.border = '#990000 1px solid';
	df.btnSave.style.color = '#CC0000';
	df.btnSave.disabled = false;
	df.btnDiscard.disabled = false;
}

var df = document.forms['editPageForm'];
for (var x = 0; x < df.elements.length; x++) {
	if (!df.elements[x].onchange) {
		df.elements[x].onchange = on_change;
	}
}

if (window.opener && typeof(window.opener.preferredEditorHeight) != 'undefined' && typeof(window.opener.preferredEditorWidth) != 'undefined') {
	document.body.onresize = function() {var df = document.editPageForm; df.preferredEditorHeight.value = document.body.clientHeight + 13; df.preferredEditorWidth.value = document.body.clientWidth + 13; window.opener.preferredEditorHeight = document.body.clientHeight + 13; window.opener.preferredEditorWidth = document.body.clientWidth + 13; df.editPageAction.value = 'store';};	
}

</script>
{/literal}
</form>
 
</body>
</html>
{/if}