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());
589 return $this->
GetYesNo($this->Field->EnableOnOwnerReturn());
598 $Value = $this->
MapUserIsValue($this->Field->ViewingUserIsValue());
609 $Value = $this->
MapUserIsValue($this->Field->AuthoringUserIsValue());
620 $Value = $this->
MapUserIsValue($this->Field->EditingUserIsValue());
631 $Value = $this->
MapUserValue($this->Field->ViewingUserValue());
642 $Value = $this->
MapUserValue($this->Field->AuthoringUserValue());
653 $Value = $this->
MapUserValue($this->Field->EditingUserValue());
664 $Value = $this->Field->UserPrivilegeRestrictions();
667 # need to map each privilege ID to its text
668 foreach ($Value as $Id)
700 $Type = $this->Field->Type();
701 $Value = $this->Field->DefaultValue();
716 return (strlen($XText) ? $XText .
", " :
"") .
"Y: " . $Y;
724 # multiple default values are set
725 if (is_array($Value))
727 foreach ($Value as $Id)
731 $Names[] = $ControlledName->Name();
734 return implode(
", ", $Names);
737 # only one default value
742 return $ControlledName->Name();
762 $Value = $this->Field->UpdateMethod();
775 $Value = $this->Field->GetPossibleValues();
798 return $this->
GetYesNo($this->Field->HasItemLevelQualifiers());
807 $Value = $this->Field->AssociatedQualifierList();
817 $Value = $this->Field->UnassociatedQualifierList();
868 $this->NotSetText = $Text;
878 return $Value ?
"Yes" :
"No";
900 $Privilege = $this->
MapPrivilege($this->Field->{$Mode.
"Privileges"}());
901 $UserIsValue = $this->
MapUserIsValue($this->Field->{$Mode.
"UserIsValue"}());
902 $UserValue = $this->MapUserValue($this->Field->{$Mode.
"UserValue"}());
906 # add the user privilege constraint first, if set
907 if (!is_null($Privilege))
909 $String = $Privilege;
912 # then add the "user is value of field" constraint, if set
913 if (!is_null($UserIsValue) && !is_null($UserValue))
915 if (is_null($String))
917 $String =
"User is value of " . $UserValue;
922 $String .=
" " . $UserIsValue .
" user is value of ";
923 $String .= $UserValue;
927 return is_null($String) ? $this->NotSetText : $String;
937 if (!isset(self::$PrivilegeList))
939 $this->LoadPrivilegeList();
942 return $this->GetArrayValue(self::$PrivilegeList, $Value);
952 self::$PrivilegeList = $PrivilegeFactory->GetPrivileges(TRUE, FALSE);
962 return $this->GetArrayValue(self::$UserIsValueList, $Value);
972 if (!isset(self::$UserFieldList))
974 $this->LoadUserFieldList();
977 return $this->GetArrayValue(self::$UserFieldList, $Value);
988 # make sure the list is set to something even if there are no user
990 self::$UserFieldList = array();
992 foreach ($UserFields as $Field)
994 self::$UserFieldList[$Field->Id()] = $Field->GetDisplayName();
1010 return array_key_exists($Key, $Array) ? $Array[$Key] : $Default;
1024 protected $NotSetText =
"--";
1036 protected static $UserIsValueList = array(
Factory which extracts all defined privileges from the database.
Metadata type representing non-hierarchical controlled vocabulary values.