3 # FILE: ItemFactory.php
5 # Part of the Collection Workflow Integration System (CWIS)
6 # Copyright 2013 Edward Almasy and Internet Scout Research Group
7 # http://scout.wisc.edu/cwis/
32 switch ($this->Field->Status())
39 return "Duplicate field name";
41 return "Duplicate database column";
43 return "Field does not exist";
45 return "Illegal field name";
47 return "Duplicate label name";
49 return "Illegal label name";
70 return $this->Field->TypeAsName();
79 return $this->Field->GetDisplayName();
88 return $this->Field->Name();
106 $Value = $this->Field->GetAllowedConversionTypes();
118 return $this->
GetYesNo($this->Field->IsTempItem());
127 return $this->Field->Id();
136 return $this->Field->DBFieldName();
145 # for our purposes, HTML code and some whitespace are not human-readable
146 $Value = strip_tags($this->Field->Description());
147 $Value = trim(str_replace(array(
"\r",
"\n",
"\t"),
" ", $Value));
148 $Value = preg_replace(
'/ +/',
" ", $Value);
159 # for our purposes, HTML code and some whitespace are not human-readable
160 $Value = strip_tags($this->Field->Instructions());
161 $Value = trim(str_replace(array(
"\r",
"\n",
"\t"),
" ", $Value));
162 $Value = preg_replace(
'/ +/',
" ", $Value);
183 return $this->
GetYesNo($this->Field->RequiredBySPT());
192 return $this->
GetYesNo($this->Field->Enabled());
201 return $this->
GetYesNo($this->Field->Optional());
210 return $this->
GetYesNo($this->Field->Editable());
219 return $this->
GetYesNo($this->Field->Viewable());
230 return $this->
GetYesNo($this->Field->AllowMultiple());
241 return $this->
GetYesNo($this->Field->IncludeInKeywordSearch());
252 return $this->
GetYesNo($this->Field->IncludeInAdvancedSearch());
263 return $this->
GetYesNo($this->Field->IncludeInFacetedSearch());
274 return $this->
GetYesNo($this->Field->IncludeInSortOptions());
285 return $this->
GetYesNo($this->Field->IncludeInRecommender());
463 return $this->
GetYesNo($this->Field->UsesQualifiers());
474 return $this->
GetYesNo($this->Field->ShowQualifiers());
483 $DefaultQualifier = $this->Field->DefaultQualifier();
485 if ($DefaultQualifier > 0)
487 $Qualifier =
new Qualifier($DefaultQualifier);
489 return $Qualifier->Name();
502 return $this->
GetYesNo($this->Field->AllowHTML());
513 return $this->
GetYesNo($this->Field->UseWysiwygEditor());
524 return $this->
GetYesNo($this->Field->UseForOaiSets());
534 return $this->Field->NumAjaxResults();
543 $Value = $this->
MapPrivilege($this->Field->ViewingPrivilege());
554 $Value = $this->
MapPrivilege($this->Field->AuthoringPrivilege());
565 $Value = $this->
MapPrivilege($this->Field->EditingPrivilege());
576 $Value = $this->
MapPrivilege($this->Field->ImagePreviewPrivilege());
587 $Value = $this->
MapPrivilege($this->Field->TreeBrowsingPrivilege());
600 return $this->
GetYesNo($this->Field->EnableOnOwnerReturn());
609 $Value = $this->
MapUserIsValue($this->Field->ViewingUserIsValue());
620 $Value = $this->
MapUserIsValue($this->Field->AuthoringUserIsValue());
631 $Value = $this->
MapUserIsValue($this->Field->EditingUserIsValue());
642 $Value = $this->
MapUserValue($this->Field->ViewingUserValue());
653 $Value = $this->
MapUserValue($this->Field->AuthoringUserValue());
664 $Value = $this->
MapUserValue($this->Field->EditingUserValue());
675 $Value = $this->Field->UserPrivilegeRestrictions();
678 # need to map each privilege ID to its text
679 foreach ($Value as $Id)
711 $Type = $this->Field->Type();
712 $Value = $this->Field->DefaultValue();
727 return (strlen($XText) ? $XText .
", " :
"") .
"Y: " . $Y;
735 # multiple default values are set
736 if (is_array($Value))
738 foreach ($Value as $Id)
742 $Names[] = $ControlledName->Name();
745 return implode(
", ", $Names);
748 # only one default value
753 return $ControlledName->Name();
773 $Value = $this->Field->UpdateMethod();
786 $Value = $this->Field->GetPossibleValues();
809 return $this->
GetYesNo($this->Field->HasItemLevelQualifiers());
818 $Value = $this->Field->AssociatedQualifierList();
828 $Value = $this->Field->UnassociatedQualifierList();
879 $this->NotSetText = $Text;
889 return $Value ?
"Yes" :
"No";
911 $Privilege = $this->
MapPrivilege($this->Field->{$Mode.
"Privilege"}());
912 $UserIsValue = $this->
MapUserIsValue($this->Field->{$Mode.
"UserIsValue"}());
913 $UserValue = $this->MapUserValue($this->Field->{$Mode.
"UserValue"}());
917 # add the user privilege constraint first, if set
918 if (!is_null($Privilege))
920 $String = $Privilege;
923 # then add the "user is value of field" constraint, if set
924 if (!is_null($UserIsValue) && !is_null($UserValue))
926 if (is_null($String))
928 $String =
"User is value of " . $UserValue;
933 $String .=
" " . $UserIsValue .
" user is value of ";
934 $String .= $UserValue;
938 return is_null($String) ? $this->NotSetText : $String;
948 if (!isset(self::$PrivilegeList))
950 $this->LoadPrivilegeList();
953 return $this->GetArrayValue(self::$PrivilegeList, $Value);
963 self::$PrivilegeList = $PrivilegeFactory->GetPrivileges(TRUE, FALSE);
973 return $this->GetArrayValue(self::$UserIsValueList, $Value);
983 if (!isset(self::$UserFieldList))
985 $this->LoadUserFieldList();
988 return $this->GetArrayValue(self::$UserFieldList, $Value);
999 # make sure the list is set to something even if there are no user
1001 self::$UserFieldList = array();
1003 foreach ($UserFields as $Field)
1005 self::$UserFieldList[$Field->Id()] = $Field->GetDisplayName();
1021 return array_key_exists($Key, $Array) ? $Array[$Key] : $Default;
1035 protected $NotSetText =
"--";
1047 protected static $UserIsValueList = array(
Factory which extracts all defined privileges from the database.
Metadata type representing non-hierarchical controlled vocabulary values.