Example #1
0
connect();
// save new value and redirect to the page to view the change
$save = $_POST['save'];
if ($save) {
    StaticField::createStaticField($save, $_POST['value']);
    $location = ViewUrl::getViewUrl($save);
    if ($location) {
        header("location: view.php?location=" . $location);
    } else {
        header("location: view.php");
    }
}
//get default value for the textarea (either from selecting an item in the history, or from the current active record)
$name = $_GET['name'];
if ($_GET['init']) {
    $row = StaticField::getStaticFieldById($_GET['init']);
} else {
    $row = StaticField::getStaticFieldByName($name);
}
if ($row) {
    $initValue = restoreValue($row[2]);
}
//delete history entry
$delete = $_GET['delete'];
if ($delete) {
    StaticField::deleteStaticField($delete);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
}
connect();
$type = $_POST["type"];
$name = $_POST["name"];
$value = $_POST["value"];
$id = $_POST["id"];
if ($type) {
    switch ($type) {
        case 'getStaticFieldValueByName':
            $result = "getStaticFieldValue result:" . StaticField::getStaticFieldValueByName($name);
            break;
        case 'getStaticFieldByName':
            $result = "getStaticField result:" . implode(",", StaticField::getStaticFieldByName($name));
            break;
        case 'getStaticFieldById':
            $result = "getStaticFieldById result:" . implode(",", StaticField::getStaticFieldById($id));
            break;
        case 'getAllStaticFieldsByName':
            $staticFields = StaticField::getAllStaticFieldsByName($name);
            if (!$staticFields) {
                $result = "no record for the name={$name}";
            } else {
                foreach ($staticFields as $sf) {
                    $sfList[] = implode(",", $sf);
                }
                $result = "getAllStaticFieldsByName result:\n" . implode("<br/>", $sfList);
            }
            break;
        case 'createStaticField':
            StaticField::createStaticField($name, $value);
            $result = "static field created: name={$name}, value={$value}";