Location: PHPKode > projects > SiteX > admin/navigation.php
<?PHP
ob_start();
session_start();
include("../includes/globals.php.inc");
include("../includes/functions.php");
include("../lang/English.php");
if(strtolower($sxSetup['Language']) != 'english') include("../lang/".$sxSetup['Language'].".php");
include("../themes/$THEME_FOLDER/config.php.inc");
if((!userEditor())AND(!userAdmin()))  loginError($sxLang['LoginRequired']);
if((userEditor())AND(!$sxSetup['EditorRightsNavigation']))  loginError($sxLang['LoginRequired']);

if($upid)
{
	$query = "SELECT * FROM $DB_Navigation WHERE id='$upid'";
	$result = mysql_query($query, $Link) or queryError("28", mysql_error());
	$ROW = mysql_fetch_object($result);
	
	$position1 = $ROW->position;
	$position2 = $position1 - 1;
	
	$query = "SELECT * FROM $DB_Navigation WHERE position='$position2'";
	$result = mysql_query($query, $Link) or queryError("27", mysql_error());
	
	if(mysql_num_rows($result))
	{
		$ROW = mysql_fetch_object($result);
		$changeID = $ROW->id;
		
		$query = "UPDATE $DB_Navigation SET position='$position2' WHERE id='$upid'";
		$result = mysql_query($query, $Link) or queryError("27", mysql_error());
		
		$query = "UPDATE $DB_Navigation SET position='$position1' WHERE id='$changeID'";
		$result = mysql_query($query, $Link) or queryError("27", mysql_error());
	}
	
	sxSyncPositionsNavigation();
}

if($downid)
{
	$query = "SELECT * FROM $DB_Navigation WHERE id='$downid'";
	$result = mysql_query($query, $Link) or queryError("22", mysql_error());
	$ROW = mysql_fetch_object($result);
	
	$position1 = $ROW->position;
	$position2 = $position1 + 1;
	
	$query = "SELECT * FROM $DB_Navigation WHERE position='$position2'";
	$result = mysql_query($query, $Link) or queryError("23", mysql_error());
	
	if(mysql_num_rows($result))
	{
		$ROW = mysql_fetch_object($result);
		$changeID = $ROW->id;
		
		$query = "UPDATE $DB_Navigation SET position='$position2' WHERE id='$downid'";
		$result = mysql_query($query, $Link) or queryError("27", mysql_error());
		
		$query = "UPDATE $DB_Navigation SET position='$position1' WHERE id='$changeID'";
		$result = mysql_query($query, $Link) or queryError("27", mysql_error());
	}
	
	sxSyncPositionsNavigation();
}

if($delete)
{
	$query = "SELECT * FROM $DB_Navigation WHERE id='$delete'";
	$result = mysql_query($query, $Link) or queryError("25", mysql_error());
	$ROW = mysql_fetch_object($result);
	$thisPos = $ROW->position;
	
	$query = "SELECT * FROM $DB_Navigation WHERE position>'$thisPos' ORDER BY position ASC";
	$result = mysql_query($query, $Link) or queryError("26", mysql_error());
	while($ROW = mysql_fetch_object($result))
	{
		if($ROW->position > 1)
			$new_position = $ROW->position-1;
		else
			$new_position = $ROW->position;
		
		$query2 = "UPDATE $DB_Navigation SET position='$new_position' WHERE id='$ROW->id'";
		$result2 = mysql_query($query2, $Link);
	}
	
	$query = "DELETE FROM $DB_Navigation WHERE id='$delete'";
	$result = mysql_query($query, $Link) or queryError("27", mysql_error());
	$message = $sxLang['MessageNavDeleted'];
	
	sxSyncPositionsNavigation();
}

if($Edit_x)
{
	$query = "UPDATE $DB_Navigation SET name='$new_name', url='$new_url', target='$new_target' WHERE id='$navid'";
	$result = mysql_query($query, $Link) or queryError("56", mysql_error());
	$message = $sxLang['MessageNavUpdated'];
}

if($EditComponent_x)
{
	$query = "UPDATE $DB_Navigation SET name='$new_name' WHERE id='$navid'";
	$result = mysql_query($query, $Link) or queryError("55", mysql_error());
	$message = $sxLang['MessageNavUpdated'];
}

