RequireUIFile("CW-Keyboard.js"); $GLOBALS["AF"]->RequireUIFile("CW-QuickSearch.js"); $Schema = new MetadataSchema($Resource->SchemaId()); $Ordering = $Schema->GetEditOrder(); $Items = $Ordering->GetItems(); PrintFieldTableBegin( $Resource, $User, $EditingAllowed, $ErrorCode, $ErrorFieldIds, $ErrorInfoOne, $ErrorInfoTwo); $InTableBody = FALSE; ?>

Id()); $SafeGroupName = defaulthtmlentities($Item->Name()); $Fields = $Item->GetFields(); # go to the next item if there are no fields in the group if (!count($Fields)) { continue; } ?>

GUIFile("CKEditorSetup.php")); # error codes (NOTE: Must match codes in SPT--EditResourceComplete.php!!!) if (!defined("ERR_FILEUPLOADERROR")) { define("ERR_FILEUPLOADERROR", 1); define("ERR_ZEROLENGTH", 2); define("ERR_IMAGEUPLOADERROR", 3); define("ERR_UNSUPPORTEDIMAGEFORMAT", 4); define("ERR_UNKNOWNIMAGETYPE", 5); define("ERR_REQUIREDFIELDEMPTY", 6); define("ERR_POSTEMPTY", 7); define("ERR_IMAGESTORE", 8); define("ERR_TEMPSTORE", 9); define("ERR_FILESTORE", 10); } # error messages $ErrorMessages = array( ERR_FILEUPLOADERROR => "A problem was encountered uploading the file %s for the %s field. (%s)", ERR_ZEROLENGTH => "The file %s uploaded to the %s field was empty (zero length).", ERR_IMAGEUPLOADERROR => "A problem was encountered uploading the image file %s for the %s field. (%s)", ERR_UNSUPPORTEDIMAGEFORMAT => "The image file %s uploaded for the %s field was in an unsupported image format.", ERR_UNKNOWNIMAGETYPE => "The image file %s uploaded for the %s field was of an unknown type.", ERR_REQUIREDFIELDEMPTY => "%s%s is a required field.", ERR_POSTEMPTY => "File or image upload was too large (No POST data received)", ERR_IMAGESTORE => "There were problems with the image store:%s
Contact the site administrator with this information to resolve them.", ERR_TEMPSTORE => "tmp does not exist or is not writeable, contact the site administrator with this error.", ERR_FILESTORE => File::GetStorageDirectory()." does not exist or is not writeable, contact the site administrator with this error." ); ?>

- GetDisplayName(), $ErrorInfoTwo); ?>

