<?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($AddComponent)
{
$position = 1;
$query = "SELECT * FROM $DB_Navigation ORDER BY position DESC LIMIT 0,1";
$result = mysql_query($query, $Link) or queryError("22", mysql_error());
$ROW = mysql_fetch_object($result);
if(mysql_num_rows($result))
$position = $ROW->position + 1;
$query = "SELECT * FROM $DB_Components, $DB_Components_Rename
WHERE $DB_Components.id=$DB_Components_Rename.compid AND
$DB_Components.id='$component_id'";
$result = mysql_query($query, $Link) or queryError("22", mysql_error());
$ROW = mysql_fetch_object($result);
$query = "INSERT INTO $DB_Navigation (name, url, position) VALUES ('$ROW->new_name', '$ROW->page_url', '$position')";
$result = mysql_query($query, $Link) or queryError("22", mysql_error());
sxSyncPositionsNavigation();
header("Location: navigation.php?message=".str_replace(" ","_",$sxLang['MessageNavAdded']));
die();
}
if($AddURL)
{
$position = 1;
$query = "SELECT * FROM $DB_Navigation ORDER BY position DESC LIMIT 0,1";
$result = mysql_query($query, $Link) or queryError("22", mysql_error());
$ROW = mysql_fetch_object($result);
if(mysql_num_rows($result))
$position = $ROW->position + 1;
$query = "INSERT INTO $DB_Navigation (name, url, position) VALUES ('$new_name', '$new_url', '$position')";
$result = mysql_query($query, $Link) or queryError("22", mysql_error());
sxSyncPositionsNavigation();
header("Location: navigation.php?message=".str_replace(" ","_",$sxLang['MessageNavAdded']));
die();
}
if($AddPage)
{
$position = 1;
$query = "SELECT * FROM $DB_Navigation ORDER BY position DESC LIMIT 0,1";
$result = mysql_query($query, $Link) or queryError("22", mysql_error());
$ROW = mysql_fetch_object($result);
if(mysql_num_rows($result))
$position = $ROW->position + 1;
$query = "SELECT * FROM $DB_Pages WHERE name='$page_name'";
$result = mysql_query($query, $Link) or queryError("22", mysql_error());
$ROW = mysql_fetch_object($result);
$query = "INSERT INTO $DB_Navigation (name, url, position) VALUES ('$page_name', 'page.php?pageid=$ROW->id', '$position')";
$result = mysql_query($query, $Link) or queryError("22", mysql_error());
sxSyncPositionsNavigation();
header("Location: navigation.php?message=".str_replace(" ","_",$sxLang['MessageNavAdded']));
die();
}
$sxTitleAddendum = $sxLang['AdminHeading'];
include("../themes/$THEME_FOLDER/header.php");
?>
<div class="bodyWrapper">
<h1 class="sxAdminHeading"><?PHP echo $sxLang['NavHeadingAdd']; ?></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> > <a href="navigation.php"><?PHP echo $sxLang['NavHeading']; ?></a> > <?PHP echo $sxLang['NavHeadingAdd']; ?></div>
<?PHP echoMessage($message); ?>
<form name="sxFormNavAdd" method="post" action="<?PHP echo $PHP_SELF; ?>">
<table border="0" cellspacing="0" cellpadding="5">
<?PHP if(!$Continue){ ?>
<tr>
<td>
<input name="nav_type" type="radio" value="component" /> <?PHP echo $sxLang['NavAddLink']; ?><br />
<input name="nav_type" type="radio" value="page" /> <?PHP echo $sxLang['NavAddPage']; ?><br />
<input name="nav_type" type="radio" value="url" checked /> <?PHP echo $sxLang['NavAddURL']; ?></td>
</tr>
<tr>
<td><br /><input type="submit" name="Continue" value="<?PHP echo $sxLang['ButtonContinue']; ?>" class="sxButton" /></td>
</tr>
<?PHP }elseif($nav_type == 'component'){ ?>
<tr>
<td><strong><?PHP echo $sxLang['GeneralItemComponent']; ?></strong> <select style="width:200px;" name="component_id">
<?PHP
$query = "SELECT * FROM $DB_Components, $DB_Components_Rename
WHERE $DB_Components.active='1' AND $DB_Components.id=$DB_Components_Rename.compid
ORDER BY $DB_Components_Rename.new_name ASC";
$result = mysql_query($query, $Link) or queryError("21", mysql_error());
while($ROW = mysql_fetch_object($result)){
echo '<option value="' . $ROW->id . '">' . htmlspecialchars($ROW->new_name) . '</option>';
}
?>
</select> <input style="width:50px;" type="submit" name="AddComponent" value="<?PHP echo $sxLang['ButtonAdd']; ?>" class="sxButton" /></td>
</tr>
<?PHP }elseif($nav_type == 'url'){ ?>
<tr>
<td class="sxTdItem"><?PHP echo $sxLang['GeneralItemName']; ?></td>
<td><input style="width:150px;" name="new_name" type="text" maxlength="255" /></td>
</tr>
<tr>
<td class="sxTdItem"><?PHP echo $sxLang['GeneralItemURL']; ?></td>
<td><input style="width:150px;" name="new_url" type="text" maxlength="255" /></td>
</tr>
<tr>
<td class="sxTdItem"> </td>
<td><input style="width:50px;" type="submit" name="AddURL" value="<?PHP echo $sxLang['ButtonAdd']; ?>" class="sxButton" /></td>
</tr>
<?PHP }elseif($nav_type == 'page'){ ?>
<tr>
<td class="sxTdItem"><?PHP echo $sxLang['GeneralItemPage']; ?></td>
<td><select style="width:200px;" name="page_name">
<?PHP
$query = "SELECT * FROM $DB_Pages ORDER BY name";
$result = mysql_query($query, $Link) or queryError("21", mysql_error());
while($ROW = mysql_fetch_object($result)){
echo '<option value="' . $ROW->name . '">' . htmlspecialchars($ROW->name) . '</option>';
}
?>
</select> <input style="width:50px;" type="submit" name="AddPage" value="<?PHP echo $sxLang['ButtonAdd']; ?>" class="sxButton" /></td>
</tr>
<?PHP } ?>
</table>
</form>
</div>
<?PHP
include("../themes/$THEME_FOLDER/footer.php");
ob_end_flush();
?>