Пример #1
0
$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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>standupweb CMS - Edit static field mode</title>
require_once '../../lib/php/DOLib.php';
if (!swValidate('s_username')) {
    header("location: ../index.php");
}
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;