public static function printField($name, $formattedString)
 {
     if (swValidate('edit')) {
         echo "<div style='position:absolute'><a target='_top' class='edit' href='swcms/editrecord.php?edittype=record&name={$name}' class='edit'></a></div>";
     }
     $fieldList = StructuredField::getSortedRecords(StructuredUnit::getUnitId($name), true);
     $rank = 1;
     if ($fieldList) {
         foreach ($fieldList as $field) {
             $output = $formattedString;
             $output = str_replace("@@rank", $rank++, $output);
             $values = StructuredFieldValue::getValues($field[0]);
             $index = 1;
             if ($values) {
                 foreach ($values as $value) {
                     $output = str_replace("@@" . $index++, displayValue($value[3]), $output);
                 }
             }
             $index = 1;
             $assets = StructuredFieldAsset::getAssets($field[0]);
             if ($assets) {
                 foreach ($assets as $asset) {
                     $output = str_replace("@@a" . $index, displayValue($asset[2]), $output);
                     $output = str_replace("@@t" . $index, displayValue($asset[1]), $output);
                     $index++;
                 }
             }
             echo $output;
         }
     }
 }
$type = $_POST["type"];
$name = $_POST["name"];
$id = $_POST["id"];
$value = $_POST["value"];
if ($type) {
    switch ($type) {
        case 'createValue':
            StructuredFieldValue::createValue($id, $value, $name);
            $result = "structured field value with name={$name} created";
            break;
        case 'readValue':
            $value = StructuredFieldValue::readValue($id);
            $result = "The value with id={$id} is '" . implode(', ', $value) . "'";
            break;
        case 'getValues':
            $valueArray = StructuredFieldValue::getValues($id);
            if (!$valueArray) {
                $result = "no record for the name={$name}";
            } else {
                foreach ($valueArray as $v) {
                    $vArray[] = implode(",", $v);
                }
                $result = "getValues result:\n" . implode("<br/>", $vArray);
            }
            break;
        case 'updateValue':
            StructuredFieldValue::updateValue($id, $value, $name);
            $result = "structured field value with id={$id} updated with value={$value} and name={$name} updated";
            break;
        case 'deleteValue':
            StructuredFieldValue::deleteValue($id, $name);
Example #3
0
        $lockVal = $_POST['lock'];
    } else {
        $lockVal = $selectedRecord[4];
    }
    StructuredField::updateRecord($selectedRecord[0], $recordName, $selectedRecord[2], $lockVal);
    $records = StructuredField::getSortedRecords($id, $isAdmin);
}
//get default values for the textareas (either from the selecting record, or from the first record)
if ($init) {
    $selectedRecord = StructuredField::readRecord($init);
} else {
    $selectedRecord = $records[0];
    $init = $selectedRecord[0];
}
if ($init) {
    $textArray = StructuredFieldValue::getValues($init);
    $assetArray = StructuredFieldAsset::getAssets($init);
    $selectedRecordName = displayValue($selectedRecord[3]);
    // don't show locked record for non-admin users or there is no record name in the URL
    $lock = $selectedRecord[4];
    if (empty($name) || $lock == 1 && !$isAdmin) {
        header('location:index.php');
    }
}
?>
<!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 <?php 
echo $name;