UserCanViewField($User, $Field)) { $Edit = $EditingAllowed ? $Resource->UserCanModifyField($User, $Field) : FALSE; # if the field is not editable, don't allow editing in this # interface if (!$Field->Editable()) { $Edit = FALSE; } $Error = $ErrorCode && in_array($Field->Id(), $ErrorFieldIds); $EditValue = $Resource->GetByField($Field); global $AF; $SignalResult = $AF->SignalEvent( ($Edit ? "EVENT_PRE_FIELD_EDIT_FILTER" : "EVENT_FIELD_DISPLAY_FILTER"), array( "Field" => $Field, "Resource" => $Resource, "Value" => $EditValue)); $EditValue = $SignalResult["Value"]; # get additional HTML to display, if any $Context = $Edit ? "EDIT" : "EDIT_COMPLETE_DISPLAY"; $SignalResult = $AF->SignalEvent( "EVENT_APPEND_HTML_TO_FIELD_DISPLAY", array( "Field" => $Field, "Resource" => $Resource, "Context" => $Context, "Html" => NULL)); $Html = $SignalResult["Html"]; switch ($Field->Type()) { case MetadataSchema::MDFTYPE_TEXT: case MetadataSchema::MDFTYPE_NUMBER: case MetadataSchema::MDFTYPE_DATE: case MetadataSchema::MDFTYPE_URL: DisplayTextField( $Field, $Resource, $Edit, $Error, $EditValue, $Html); break; case MetadataSchema::MDFTYPE_TIMESTAMP: DisplayTimestampField( $Field, $Resource, $Edit, $Error, $EditValue, $Html); break; case MetadataSchema::MDFTYPE_POINT: DisplayPointField( $Field, $Resource, $Edit, $Error, $EditValue, $Html); break; case MetadataSchema::MDFTYPE_PARAGRAPH: DisplayParagraphField( $Field, $Resource, $Edit, $Error, $EditValue, $Html); break; case MetadataSchema::MDFTYPE_FLAG: DisplayFlagField( $Field, $Resource, $Edit, $Error, $EditValue, $Html); break; case MetadataSchema::MDFTYPE_TREE: DisplayTreeField($Field, $Resource, $Edit, $Error, $Html); break; case MetadataSchema::MDFTYPE_CONTROLLEDNAME: DisplayControlledNameField($Field, $Resource, $Edit, $Error, $Html); break; case MetadataSchema::MDFTYPE_OPTION: DisplayOptionField($Field, $Resource, $Edit, $Error, $Html); break; case MetadataSchema::MDFTYPE_USER: DisplayUserField($Field, $Resource, $Edit, $Error, $Html); break; case MetadataSchema::MDFTYPE_IMAGE: DisplayImageField($Field, $Resource, $Edit, $Error, $Html); break; case MetadataSchema::MDFTYPE_FILE: DisplayFileField($Field, $Resource, $Edit, $Error, $Html); break; case MetadataSchema::MDFTYPE_REFERENCE: DisplayReferenceField($Field, $Resource, $Edit, $Error, $Html); } } } /** * Print the label for a metadata field cell. * @param MetadataField $Field The field whose label we print. * @param Boolean $Error Whether the field has an error we need to show. * @param Boolean $IsEditable Whether the field is editable at present. * @param Boolean $PseudoLabel If there is a pseudolabel we should include. */ function PrintLabelCell($Field, $Error, $IsEditable, $PseudoLabel=FALSE) { $FieldName = defaulthtmlentities($Field->GetDisplayName()); $Instructions = $Field->Instructions(); $ClassAttr = NULL; $OnEditPage = GetArrayValue($_GET, "P") == "EditResource"; # use the field definition if no instructions are available if (strlen($Instructions) < 1) { $Instructions = $Field->Description(); } $Title = defaulthtmlentities(strip_tags(trim($Instructions))); $Instructions = defaulthtmlentities(trim($Instructions)); if ($Error) { $ClassAttr = "cw-form-error"; } else if (!$Field->Optional() && $IsEditable) { $ClassAttr = "cw-form-required"; } ?> PUIFile("help.png"); ?>" alt="?" title=""/>
MaxLength()) { ?> maxlength="MaxLength(); ?>" />
MaxLength()) { ?> maxlength="MaxLength(); ?>" /> UpdateMethod() == MetadataField::UPDATEMETHOD_BUTTON) { ?>
(not set)"; } ?>
AllowHTML() && $Field->UseWysiwygEditor(); ?>
class="ckeditor"<?PHP } ?> name="F_<?PHP print $Field->DBFieldName(); ?>" rows="<?PHP print $Field->ParagraphRows(); ?>" cols="<?PHP print $Field->ParagraphCols(); ?>" ><?PHP print htmlspecialChars($Value); ?>
/> FlagOnLabel(); ?> /> FlagOffLabel(); ?> FlagOnLabel() : $Field->FlagOffLabel(); } ?>
GetByField($Field, TRUE); ?> 0) { ?> class="cw-content-tallrow">

"; # display link to file print ''. htmlspecialchars($File->Name()).''; # display delete button print ''; print ""; } print '

'; } # display file name selection and upload buttons if (count($Files) == 0 || $Field->AllowMultiple()) { print '' .''; } } else { # if there are files uploaded if (count($Files)) { # for each previously uploaded file foreach ($Files as $File) { # display link to file ?>Name()); ?>
(no files uploaded) GetByField($Field, TRUE); if (is_object($Images)) { $Images = array($Images); } ?>

LinkTarget(); $SafeHref = defaulthtmlentities( (!empty($LinkTarget) ? $LinkTarget : $Image->GetLink() )); $SafeSrc = defaulthtmlentities($Image->ThumbnailUrl()); $SafeAlt = defaulthtmlentities($Image->AltText()); $SafeId = defaulthtmlentities($Image->Id()); ?>
|  | Description:
DBFieldName()); $SafeAltText = defaulthtmlentities($Field->DefaultAltText()); ?>
|  | Description:

LinkTarget(); $SafeHref = defaulthtmlentities( (!empty($LinkTarget) ? $LinkTarget : $Image->GetLink() )); $SafeSrc = defaulthtmlentities($Image->ThumbnailUrl()); $SafeAlt = defaulthtmlentities($Image->AltText()); ?>

