$recordArray = StructuredField::getSortedRecords($id);
            if (!$recordArray) {
                $result = "no record for the unit with id={$id}";
            } else {
                foreach ($recordArray as $record) {
                    $recordFields[] = implode(",", $record);
                }
                $result = implode("<br/>", $recordFields);
            }
            break;
        case 'switchRank':
            StructuredField::switchRank($id, $id2);
            $result = "record at id={$id2} and id={$id} have switched their ranks";
            break;
        case 'deleteRecord':
            StructuredField::deleteRecord($id, $rank);
            $result = "record for unit with id={$id} at rank={$rank} have been deleted";
            break;
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>simple CMS - unit structured field test</title>
<link rel="shortcut icon" href="../images/favicon.ico" />

</head>
<body>
<form method="post" action="<?php 
Exemplo n.º 2
0
    $message .= "The record has been updated";
} else {
    $init = $_GET['init'];
    $name = $_GET['name'];
}
// create a new record
$new = $_GET['new'];
if ($new) {
    $unit = StructuredUnit::getUnitByName($name);
    $init = StructuredField::createRecord($unit[0], $unit[3], 0);
    $message = "A new record has been created";
}
//delete record
$delete = $_GET['delete'];
if ($delete) {
    StructuredField::deleteRecord($delete);
    $message = "The record has been deleted";
}
//get the list of records
if ($name) {
    $id = StructuredUnit::getUnitId($name);
    if ($id) {
        $records = StructuredField::getSortedRecords($id, $isAdmin);
    } else {
        header('location:editlist.php?name=' . $name);
    }
}
//move rank up
$moveRankUp = $_GET['moveup'];
if ($moveRankUp) {
    StructuredField::switchRank($records[$moveRankUp][0], $records[$moveRankUp - 1][0]);