"No", 1 => "Yes");
}
/**
* Get an array of options available for a privilege value. The array keys are
* values for the form and the values are the labels for the form.
* @return array array of privilege options
*/
function GetPrivilegeOptions()
{
$PrivilegeFactory = new PrivilegeFactory();
return array("--" => "--") + $PrivilegeFactory->GetPrivileges(TRUE, FALSE);
}
/**
* Get the escaped option text and value for a flag value.
* @param int $State TRUE if the flag is on and FALSE if the flag is OFF
* @return array the first value is the text, the second is the value
*/
function GetSafeFlagOption($State)
{
return array(
defaulthtmlentities(GetArrayValue(GetFlagOptions(), $State ? 1 : 0)),
defaulthtmlentities($State ? 1 : 0));
}
/**
* Print the type field for the given metadata field data.
* @param array $Data metadata field data
* @param string|null $Error field error, if one exists
* @return void
*/
function PrintTypeField(array $Data, $Error)
{
$AllowedTypes = MakeTypesHumanReadable($Data["AllowedTypes"]);
$HasNoAllowedTypes = !count($AllowedTypes);
$SafeType = defaulthtmlentities($Data["Type"]);
$SafeTypeName = defaulthtmlentities(MetadataField::$FieldTypeHumanEnums[$Data["Type"]]);
?>
class="cw-form-error" for="F_Type">Type
All fields.
Name
All fields.
class="cw-form-error" for="F_Name">Name
All fields.
class="cw-form-error" for="F_Label">Display Name
All fields.
Definition
All fields.
class="cw-form-error" for="F_Instructions">Instructions
All fields.
class="cw-form-error" for="F_Enabled">Enabled
All fields.
class="cw-form-error" for="F_Editable">Editable
All fields.
class="cw-form-error" for="F_Optional">Optional
Text , Paragraph , Number , Date ,
Timestamp , Flag , Tree , Controlled Name ,
Option , User , Image , File , URL , and
Point fields.
class="cw-form-error" for="F_UsesQualifiers">Uses Qualifiers
Text , Paragraph , Number , Date ,
Timestamp , Flag , Tree , Controlled Name ,
Option , Image , File , URL , and Point
fields.
class="cw-form-error" for="F_HasItemLevelQualifiers">Has Item Level Qualifiers
Text , Paragraph , Number , Date ,
Timestamp , Flag , Tree , Controlled Name ,
Option , Image , File , URL , and Point
fields.
Id() == MetadataSchema::SCHEMAID_DEFAULT &&
array_search($Data["Name"], $ExcludedFields) !== FALSE)
{
return;
}
list($SafeTex, $SaveValue) = GetSafeFlagOption($Data["CopyOnResourceDuplication"]);
?>
class="cw-form-error" for="F_CopyOnResourceDuplication">Copy on Resource Duplication
All fields.
"--") + $Options;
?>
class="cw-form-error" for="F_DefaultQualifier">Default Qualifier
Text , Paragraph , Number , Date ,
Timestamp , Flag , Tree , Controlled Name ,
Option , Image , File , URL , and Point
fields.
class="cw-form-error" for="F_AssociatedQualifierList">Allowed Qualifiers
Text , Paragraph , Number , Date ,
Timestamp , Flag , Tree , Controlled Name ,
Option , Image , File , URL , and Point
fields.
class="cw-form-error" for="F_ShowQualifiers">Show Qualifiers
(on the full record page)
Text , Paragraph , Number , Date ,
Timestamp , Flag , Tree , Controlled Name ,
Option , Image , File , URL , and Point
fields.
class="cw-form-error" for="F_IncludeInKeywordSearch">Include in Keyword Search
Text , Paragraph , Number , Tree , Controlled
Name , Option , User , Image , File , and
URL fields.
class="cw-form-error" for="F_IncludeInAdvancedSearch">Include in Advanced Search
Text , Paragraph , Number , Date ,
Timestamp , Flag , Tree , Controlled Name ,
Option , User , Image , File , URL , and
Reference fields.
class="cw-form-error" for="F_IncludeInFacetedSearch">Include in Faceted Search
Tree , Controlled Name , and Option fields.
class="cw-form-error" for="F_IncludeInSortOptions">Include in Sort Options
Text , Number , Date , Timestamp , and
URL fields.
Search Weight
(1-20)
Text , Paragraph , Number , Date ,
Timestamp , Tree , Controlled Name , Option ,
User , Image , File , URL , and
Reference fields.
Option List Field Threshold
(1 or more)
Tree and Controlled Name fields.
Incremental Search Field Threshold
(1 or more)
Tree , Controlled Name , and Reference fields.
Max Number of Search Results
(10 or more)
Tree , Controlled Name , and Reference fields.
class="cw-form-error" for="F_UseForOaiSets">Use for OAI Sets
Tree , Controlled Name , and Option fields.
class="cw-form-error" for="F_DisplayAsLIstForAdvancedSearch">Display as list for Advanced Search
Tree fields.
Field Size
characters
Text , Number , Date , and Point fields.
cw-form-required" for="F_MaxLength">Max Length
characters
characters
(Note: making this value smaller will not truncate any
existing field values)
Text and URL fields.
None";
}
?>
class="cw-form-error" for="F_DefaultValue[Generic]">Default Value
Text and Paragraph fields.
None";
}
?>
class="cw-form-error" for="F_DefaultValue[Numeric]">Default Value
Number fields.
$Data["FlagOffLabel"], 1 => $Data["FlagOnLabel"]);
$SafeText = defaulthtmlentities($Value ? $Options[1] : $Options[0]);
$SafeValue = defaulthtmlentities($Value ? 1 : 0);
?>
class="cw-form-error" for="F_DefaultValue[Flag]">Default Value
Flag fields.
NULL, "Y" => NULL);
$SafeValue = defaulthtmlentities($DefaultValue["X"]);
$SafeValue2 = defaulthtmlentities($DefaultValue["Y"]);
if ($Data["HasOwner"])
{
if (!strlen($SafeValue))
{
$SafeValue = "None ";
}
if (!strlen($SafeValue2))
{
$SafeValue2 = "None ";
}
}
?>
class="cw-form-error" for="F_DefaultValue[Point1]">Default Value
X: , Y:
X:
Y:
Point fields.
class="cw-form-error" for="F_AllowHTML">Allow HTML in Text
Tree and Paragraph fields.
Min Value
Number fields.
Max Value
Number fields.
class="cw-form-required" for="F_PointPrecision">Point Precision
digits to the left of the decimal point
digits to the left of the decimal point
Point fields.
cw-form-required" for="F_PointDecimalDigits">Decimal Digits in Point
digits to the right of the decimal point
digits to the right of the decimal point
Point fields.
class="cw-form-error" for="F_UpdateMethod">Update Method
Timestamp fields.
Paragraph Rows
Paragraph fields.
Paragraph Cols
Paragraph fields.
class="cw-form-error" for="F_UseWysiwygEditor">Use WYSIWYG Editor
Paragraph fields.
Flag On Label
Flag fields.
Flag Off Label
Flag fields.
class="cw-form-error" for="F_AllowMultiple">Allow Multiple
Option fields.
Default Alt Text
Image fields.
Max Height
Image fields.
Max Width
Image fields.
Max Preview Height
Image fields.
Max Preview Width
Image fields.
Max Thumbnail Height
Image fields.
Max Thumbnail Width
Image fields.
GetPrivileges(TRUE, FALSE);
$Selected = $Data["UserPrivilegeRestrictions"];
?>
class="cw-form-error" for="F_UserPrivilegeRestrictions">Restrict to Users With One of the Following
User fields.
ViewingPrivileges();
?>
">Viewing Permissions
Schema requirements are: Id(); ?>">Edit
GetPrivilegeInfo() )); ?>
In addition, this field requires :
DisplaySet("ViewingPrivileges", $Data["ViewingPrivileges"]); ?>
All fields.
AuthoringPrivileges();
?>
">Authoring Permissions
Schema requirements are: Id(); ?>">Edit
GetPrivilegeInfo() )); ?>
In addition, this field requires :
DisplaySet("AuthoringPrivileges", $Data["AuthoringPrivileges"]); ?>
All fields.
EditingPrivileges();
?>
">Editing Permissions
Schema requirements are: Id(); ?>">Edit
GetPrivilegeInfo() )); ?>
In addition, this field requires :
DisplaySet("EditingPrivileges", $Data["EditingPrivileges"]); ?>
All fields.
"is", "!=" => "is not",
">" => "is greater than",
"<" => "is less than");
# construct an array to hold descriptions of each priv element
$Elements = array();
# unset "Logic" so that we can iterate over the rest
unset($PrivilegeData["Logic"]);
# foreach privilege info element
foreach ($PrivilegeData as $Key => $Condition)
{
# have resource
if (is_array($Condition) &&
$Condition["FieldId"] == PrivilegeSet::HAVE_RESOURCE )
{
$Elements []= "Checking resource is ".
( (bool)$Condition["Value"] ? "true" : "false");
}
# field conditions
elseif (is_array($Condition))
{
try
{
# get the field
$Field = new MetadataField($Condition["FieldId"]);
$SafeName = defaulthtmlentities($Field->Name());
$SafeOperator = $OpNames[ $Condition["Operator"] ];
# proper dislpay of 'current user' tests against user fields
if ($Field->Type() == MetadataSchema::MDFTYPE_USER &&
is_null($Condition["Value"]))
{
$SafeValue = "current user";
}
elseif ($Field->Type() == MetadataSchema::MDFTYPE_OPTION)
{
# proper display of cname values and the contains /
# does not contain test.
$CName = new ControlledName($Condition["Value"]);
$SafeValue = defaulthtmlentities($CName->Name());
if ($Condition["Operator"] == "==" )
{
$SafeOperator = "contains";
}
elseif ($Condition["Operator"] == "!=")
{
$SafeOperator = "does not contain";
}
}
elseif ($Field->Type() == MetadataSchema::MDFTYPE_FLAG)
{
# friendly names for flag values
$SafeValue = ($Condition["Value"]==1)? "true" : "false";
}
else
{
# otherwise display the literal value
$SafeValue = defaulthtmlentities($Condition["Value"]);
}
}
catch (Exception $e)
{
# handle invalid (or deleted) fields
$SafeName = "INVALID FIELD";
$SafeValue = defaulthtmlentities($Condition["Value"]);
}
# append friendly description to our list
$Elements []= $SafeName." ".$SafeOperator." ".$SafeValue;
}
elseif (is_numeric($Condition))
{
# for priv conditions, use priv names
$PrivFlag = new Privilege($Condition);
$Elements []= "Current user has ".$PrivFlag->Name()." privilege";
}
elseif ($Condition instanceof PrivilegeSet)
{
# for subgroups, wrap a div around a recursive call to ourself
$Elements []=
"(".
ReadOnlyPrivilegeHtml($Condition->GetPrivilegeInfo()).
"
)";
}
}
# glue together all the elements we collected with our logic
return implode(" ".$Logic." ", $Elements);
}
# ----- MAIN -----------------------------------------------------------------
$SafeSchemaId = defaulthtmlentities($H_Schema->Id());
$SafeId = defaulthtmlentities($H_FieldData["Id"]);
$SafeName = defaulthtmlentities($H_FieldData["Name"]);
$SafeMappedName = defaulthtmlentities($H_FieldData["MappedName"]);
$SafeTypeAsName = defaulthtmlentities($H_FieldData["TypeAsName"]);
$SafeOwner = defaulthtmlentities($H_FieldData["Owner"]);
?>