<?php
require_once('admin.php');
//_________________________________________________________
$Display->Title = 'Options';
$Display->Subtitle = 'Manage links';
//__________________________________________________________
require('./admin-display-header.php');
if(isset($_GET['action']))
$Action = $_GET['action'];
if($Action)
{
switch($Action)
{
case 'new':
$Display->Subtitle = 'Links » New link';
$InitialHeading = " <h2> Add a new link »» </h2> ";
$LinkName = $LinkURL = $LinkCategory = false;
$Form = new AdminForm('option-link-update.php?action=link_new');
//If there are errors from the option-link-action page, show them here
if(isset($_GET['update']))
{
foreach($Error as $Key => $KeyValue)
{
$Form->Error[$Key] = $KeyValue;
}
$LinkName = $_POST['link_name'];
$LinkURL = $_POST['link_url'];
$LinkCategory = $_POST['link_category'];
}
$Form->Input('text', 'link_name', $LinkName, 'Link name', false);
$Form->Input('text', 'link_url', $LinkURL, 'Link URL', 'The address of the link');
$Form->Input('text', 'link_category', $LinkCategory, 'Category', false);
print $InitialHeading.$Form->Finish('Add new link');
break;
case 'edit':
$Display->Subtitle = 'Links » Edit Link';
$InitialHeading = " <h2> Edit link »» </h2> ";
$ID = $_GET['id'];
//---------------------- Database query
$LinkData = $DC->Select('link', 'link_id', $_GET['id']);
//-------------------------------------
$LinkName = $LinkData[0]['link_name'];
$LinkURL = $LinkData[0]['link_url'];
$LinkCategory = $LinkData[0]['link_category'];
$Form = new AdminForm("option-link-update.php?action=link_edit&id=$ID");
//If there are errors from the option-link-action page, show them here
if(isset($_GET['update']))
{
foreach($Error as $Key => $KeyValue)
{
$Form->Error[$Key] = $KeyValue;
}
$LinkName = $_POST['link_name'];
$LinkURL = $_POST['link_url'];
$LinkCategory = $_POST['link_category'];
}
$Form->Input('text', 'link_name', $LinkName, 'Link name', false);
$Form->Input('text', 'link_url', $LinkURL, 'Link URL', 'The address of the link');
$Form->Input('text', 'link_category', $LinkCategory, 'Category', false);
print $InitialHeading.$Form->Finish('Update Link');
break;
default:
break;
}
}
else
{
header("Location: option-link.php");
exit();
}
_foot()
?>