(no images uploaded)
Get($Field); asort($Values); # get all possible values and sort them alphabetically $PossibleValues = $Field->GetPossibleValues(); asort($PossibleValues); $MaxValueLength = 0; # determine the length of the longest value in order to determine how many # options will be displayed per row foreach ($PossibleValues as $PossibleValue) { $Length = strlen($PossibleValue); if ($Length > $MaxValueLength) { $MaxValueLength = $Length; } } # determine how many values per row based on length of longest value if ($MaxValueLength > 25) { $OptionsPerRow = 2; } else if ($MaxValueLength > 17) { $OptionsPerRow = 3; } else if ($MaxValueLength > 12) { $OptionsPerRow = 4; } else { $OptionsPerRow = 5; } # determine how many rows there should be $NumberOfRows = ceil((count($PossibleValues) + ($OptionsPerRow - 1)) / $OptionsPerRow); $SafeFieldName = defaulthtmlentities($Field->DBFieldName()); ?>
" name="[]" value="" /> ">
GetPossibleValues(); if ($Field->Type()==MetadataSchema::MDFTYPE_USER) { $Names += $Resource->Get($Field); } asort($Names); $Names = array(-1 => "--") + $Names; # retrieve values currently selected $SetNames = $Resource->Get($Field); asort($SetNames); # set up javascript function to dynamically populate option lists $DBFieldName = $Field->DBFieldName(); ?>
$Name) { PrintOptionList("D_".$DBFieldName."_".$MenuIndex, $Names, $NameId, "", 1, 0, FALSE, "CheckAdd('dbentry', 'D_".$DBFieldName."_', ".$MenuIndex.");", "auto; display: block; max-height: 10000000"); $MenuIndex++; } # print option list for use in selecting additional name PrintOptionList("D_".$DBFieldName."_".$MenuIndex, $Names, -1, "", 1, 0, FALSE, "CheckAdd('dbentry', 'D_".$DBFieldName."_', ".$MenuIndex.");", "auto; display: block; max-height: 10000000"); $MenuIndex++; # print shells to contain additional option lists $MaxNames = 21; for (; $MenuIndex < $MaxNames; $MenuIndex++) { ?>
LoadFunction("PrintQuickSearchField"); $SafeValues = array(); # get the escaped values for the references foreach ($Resource->Get($Field) as $NameId => $Name) { $SafeValues[$Name] = array( "Id" => defaulthtmlentities($NameId), "Name" => defaulthtmlentities($Name)); } # sort alphabetically by key ksort($SafeValues); foreach ($SafeValues as $Val) { PrintQuickSearchField( $Field->Id(), $Val["Id"], $Val["Name"]); } # print the blank search field where appropriate if (count($SafeValues)==0 || $Field->AllowMultiple()) { PrintQuickSearchField($Field->Id(),"","", $Field->AllowMultiple()); } } /** * Display terms using a list. * @param MetadataField $Field The Field we are displaying. * @param Resource $Resource The resource whose terms we are printing. */ function DisplayTermUsingList($Field, $Resource) { # retrieve all possible values $PossibleValues = $Field->GetPossibleValues(); if ($Field->Type()==MetadataSchema::MDFTYPE_USER) { $PossibleValues += $Resource->Get($Field); } # sort values and add "no value" value $PossibleValues[-1] = "--"; asort($PossibleValues); # retrieve value currently selected # value comes out as an array of ThingId => ThingName # flip it to an array of ThingName => ThingId and grab the first ThingId # (we don't have to worry about having more than one, we won't be called # if AllowMultiple is true) $Value = array_flip($Resource->Get($Field)); $SelectedValue = array_shift($Value); # set up javascript function to dynamically populate option lists $DBFieldName = $Field->DBFieldName(); PrintOptionList( "F_".$DBFieldName, $PossibleValues, $SelectedValue, "", 1, 0, FALSE, "", "auto; display: block; max-height: 10000000"); } /** * Display a controlled name field. * @param MetadataField $Field The Field we are displaying. * @param Resource $Resource The resource whose terms we are printing. * @param Boolean $IsEditable Whether this user can edit this field. * @param Boolean $Error Whether the field has an error we need to show. * @param String $Html Optional HTML to append to the end of the field. OPTIONAL. */ function DisplayControlledNameField($Field, $Resource, $IsEditable, $Error, $Html=NULL) { $OptionListThreshold = $Field->OptionListThreshold(); $AjaxThreshold = $Field->AjaxThreshold(); $ValueCount = $Field->GetCountOfPossibleValues(); ?>
(no values defined for this field)"; } else { if ($ValueCount < $OptionListThreshold) { DisplayTermsUsingOptions($Field, $Resource); } else if ($ValueCount < $AjaxThreshold) { if ($Field->AllowMultiple()) { DisplayTermsUsingLists($Field, $Resource); } else { DisplayTermUsingList($Field, $Resource); } } else { DisplayTermsUsingSearch($Field, $Resource); } } } else { ?>

