예제 #1
0
 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;
         }
     }
 }
 public static function create($unitId)
 {
     $unit = StructuredUnit::getUnit($unitId);
     $records = StructuredFieldValueLabel::getSorted($unitId);
     $rank = 1;
     if ($records) {
         $rank = $records[sizeOf($records) - 1][sizeOf(StructuredFieldValueLabel::getStructure()) + 2] + 1;
     }
     $query = "INSERT INTO structured_field_value_label (unit_id, label, type, rank) VALUES ({$unitId}, '" . $unit[3] . "', 'text', {$rank});";
     $result = mysql_query($query) or die(sqlError(__FILE__, __LINE__, $query));
 }
예제 #3
0
        StructuredFieldAssetLabel::delete($delete);
    }
    $message = "{$type} label deleted";
}
// get the list of record labels
// retrieve asset labels and value labels
if ($id) {
    // retrieve value labels
    $valueLabels = StructuredFieldValueLabel::getSorted($id);
    // retrieve asset labels
    $assetLabels = StructuredFieldAssetLabel::getSorted($id);
} else {
    if (empty($name)) {
        header('location:index.php');
    }
    StructuredUnit::createUnit($name);
    $message = "The list {$name} has been created";
}
//move rank up
$moveRankUp = $_GET['moveup'];
if ($moveRankUp) {
    // move value label up
    if (strcmp($type, 'value') == 0) {
        StructuredFieldValueLabel::switchRank($valueLabels[$moveRankUp][0], $valueLabels[$moveRankUp - 1][0]);
        $valueLabels = StructuredFieldValueLabel::getSorted($id);
    } else {
        StructuredFieldAssetLabel::switchRank($assetLabels[$moveRankUp][0], $assetLabels[$moveRankUp - 1][0]);
        $assetLabels = StructuredFieldAssetLabel::getSorted($id);
    }
}
//move rank down
예제 #4
0
// 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]);
    $records = StructuredField::getSortedRecords($id, $isAdmin);
}
//move rank down
$moveRankDown = $_GET['movedown'];
if ($moveRankDown) {
            $result = "The id for the unit {$name} is {$id}";
            break;
        case 'getUnit':
            $unit = StructuredUnit::getUnit($name);
            $result = "unit: " . implode(', ', $unit);
            break;
        case 'getUnitRandom':
            $random = StructuredUnit::getUnitRandom($name);
            $result = "The random for the unit {$name} is {$random}";
            break;
        case 'updateUnit':
            StructuredUnit::updateUnit($id, $name, $random);
            $result = "structured unit with name={$name}, id={$id}, random={$random} updated";
            break;
        case 'deleteUnit':
            StructuredUnit::deleteUnit($name);
            $result = "structured unit with name={$name} 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 unit test</title>
<link rel="shortcut icon" href="../images/favicon.ico" />

</head>
<body>
<form method="post" action="<?php