$sxTitleAddendum = $sxLang['AdminHeading'];
include("../themes/$THEME_FOLDER/header.php");
?>
<script language="JavaScript" type="text/JavaScript">
<!--
function confirmDelete(theID,theName){
	if(confirm("<?PHP echo $sxLang['GeneralJSDeleteEntry3']; ?> '"+theName+"' <?PHP echo $sxLang['GeneralJSDeleteEntry5']; ?>")){
		window.location='<?PHP print $PHP_SELF."?delete="; ?>'+theID;
	}
}
//-->
</script>  
<div class="bodyWrapper">
   <h1 class="sxAdminHeading"><?PHP echo $sxLang['NavHeading']; ?></h1>
   <div class="sxAdminBreadcrumbs"><?PHP if(userAdmin()) { ?><a href="index.php"><?PHP echo $sxLang['AdminBreadcrumb']; ?><?PHP }?><?PHP if(userEditor()) { ?><a href="editor_index.php"><?PHP echo $sxLang['EditorBreadcrumb']; ?><?PHP }?></a> > <?PHP echo $sxLang['NavHeading']; ?></div>   
   <?PHP echoMessage($message); ?>
	<table border="0" cellspacing="2" cellpadding="5">
	  <tr>
		<td class="tableColumn"><?PHP echo $sxLang['GeneralItemNum']; ?></td>
		<td class="tableColumn"><?PHP echo $sxLang['GeneralItemName']; ?></td>
		<td class="tableColumn"><?PHP echo $sxLang['GeneralItemURL']; ?></td>
		<td class="tableColumn"><?PHP echo $sxLang['GeneralItemTarget']; ?></td>
		<td class="tableColumn"><?PHP echo $sxLang['GeneralItemOptions']; ?></td>
	  </tr>
	<?PHP
	// Output navigation rows
	$query = "SELECT * FROM $DB_Navigation ORDER BY position ASC";
	$result = mysql_query($query, $Link) or queryError("21", mysql_error());
	while($ROW = mysql_fetch_object($result))
	{
	
		echo ' <form name="sxFormEditNav' . $ROW->id . '" method="post" action="' . $PHP_SELF . '"><tr>';
		echo '     <td bgcolor="' . $sxTheme['ColorTableRow'] . '">' . $ROW->position . '</td>';			
		echo '     <td bgcolor="' . $sxTheme['ColorTableRow'] . '"><input style="width:150px;"name="new_name" type="text" maxlength="255" value="' .  htmlspecialchars($ROW->name) . '" /></td>';
		echo '     <td bgcolor="' . $sxTheme['ColorTableRow'] . '"><input style="width:150px;"name="new_url" type="text" maxlength="255" value="' . $ROW->url . '" /></td>';
		echo '     <td bgcolor="' . $sxTheme['ColorTableRow'] . '">';
		echo '     <select name="new_target">';
		echo '		<option value="_self"'; 
			if ($ROW->target == '_self') echo ' selected="selected"';
		echo '>'. $sxLang['NavTargetSelf'] .'</option>';
		echo '		<option value="_blank"'; 
			if ($ROW->target == '_blank') echo ' selected="selected"';
		echo '>'. $sxLang['NavTargetBlank'] .'</option>';
		echo '</select></td>';
		echo '     <td bgcolor="' . $sxTheme['ColorTableRow'] . '">';
		echo '       <input name="navid" type="hidden" value="' . $ROW->id . '" />';
		echo '       <input name="Edit';
		if($component)
			echo 'Component';
		echo '" type="image" src="../images/admin_edit.gif" alt="' . $sxLang['ButtonEdit'] . '" value="' . $sxLang['ButtonEdit'] . '" /> ';
		
		echo '       <a href="#" onclick="confirmDelete(' . $ROW->id . ',\'' .  htmlspecialchars(addslashes($ROW->name)) . '\')" title="' . $sxLang['ButtonDelete'] . '"><img src="../images/admin_delete.gif" style="border: 0;" alt="' . $sxLang['ButtonDelete'] . '" /></a> ';
		echo '       <a href="' . $PHP_SELF . '?upid=' . $ROW->id . '" title="' . $sxLang['ButtonUp'] . '"><img src="../images/admin_up.gif" style="border: 0;" alt="' . $sxLang['ButtonUp'] . '" /></a> ';
		echo '       <a href="' . $PHP_SELF . '?downid=' . $ROW->id . '" title="' . $sxLang['ButtonDown'] . '"><img src="../images/admin_down.gif" style="border: 0;" alt="' . $sxLang['ButtonDown'] . '" /></a> ';
		echo '     </td>';
		echo '  </tr></form>';
	}
	?></table>
	<p><input style="width:170px;" type="button" name="add" value="<?PHP echo $sxLang['NavButtonAddNew']; ?>" onclick="window.location='navigation_add.php'" /></p>
</div>
<?PHP
include("../themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>
Return current item: SiteX