GetByField($Field, TRUE); asort($CurrentValues); foreach ($CurrentValues as $Value) { $Qualifier = $Value->Qualifier(); print "
- "; print htmlspecialchars($Value->Name()); if ($Qualifier && strlen($Qualifier->Name())>0) { print " (".htmlspecialchars($Qualifier->Name()).")"; } print "
"; } ?>

0) { ?>
GetByField($Field); # retrieve all possible values if user can edit this field if ($IsEditable) { $Options = $Field->GetPossibleValues(); asort($Options); } # otherwise use just options that are set to display else { $Options = $SetOptions; } $MaxLength = 0; # determine the length of the longest value foreach ($Options as $OptionName) { $Length = strlen($OptionName); if ($Length > $MaxLength) { $MaxLength = $Length; } } # determine how many values per row based on length of longest value if ($MaxLength > 25) { $OptionsPerRow = 2; } else if ($MaxLength > 17) { $OptionsPerRow = 3; } else if ($MaxLength > 12) { $OptionsPerRow = 4; } else { $OptionsPerRow = 5; } # determine number of rows $OptionCount = count($Options); $NumberOfRows = intval(($OptionCount + ($OptionsPerRow - 1)) / $OptionsPerRow); ?> 1) { ?> class="cw-content-tallrow">

AllowMultiple()) { ?>" name="DBFieldName()."_".$OptionId."\""; if (in_array($OptionName, $SetOptions)) { print " checked"; } print " />"; ?> " > "; ?>
(no options selected)

"; } ?> AllowMultiple()) { ?>
DBFieldName()); $SafeFieldId = defaulthtmlentities($Field->Id()); $Users = $Resource->Get($Field, TRUE); $GLOBALS["AF"]->LoadFunction("PrintQuickSearchField"); if (count($Users) > 0) { foreach ($Users as $User) { if ($User instanceof User) { PrintQuickSearchField( $Field->Id(), $User->Id(), $User->Name() ); } } } if ($Field->AllowMultiple()) { PrintQuickSearchField($Field->Id(), "", "", TRUE); } elseif (count($Users)==0) { PrintQuickSearchField($Field->Id(), "", ""); } } /** * Display a user field. * @param MetadataField $Field The Field we are displaying. * @param Resource $Resource The resource whose terms we are printing. * @param Boolean $IsEditable Whether this user can edit this field. * @param Boolean $Error Whether the field has an error we need to show. * @param String $Html Optional HTML to append to the end of the field. OPTIONAL. */ function DisplayUserField($Field, $Resource, $IsEditable, $Error, $Html=NULL) { $InterfaceToggleThreshold = 45; $ValueCount = $Field->GetCountOfPossibleValues(); $Users = $Resource->Get($Field, TRUE); if (!is_array($Users)) { $Users = array($Users); } ?>
AllowMultiple()) { DisplayTermsUsingLists($Field, $Resource); } else { DisplayTermUsingList($Field, $Resource); } } else { DisplayUserUsingSearch($Field, $Resource); } ?>

- Get("UserName")); ?>

Id()); $SafeDBFieldName = defaulthtmlentities($Field->DBFieldName()); $SafeReferences = array(); $SafeNumAjaxResults = defaulthtmlentities($Field->NumAjaxResults()); $Schema = new MetadataSchema($Resource->SchemaId()); $TitleField = $Schema->GetFieldByMappedName("Title"); $GLOBALS["AF"]->LoadFunction("PrintQuickSearchField"); # get the escaped values for the references foreach ($Resource->Get($Field, TRUE) as $ReferenceId => $Reference) { $Schema = new MetadataSchema($Reference->SchemaId()); $TitleField = $Schema->GetFieldByMappedName("Title"); $Title = $Reference->Get($TitleField); # remove HTML if editing because HTML tags are displayed as text in # input fields if ($IsEditable) { $Title = strip_tags($Title); } # otherwise escape HTML characters if HTML is not allowed in the field else if (!$TitleField->AllowHTML()) { $Title = defaulthtmlentities($Title); } $SafeReferences[] = array( "Id" => defaulthtmlentities($ReferenceId), "Title" => $Title); } ?>

- " >