CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

MetadataField.php
Go to the documentation of this file.
1 <?PHP
2 #
3 # FILE: MetadataField.php
4 #
5 # Part of the Collection Workflow Integration System (CWIS)
6 # Copyright 2012-2013 Edward Almasy and Internet Scout Research Group
7 # http://scout.wisc.edu/cwis/
8 #
9
13 class MetadataField {
14
15 # ---- PUBLIC INTERFACE --------------------------------------------------
16
17 # update methods for timestamp fields
18 const UPDATEMETHOD_NOAUTOUPDATE = "NoAutoUpdate";
19 const UPDATEMETHOD_ONRECORDCREATE = "OnRecordCreate";
20 const UPDATEMETHOD_BUTTON = "Button";
21 const UPDATEMETHOD_ONRECORDEDIT = "OnRecordEdit";
22 const UPDATEMETHOD_ONRECORDCHANGE = "OnRecordChange";
23
24 # values for the *UserIsValue fields
25 const USERISVALUE_OR = -1;
26 const USERISVALUE_UNSET = 0;
27 const USERISVALUE_AND = 1;
28
34 function Status()
35 {
36 return $this->ErrorStatus;
37 }
38
45 function Type($NewValue = DB_NOVALUE)
46 {
47 # if new value supplied
48 $FTFieldName = $this->DBFields["FieldType"];
49 if (($NewValue != DB_NOVALUE)
50 && ($NewValue != self::$FieldTypePHPEnums[$FTFieldName]))
51 {
52 # update database fields and store new type
53 $this->ModifyField(NULL, $NewValue);
54 }
55
56 # return type to caller
57 return self::$FieldTypePHPEnums[$FTFieldName];
58 }
59
64 function TypeAsName()
65 {
66 return $this->DBFields["FieldType"];
67 }
68
73 function SchemaId()
74 {
75 return $this->DBFields["SchemaId"];
76 }
77
83 function GetDisplayName()
84 {
85 return strlen($this->Label()) ? $this->Label() : $this->Name();
86 }
87
94 function Name($NewName = DB_NOVALUE)
95 {
96 # if new name specified
97 if ($NewName != DB_NOVALUE
98 && trim($NewName) != $this->DBFields["FieldName"])
99 {
100 $NewName = trim($NewName);
101 $NormalizedName = $this->NormalizeFieldNameForDB(strtolower($NewName));
102
103 # if field name is invalid
104 if (!preg_match("/^[[:alnum:] \(\)]+$/", $NewName))
105 {
106 # set error status to indicate illegal name
107 $this->ErrorStatus = MetadataSchema::MDFSTAT_ILLEGALNAME;
108 }
109
110 # if the new name is a reserved word
111 else if ($NormalizedName == "resourceid" || $NormalizedName == "schemaid")
112 {
113 # set error status to indicate illegal name
114 $this->ErrorStatus = MetadataSchema::MDFSTAT_ILLEGALNAME;
115 }
116
117 # the name is okay but might be a duplicate
118 else
119 {
120 # check for duplicate name
121 $DuplicateCount = $this->DB->Query(
122 "SELECT COUNT(*) AS RecordCount FROM MetadataFields"
123 ." WHERE FieldName = '".addslashes($NewName)."'"
124 ." AND SchemaId = ".intval($this->DBFields["SchemaId"]),
125 "RecordCount");
126
127 # if field name is duplicate
128 if ($DuplicateCount > 0)
129 {
130 # set error status to indicate duplicate name
131 $this->ErrorStatus = MetadataSchema::MDFSTAT_DUPLICATENAME;
132 }
133 else
134 {
135 # modify database declaration to reflect new field name
136 $this->ErrorStatus = MetadataSchema::MDFSTAT_OK;
137 $this->ModifyField($NewName);
138 }
139 }
140 }
141
142 # return value to caller
143 return $this->DBFields["FieldName"];
144 }
145
151 function Label($NewLabel = DB_NOVALUE)
152 {
153 $ValidValueExp = '/^[[:alnum:] ]*$/';
154 $Value = $this->DBFields["Label"];
155
156 # if a new label was specified
157 if ($NewLabel !== DB_NOVALUE && trim($NewLabel) != $Value)
158 {
159 $NewLabel = trim($NewLabel);
160
161 # if field label is valid
162 if (preg_match($ValidValueExp, $NewLabel))
163 {
164 $this->UpdateValue("Label", $NewLabel);
165 $Value = $NewLabel;
166 }
167 # the field label is invalid
168 else
169 {
170 $this->ErrorStatus = MetadataSchema::MDFSTAT_ILLEGALLABEL;
171 }
172 }
173
174 return $Value;
175 }
176
182 function GetAllowedConversionTypes()
183 {
184 # determine type list based on our type
185 switch ($this->Type())
186 {
187 case MetadataSchema::MDFTYPE_TEXT:
188 case MetadataSchema::MDFTYPE_PARAGRAPH:
189 case MetadataSchema::MDFTYPE_NUMBER:
190 case MetadataSchema::MDFTYPE_FLAG:
191 case MetadataSchema::MDFTYPE_URL:
192 $AllowedTypes = array(
193 MetadataSchema::MDFTYPE_TEXT => "Text",
194 MetadataSchema::MDFTYPE_PARAGRAPH => "Paragraph",
195 MetadataSchema::MDFTYPE_NUMBER => "Number",
196 MetadataSchema::MDFTYPE_FLAG => "Flag",
197 MetadataSchema::MDFTYPE_URL => "Url"
198 );
199 break;
200
201 case MetadataSchema::MDFTYPE_CONTROLLEDNAME:
202 case MetadataSchema::MDFTYPE_OPTION:
203 $AllowedTypes = array(
204 MetadataSchema::MDFTYPE_CONTROLLEDNAME => "ControlledName",
205 MetadataSchema::MDFTYPE_OPTION => "Option",
206 );
207 break;
208
209 case MetadataSchema::MDFTYPE_DATE:
210 $AllowedTypes = array(
211 MetadataSchema::MDFTYPE_TEXT => "Text",
212 MetadataSchema::MDFTYPE_DATE => "Date",
213 );
214 break;
215
216 case MetadataSchema::MDFTYPE_IMAGE:
217 $AllowedTypes = array(
218 MetadataSchema::MDFTYPE_TEXT => "Text",
219 MetadataSchema::MDFTYPE_IMAGE => "Still Image",
220 );
221 break;
222
223 case MetadataSchema::MDFTYPE_TIMESTAMP:
224 case MetadataSchema::MDFTYPE_TREE:
225 case MetadataSchema::MDFTYPE_USER:
226 case MetadataSchema::MDFTYPE_FILE:
227 case MetadataSchema::MDFTYPE_REFERENCE:
228 default:
229 $AllowedTypes = array();
230 break;
231 }
232
233 # return type list to caller
234 return $AllowedTypes;
235 }
236
244 function IsTempItem($NewSetting = NULL)
245 {
246 $Schema = new MetadataSchema($this->SchemaId());
247 $ItemTableName = "MetadataFields";
248 $ItemIdFieldName = "FieldId";
249 $ItemFactoryObjectName = "MetadataSchema";
250 $ItemAssociationTables = array(
251 "FieldQualifierInts",
252 );
253 $ItemAssociationFieldName = "MetadataFieldId";
254
255 # if new temp item setting supplied
256 if (!is_null($NewSetting))
257 {
258 # if caller requested to switch
259 if (($this->Id() < 0 && $NewSetting == FALSE)
260 || ($this->Id() >= 0 && $NewSetting == TRUE))
261 {
262 # if field name is invalid
263 if (strlen($this->NormalizeFieldNameForDB($this->Name())) < 1)
264 {
265 # set error status to indicate illegal name
266 $this->ErrorStatus = MetadataSchema::MDFSTAT_ILLEGALNAME;
267 }
268 else
269 {
270 # lock DB tables to prevent next ID from being grabbed
271 $DB = $this->DB;
272 $DB->Query("
273 LOCK TABLES ".$ItemTableName." WRITE,
274 APSessions WRITE, APSessionData WRITE,
275 MetadataSchemas WRITE");
276
277 # nuke stale field cache
278 self::$FieldCache = NULL;
279
280 # get next temp item ID
281 $OldItemId = $this->Id();
282 $Factory = new $ItemFactoryObjectName();
283 if ($NewSetting == TRUE)
284 {
285 $NewId = $Factory->GetNextTempItemId();
286 }
287 else
288 {
289 $NewId = $Factory->GetNextItemId();
290 }
291
292 # change item ID
293 $DB->Query("UPDATE ".$ItemTableName." SET ".$ItemIdFieldName." = ".
294 $NewId. " WHERE ".$ItemIdFieldName." = ".$OldItemId);
295
296 # release DB tables
297 $DB->Query("UNLOCK TABLES");
298
299 # change associations
300 foreach ($ItemAssociationTables as $TableName)
301 {
302 $DB->Query("UPDATE ".$TableName." ".
303 "SET ".$ItemAssociationFieldName." = ".$NewId." ".
304 "WHERE ".$ItemAssociationFieldName." = ".$OldItemId);
305 }
306
307 # if changing item from temp to non-temp
308 if ($NewSetting == FALSE)
309 {
310 # add any needed database fields and/or entries
311 $this->AddDatabaseFields();
312
313 # Signal that a new (real) field was added:
314 global $AF;
315 $AF->SignalEvent(
316 "EVENT_FIELD_ADDED",
317 array("FieldId" => $NewId ) );
318
319 # set field order values for new field
320 $Schema->GetDisplayOrder()->AppendItem($NewId, "MetadataField");
321 $Schema->GetEditOrder()->AppendItem($NewId, "MetadataField");
322 }
323
324 # update metadata field id
325 $this->DBFields["FieldId"] = $NewId;
326 $this->Id = $NewId;
327 }
328 }
329 }
330
331 # report to caller whether we are a temp item
332 return ($this->Id() < 0) ? TRUE : FALSE;
333 }
334
340 function AuthoringPrivileges(PrivilegeSet $NewValue = NULL)
341 {
342 # if new privileges supplied
343 if ($NewValue !== NULL)
344 {
345 # store new privileges in database
346 $this->UpdateValue("AuthoringPrivileges", $NewValue->Data());
347 $this->AuthoringPrivileges = $NewValue;
348 }
349
350 # return current value to caller
351 return $this->AuthoringPrivileges;
352 }
353
359 function EditingPrivileges(PrivilegeSet $NewValue = NULL)
360 {
361 # if new privileges supplied
362 if ($NewValue !== NULL)
363 {
364 # store new privileges in database
365 $this->UpdateValue("EditingPrivileges", $NewValue->Data());
366 $this->EditingPrivileges = $NewValue;
367 }
368
369 # return current value to caller
370 return $this->EditingPrivileges;
371 }
372
378 function ViewingPrivileges(PrivilegeSet $NewValue = NULL)
379 {
380 # if new privileges supplied
381 if ($NewValue !== NULL)
382 {
383 # store new privileges in database
384 $this->UpdateValue("ViewingPrivileges", $NewValue->Data());
385 $this->ViewingPrivileges = $NewValue;
386 }
387
388 # return current value to caller
389 return $this->ViewingPrivileges;
390 }
391
397 function PreviewingPrivileges(PrivilegeSet $NewValue = NULL)
398 {
399 # if new privileges supplied
400 if ($NewValue !== NULL)
401 {
402 # store new privileges in database
403 $this->UpdateValue("PreviewingPrivileges", $NewValue->Data());
404 $this->PreviewingPrivileges = $NewValue;
405 }
406
407 # return current value to caller
408 return $this->PreviewingPrivileges;
409 }
410
415 function Id()
416 {
417 return $this->Id;
418 }
419
425 function DBFieldName()
426 {
427 return $this->DBFields["DBFieldName"];
428 }
429
435 function Description($NewValue = DB_NOVALUE)
436 {
437 return $this->UpdateValue("Description", $NewValue);
438 }
439
445 function Instructions($NewValue = DB_NOVALUE)
446 {
447 return $this->UpdateValue("Instructions", $NewValue);
448 }
449
455 function Owner($NewValue = DB_NOVALUE)
456 {
457 return $this->UpdateValue("Owner", $NewValue);
458 }
459
466 function Enabled($NewValue = DB_NOVALUE)
467 {
468 return $this->UpdateBoolValue("Enabled", $NewValue);
469 }
470
477 function Optional($NewValue = DB_NOVALUE)
478 {
479 return $this->UpdateBoolValue("Optional", $NewValue);
480 }
481
488 function Editable($NewValue = DB_NOVALUE)
489 {
490 return $this->UpdateBoolValue("Editable", $NewValue);
491 }
492
499 function AllowMultiple($NewValue = DB_NOVALUE)
500 {
501 return $this->UpdateBoolValue("AllowMultiple", $NewValue);
502 }
503
510 function IncludeInKeywordSearch($NewValue = DB_NOVALUE)
511 {
512 return $this->UpdateBoolValue("IncludeInKeywordSearch", $NewValue);
513 }
514
521 function IncludeInAdvancedSearch($NewValue = DB_NOVALUE)
522 {
523 return $this->UpdateBoolValue("IncludeInAdvancedSearch", $NewValue);
524 }
525
532 function IncludeInFacetedSearch($NewValue = DB_NOVALUE)
533 {
534 return $this->UpdateBoolValue("IncludeInFacetedSearch", $NewValue);
535 }
536
543 function IncludeInSortOptions($NewValue = DB_NOVALUE)
544 {
545 return $this->UpdateBoolValue("IncludeInSortOptions", $NewValue);
546 }
547
554 function IncludeInRecommender($NewValue = DB_NOVALUE)
555 {
556 return $this->UpdateBoolValue("IncludeInRecommender", $NewValue);
557 }
558
563 function CopyOnResourceDuplication($NewValue = DB_NOVALUE)
564 {
565 return $this->UpdateBoolValue("CopyOnResourceDuplication", $NewValue);
566 }
567
568 function TextFieldSize($NewValue = DB_NOVALUE)
569 {
570 return $this->UpdateIntValue("TextFieldSize", $NewValue);
571 }
572
573 function MaxLength($NewValue = DB_NOVALUE)
574 {
575 return $this->UpdateIntValue("MaxLength", $NewValue);
576 }
577
578 function ParagraphRows($NewValue = DB_NOVALUE)
579 {
580 return $this->UpdateIntValue("ParagraphRows", $NewValue);
581 }
582
583 function ParagraphCols($NewValue = DB_NOVALUE)
584 {
585 return $this->UpdateIntValue("ParagraphCols", $NewValue);
586 }
587
588 function MinValue($NewValue = DB_NOVALUE)
589 {
590 return $this->UpdateFloatValue("MinValue", $NewValue);
591 }
592
593 function MaxValue($NewValue = DB_NOVALUE)
594 {
595 return $this->UpdateFloatValue("MaxValue", $NewValue);
596 }
597
598 function FlagOnLabel($NewValue = DB_NOVALUE)
599 {
600 return $this->UpdateValue("FlagOnLabel", $NewValue);
601 }
602
603 function FlagOffLabel($NewValue = DB_NOVALUE)
604 {
605 return $this->UpdateValue("FlagOffLabel", $NewValue);
606 }
607
608 function DateFormat($NewValue = DB_NOVALUE)
609 {
610 return $this->UpdateValue("DateFormat", $NewValue);
611 }
612
613 function SearchWeight($NewValue = DB_NOVALUE)
614 {
615 return $this->UpdateIntValue("SearchWeight", $NewValue);
616 }
617
618 function RecommenderWeight($NewValue = DB_NOVALUE)
619 {
620 return $this->UpdateIntValue("RecommenderWeight", $NewValue);
621 }
622
623 function MaxHeight($NewValue = DB_NOVALUE)
624 {
625 return $this->UpdateIntValue("MaxHeight", $NewValue);
626 }
627
628 function MaxWidth($NewValue = DB_NOVALUE)
629 {
630 return $this->UpdateIntValue("MaxWidth", $NewValue);
631 }
632
633 function MaxPreviewHeight($NewValue = DB_NOVALUE)
634 {
635 return $this->UpdateIntValue("MaxPreviewHeight", $NewValue);
636 }
637
638 function MaxPreviewWidth($NewValue = DB_NOVALUE)
639 {
640 return $this->UpdateIntValue("MaxPreviewWidth", $NewValue);
641 }
642
643 function MaxThumbnailHeight($NewValue = DB_NOVALUE)
644 {
645 return $this->UpdateIntValue("MaxThumbnailHeight", $NewValue);
646 }
647
648 function MaxThumbnailWidth($NewValue = DB_NOVALUE)
649 {
650 return $this->UpdateIntValue("MaxThumbnailWidth", $NewValue);
651 }
652
653 function DefaultAltText($NewValue = DB_NOVALUE)
654 {
655 return $this->UpdateValue("DefaultAltText", $NewValue);
656 }
657
658 function UsesQualifiers($NewValue = DB_NOVALUE)
659 {
660 return $this->UpdateBoolValue("UsesQualifiers", $NewValue);
661 }
662
663 function ShowQualifiers($NewValue = DB_NOVALUE)
664 {
665 return $this->UpdateBoolValue("ShowQualifiers", $NewValue);
666 }
667
668 function DefaultQualifier($NewValue = DB_NOVALUE)
669 {
670 return $this->UpdateValue("DefaultQualifier", $NewValue);
671 }
672
673 function AllowHTML($NewValue = DB_NOVALUE)
674 {
675 return $this->UpdateBoolValue("AllowHTML", $NewValue);
676 }
677
678 function UseWysiwygEditor($NewValue = DB_NOVALUE)
679 {
680 return $this->UpdateBoolValue("UseWysiwygEditor", $NewValue);
681 }
682
683 function UseForOaiSets($NewValue = DB_NOVALUE)
684 {
685 return $this->UpdateBoolValue("UseForOaiSets", $NewValue);
686 }
687
688 function DisplayAsListForAdvancedSearch($NewValue = DB_NOVALUE)
689 {
690 return $this->UpdateBoolValue("DisplayAsListForAdvancedSearch", $NewValue);
691 }
692
693 function OptionListThreshold($NewValue = DB_NOVALUE)
694 {
695 return $this->UpdateIntValue("OptionListThreshold", $NewValue);
696 }
697
698 function AjaxThreshold($NewValue = DB_NOVALUE)
699 {
700 return $this->UpdateIntValue("AjaxThreshold", $NewValue);
701 }
702
703 function NumAjaxResults($NewValue = DB_NOVALUE)
704 {
705 return $this->UpdateIntValue("NumAjaxResults", $NewValue);
706 }
707
708 function ViewingPrivilege($NewValue = DB_NOVALUE)
709 {
710 if ($NewValue === DB_NOVALUE)
711 {
712 return $this->ViewingPrivileges();
713 }
714 else
715 {
716 throw new Exception("Deprecated ".__METHOD__."() called -- ".
717 __METHOD__."s() should be used instead.");
718 }
719 }
720 function AuthoringPrivilege($NewValue = DB_NOVALUE)
721 {
722 if ($NewValue === DB_NOVALUE)
723 {
724 return $this->AuthoringPrivileges();
725 }
726 else
727 {
728 throw new Exception("Deprecated ".__METHOD__."() called -- ".
729 __METHOD__."s() should be used instead.");
730 }
731 }
732 function EditingPrivilege($NewValue = DB_NOVALUE)
733 {
734 if ($NewValue === DB_NOVALUE)
735 {
736 return $this->EditingPrivileges();
737 }
738 else
739 {
740 throw new Exception("Deprecated ".__METHOD__."() called -- ".
741 __METHOD__."s() should be used instead.");
742 }
743 }
744 function ImagePreviewPrivilege($NewValue = DB_NOVALUE)
745 {
746 if ($NewValue === DB_NOVALUE)
747 {
748 return $this->ViewingPrivileges();
749 }
750 else
751 {
752 throw new Exception("Deprecated ".__METHOD__."() called -- ".
753 "ViewingPrivileges() should be used instead.");
754 }
755 }
756
757 function TreeBrowsingPrivilege($NewValue = DB_NOVALUE)
758 {
759 if ($NewValue === DB_NOVALUE)
760 {
761 return $this->ViewingPrivileges();
762 }
763 else
764 {
765 throw new Exception("Deprecated ".__METHOD__."() called -- ".
766 "this should probably be using ViewingPrivileges() instead.");
767 }
768 }
769 function EnableOnOwnerReturn($NewValue = DB_NOVALUE)
770 {
771 return $this->UpdateBoolValue("EnableOnOwnerReturn", $NewValue);
772 }
773
774 function ViewingUserIsValue($NewValue = DB_NOVALUE)
775 {
776 return $this->UpdateConstValue("ViewingUserIsValue", $NewValue, "MetadataField");
777 }
778
779 function AuthoringUserIsValue($NewValue = DB_NOVALUE)
780 {
781 return $this->UpdateConstValue(
782 "AuthoringUserIsValue", $NewValue, "MetadataField");
783 }
784
785 function EditingUserIsValue($NewValue = DB_NOVALUE)
786 {
787 return $this->UpdateConstValue("EditingUserIsValue", $NewValue, "MetadataField");
788 }
789
790 function ViewingUserValue($NewValue = DB_NOVALUE)
791 {
792 return $this->UpdateIntValue("ViewingUserValue", $NewValue, "MetadataField");
793 }
794
795 function AuthoringUserValue($NewValue = DB_NOVALUE)
796 {
797 return $this->UpdateIntValue("AuthoringUserValue", $NewValue, "MetadataField");
798 }
799
800 function EditingUserValue($NewValue = DB_NOVALUE)
801 {
802 return $this->UpdateIntValue("EditingUserValue", $NewValue, "MetadataField");
803 }
804
805 function RequiredBySPT($NewValue = DB_NOVALUE)
806 {
807 return $this->UpdateBoolValue("RequiredBySPT", $NewValue);
808 }
809
810 function UserPrivilegeRestrictions($NewValue = DB_NOVALUE)
811 {
812 # new value
813 if ($NewValue != DB_NOVALUE)
814 {
815 $NewValue = serialize((array) $NewValue);
816 }
817
818 $Value = $this->UpdateValue("UserPrivilegeRestrictions", $NewValue);
819
820 # value set
821 if (strlen($Value))
822 {
823 $Value = (array) unserialize($Value);
824 }
825
826 # no value set, set it to an empty array
827 else
828 {
829 $Value = $this->UserPrivilegeRestrictions(array());
830 }
831
832 return $Value;
833 }
834
835 function PointPrecision($NewValue = DB_NOVALUE)
836 {
837 if ($NewValue !== DB_NOVALUE && $this->Id() >= 0
838 && $this->Type() == MetadataSchema::MDFTYPE_POINT)
839 {
840 $OldValue = $this->UpdateValue("PointPrecision", DB_NOVALUE);
841
842 if ($NewValue != $OldValue)
843 {
844 $Decimals = $this->UpdateValue("PointDecimalDigits", DB_NOVALUE);
845 $TotalDigits = $NewValue + $Decimals;
846
847 $this->DB->Query("ALTER TABLE Resources MODIFY COLUMN "
848 ."`".$this->DBFields["DBFieldName"]."X` "
849 ."DECIMAL(".$TotalDigits.",".$Decimals.")");
850 $this->DB->Query("ALTER TABLE Resources MODIFY COLUMN "
851 ."`".$this->DBFields["DBFieldName"]."Y` "
852 ."DECIMAL(".$TotalDigits.",".$Decimals.")");
853 }
854 }
855
856 return $this->UpdateValue("PointPrecision", $NewValue);
857 }
858
859 function PointDecimalDigits($NewValue = DB_NOVALUE)
860 {
861 if ($NewValue !== DB_NOVALUE && $this->Id() >= 0
862 && $this->Type() == MetadataSchema::MDFTYPE_POINT)
863 {
864 $OldValue = $this->UpdateValue("PointDecimalDigits", DB_NOVALUE);
865
866 if ($NewValue != $OldValue)
867 {
868 $Precision = $this->UpdateValue("PointPrecision", DB_NOVALUE);
869
870 $TotalDigits = $NewValue + $Precision;
871
872 $this->DB->Query("ALTER TABLE Resources MODIFY COLUMN "
873 ."`".$this->DBFields["DBFieldName"]."X` "
874 ."DECIMAL(".$TotalDigits.",".$NewValue.")");
875 $this->DB->Query("ALTER TABLE Resources MODIFY COLUMN "
876 ."`".$this->DBFields["DBFieldName"]."Y` "
877 ."DECIMAL(".$TotalDigits.",".$NewValue.")");
878 }
879 }
880
881 return $this->UpdateValue("PointDecimalDigits", $NewValue);
882 }
883
884 function DefaultValue($NewValue = DB_NOVALUE)
885 {
886 if ($this->Type() == MetadataSchema::MDFTYPE_POINT)
887 {
888 # valid value given
889 if ($NewValue !== DB_NOVALUE &&
890 isset($NewValue["X"]) && isset($NewValue["Y"]))
891 {
892 $NewValue = $NewValue["X"].",".$NewValue["Y"];
893 }
894
895 # invalid value given
896 else
897 {
898 $NewValue = DB_NOVALUE;
899 }
900
901 $Value = $this->UpdateValue("DefaultValue", $NewValue);
902
903 if (is_array($Value))
904 {
905 $tmp = explode(",", $Value);
906
907 if (count($tmp)==2)
908 {
909 return array("X" => $tmp[0], "Y" => $tmp[1]);
910 }
911 }
912
913 return array("X" => NULL, "Y" => NULL);
914 }
915
916 else if ($this->Type() == MetadataSchema::MDFTYPE_OPTION)
917 {
918 # multiple default values to set
919 if (is_array($NewValue))
920 {
921 # empty array
922 if (count($NewValue) == 0)
923 {
924 $NewValue = NULL;
925 }
926
927 # multiple defaults are allowed
928 else if ($this->AllowMultiple())
929 {
930 $NewValue = serialize($NewValue);
931 }
932
933 # only one default is allowed so get the first one
934 else
935 {
936 $NewValue = array_shift($NewValue);
937 }
938 }
939
940 $Result = $this->UpdateValue("DefaultValue", $NewValue);
941
942 return empty($Result) || is_numeric($Result) ?
943 $Result : unserialize($Result);
944 }
945
946 return $this->UpdateValue("DefaultValue", $NewValue);
947 }
948
954 function UpdateMethod($NewValue = DB_NOVALUE)
955 {
956 return $this->UpdateValue("UpdateMethod", $NewValue);
957 }
958
959 # get possible values (only meaningful for Trees, Controlled Names, Options,
960 # Flags, and Users)
961 # (index for returned array is IDs for values)
962 function GetPossibleValues($MaxNumberOfValues = NULL, $Offset=0)
963 {
964 # retrieve values based on field type
965 switch ($this->Type())
966 {
967 case MetadataSchema::MDFTYPE_TREE:
968 $QueryString = "SELECT ClassificationId, ClassificationName"
969 ." FROM Classifications WHERE FieldId = ".$this->Id()
970 ." ORDER BY ClassificationName";
971 if ($MaxNumberOfValues)
972 {
973 $QueryString .= " LIMIT ".intval($MaxNumberOfValues)." OFFSET "
974 .intval($Offset);
975 }
976 $this->DB->Query($QueryString);
977 $PossibleValues = $this->DB->FetchColumn(
978 "ClassificationName", "ClassificationId");
979 break;
980
981 case MetadataSchema::MDFTYPE_CONTROLLEDNAME:
982 case MetadataSchema::MDFTYPE_OPTION:
983 $QueryString = "SELECT ControlledNameId, ControlledName"
984 ." FROM ControlledNames WHERE FieldId = ".$this->Id()
985 ." ORDER BY ControlledName";
986 if ($MaxNumberOfValues)
987 {
988 $QueryString .= " LIMIT ".intval($MaxNumberOfValues)." OFFSET "
989 .intval($Offset);
990 }
991 $this->DB->Query($QueryString);
992 $PossibleValues = $this->DB->FetchColumn(
993 "ControlledName", "ControlledNameId");
994 break;
995
996 case MetadataSchema::MDFTYPE_FLAG:
997 $PossibleValues[0] = $this->FlagOffLabel();
998 $PossibleValues[1] = $this->FlagOnLabel();
999 break;
1000
1001 case MetadataSchema::MDFTYPE_USER:
1002 $UserFactory = new CWUserFactory();
1003 $Restrictions = $this->UserPrivilegeRestrictions();
1004 $PossibleValues = array();
1005
1006 if (count($Restrictions))
1007 {
1008 $PossibleValues = call_user_func_array(
1009 array($UserFactory, "GetUsersWithPrivileges"),
1010 $Restrictions);
1011 }
1012
1013 else
1014 {
1015 $Users = $UserFactory->GetMatchingUsers(".*.");
1016
1017 foreach ($Users as $Id => $Data)
1018 {
1019 $PossibleValues[$Id] = $Data["UserName"];
1020 }
1021 }
1022
1023 break;
1024
1025 default:
1026 # for everything else return an empty array
1027 $PossibleValues = array();
1028 break;
1029 }
1030
1031 # return array of possible values to caller
1032 return $PossibleValues;
1033 }
1034
1035 # get count of possible values (only meaningful for Trees, Controlled Names,
1036 # Options, and Users)
1037 function GetCountOfPossibleValues()
1038 {
1039 # retrieve values based on field type
1040 switch ($this->Type())
1041 {
1042 case MetadataSchema::MDFTYPE_TREE:
1043 $Count = $this->DB->Query("SELECT count(*) AS ValueCount"
1044 ." FROM Classifications WHERE FieldId = ".$this->Id(),
1045 "ValueCount");
1046 break;
1047
1048 case MetadataSchema::MDFTYPE_CONTROLLEDNAME:
1049 case MetadataSchema::MDFTYPE_OPTION:
1050 $Count = $this->DB->Query("SELECT count(*) AS ValueCount"
1051 ." FROM ControlledNames WHERE FieldId = ".$this->Id(),
1052 "ValueCount");
1053 break;
1054
1055 case MetadataSchema::MDFTYPE_FLAG:
1056 $Count = 2;
1057 break;
1058
1059 case MetadataSchema::MDFTYPE_USER:
1060 $Count = count($this->GetPossibleValues());
1061 break;
1062
1063 default:
1064 # for everything else return an empty array
1065 $Count = 0;
1066 break;
1067 }
1068
1069 # return count of possible values to caller
1070 return $Count;
1071 }
1072
1073 # get ID for specified value (only meaningful for Trees / Controlled Names / Options)
1074 # (returns NULL if value not found)
1075 function GetIdForValue($Value)
1076 {
1077 # retrieve ID based on field type
1078 switch ($this->Type())
1079 {
1080 case MetadataSchema::MDFTYPE_TREE:
1081 $Id = $this->DB->Query("SELECT ClassificationId FROM Classifications"
1082 ." WHERE ClassificationName = '".addslashes($Value)."'"
1083 ." AND FieldId = ".$this->Id(),
1084 "ClassificationId");
1085 break;
1086
1087 case MetadataSchema::MDFTYPE_CONTROLLEDNAME:
1088 case MetadataSchema::MDFTYPE_OPTION:
1089 $Id = $this->DB->Query("SELECT ControlledNameId FROM ControlledNames"
1090 ." WHERE ControlledName = '".addslashes($Value)."'"
1091 ." AND FieldId = ".$this->Id(),
1092 "ControlledNameId");
1093 break;
1094
1095 default:
1096 # for everything else return NULL
1097 $Id = NULL;
1098 break;
1099 }
1100
1101 # return ID for value to caller
1102 return $Id;
1103 }
1104
1105 # get value for specified ID (only meaningful for Trees / Controlled Names / Options)
1106 # (returns NULL if ID not found)
1107 function GetValueForId($Id)
1108 {
1109 # retrieve ID based on field type
1110 switch ($this->Type())
1111 {
1112 case MetadataSchema::MDFTYPE_TREE:
1113 $Value = $this->DB->Query("SELECT ClassificationName FROM Classifications"
1114 ." WHERE ClassificationId = '".intval($Id)."'"
1115 ." AND FieldId = ".$this->Id(),
1116 "ClassificationName");
1117 break;
1118
1119 case MetadataSchema::MDFTYPE_CONTROLLEDNAME:
1120 case MetadataSchema::MDFTYPE_OPTION:
1121 $Value = $this->DB->Query("SELECT ControlledName FROM ControlledNames"
1122 ." WHERE ControlledNameId = '".intval($Id)."'"
1123 ." AND FieldId = ".$this->Id(),
1124 "ControlledName");
1125 break;
1126
1127 default:
1128 # for everything else return NULL
1129 $Value = NULL;
1130 break;
1131 }
1132
1133 # return ID for value to caller
1134 return $Value;
1135 }
1136
1147 function ValueUseCount($Value)
1148 {
1149 # retrieve ID if object passed in
1150 if (is_object($Value) && method_exists($Value, "Id"))
1151 {
1152 $Value = $Value->Id();
1153 }
1154
1155 # check value based on field type
1156 $DBFieldName = $this->DBFields["DBFieldName"];
1157 switch ($this->Type())
1158 {
1159 case MetadataSchema::MDFTYPE_TEXT:
1160 case MetadataSchema::MDFTYPE_PARAGRAPH:
1161 case MetadataSchema::MDFTYPE_NUMBER:
1162 case MetadataSchema::MDFTYPE_USER:
1163 case MetadataSchema::MDFTYPE_IMAGE:
1164 case MetadataSchema::MDFTYPE_TIMESTAMP:
1165 case MetadataSchema::MDFTYPE_URL:
1166 case MetadataSchema::MDFTYPE_FLAG:
1167 case MetadataSchema::MDFTYPE_FILE:
1168 $UseCount = $this->DB->Query("SELECT COUNT(*) AS UseCount"
1169 ." FROM Resources"
1170 ." WHERE `".$DBFieldName."` = '".addslashes($Value)."'"
1171 ." AND SchemaId = ".intval($this->DBFields["SchemaId"]),
1172 "UseCount");
1173 break;
1174
1175 case MetadataSchema::MDFTYPE_TREE:
1176 $UseCount = $this->DB->Query("SELECT COUNT(*) AS UseCount"
1177 ." FROM ResourceClassInts"
1178 ." WHERE ClassificationId = ".intval($Value),
1179 "UseCount");
1180 break;
1181
1182 case MetadataSchema::MDFTYPE_CONTROLLEDNAME:
1183 case MetadataSchema::MDFTYPE_OPTION:
1184 $UseCount = $this->DB->Query("SELECT COUNT(*) AS UseCount"
1185 ." FROM ResourceNameInts"
1186 ." WHERE ControlledNameId = ".intval($Value),
1187 "UseCount");
1188 break;
1189
1190 case MetadataSchema::MDFTYPE_POINT:
1191 $UseCount = $this->DB->Query("SELECT COUNT(*) AS UseCount"
1192 ." FROM Resources"
1193 ." WHERE `".$DBFieldName."X` = '".$Value["X"]."'"
1194 ." AND `".$DBFieldName."Y` = '".$Value["Y"]."'"
1195 ." AND SchemaId = ".intval($this->DBFields["SchemaId"]),
1196 "UseCount");
1197 break;
1198
1199 default:
1200 throw new Exception(__CLASS__."::".__METHOD__."() called for"
1201 ." unsupported field type (".$this->Type().").");
1202 break;
1203 }
1204
1205 # report use count to caller
1206 return $UseCount;
1207 }
1208
1209 # get/set whether field uses item-level qualifiers
1210 function HasItemLevelQualifiers($NewValue = DB_NOVALUE)
1211 {
1212 # if value provided different from present value
1213 if (($NewValue != DB_NOVALUE)
1214 && ($NewValue != $this->DBFields["HasItemLevelQualifiers"]))
1215 {
1216 # check if qualifier column currently exists
1217 $QualColName = $this->DBFieldName()."Qualifier";
1218 $QualColExists = $this->DB->FieldExists("Resources", $QualColName);
1219
1220 # if new value indicates qualifiers should now be used
1221 if ($NewValue == TRUE)
1222 {
1223 # if qualifier column does not exist in DB for this field
1224 if ($QualColExists == FALSE)
1225 {
1226 # add qualifier column in DB for this field
1227 $this->DB->Query("ALTER TABLE Resources ADD COLUMN `"
1228 .$QualColName."` INT");
1229 }
1230 }
1231 else
1232 {
1233 # if qualifier column exists in DB for this field
1234 if ($QualColExists == TRUE)
1235 {
1236 # remove qualifier column from DB for this field
1237 $this->DB->Query("ALTER TABLE Resources DROP COLUMN `"
1238 .$QualColName."`");
1239 }
1240 }
1241 }
1242
1243 return $this->UpdateValue("HasItemLevelQualifiers", $NewValue);
1244 }
1245
1246 # get list of qualifiers associated with field
1247 function AssociatedQualifierList()
1248 {
1249 # start with empty list
1250 $List = array();
1251
1252 # for each associated qualifier
1253 $this->DB->Query("SELECT QualifierId FROM FieldQualifierInts"
1254 ." WHERE MetadataFieldId = ".$this->DBFields["FieldId"]);
1255 while ($Record = $this->DB->FetchRow())
1256 {
1257 # load qualifier object
1258 $Qual = new Qualifier($Record["QualifierId"]);
1259
1260 # add qualifier ID and name to list
1261 $List[$Qual->Id()] = $Qual->Name();
1262 }
1263
1264 # return list to caller
1265 return $List;
1266 }
1267
1268 # get list of qualifiers not associated with field
1269 function UnassociatedQualifierList()
1270 {
1271 # grab list of associated qualifiers
1272 $AssociatedQualifiers = $this->AssociatedQualifierList();
1273
1274 # get list of all qualifiers
1275 $QFactory = new QualifierFactory();
1276 $AllQualifiers = $QFactory->GetItemNames();
1277
1278 # return list of unassociated qualifiers
1279 return array_diff($AllQualifiers, $AssociatedQualifiers);
1280 }
1281
1286 function AddQualifier($Qualifier)
1287 {
1288 # if qualifier object passed in
1289 if (is_object($Qualifier))
1290 {
1291 # grab qualifier ID from object
1292 $Qualifier = $Qualifier->Id();
1293 }
1294 # else if string passed in does not look like ID
1295 elseif (!preg_match('/^[0-9]+$/', $Qualifier))
1296 {
1297 # assume string passed in is name and use it to retrieve ID
1298 $QFact = new QualifierFactory();
1299 $Qualifier = $QFact->GetItemIdByName($Qualifier);
1300 }
1301
1302 # if not already associated
1303 $RecordCount = $this->DB->Query(
1304 "SELECT COUNT(*) AS RecordCount FROM FieldQualifierInts"
1305 ." WHERE QualifierId = ".$Qualifier
1306 ." AND MetadataFieldId = ".$this->Id(), "RecordCount");
1307 if ($RecordCount < 1)
1308 {
1309 # associate field with qualifier
1310 $this->DB->Query("INSERT INTO FieldQualifierInts SET"
1311 ." QualifierId = ".$Qualifier.","
1312 ." MetadataFieldId = ".$this->Id());
1313 }
1314 }
1320 function AssociateWithQualifier($Qualifier)
1321 {
1322 $this->AddQualifier($Qualifier);
1323 }
1324
1325 # delete qualifier association
1326 function UnassociateWithQualifier($QualifierIdOrObject)
1327 {
1328 # if qualifier object passed in
1329 if (is_object($QualifierIdOrObject))
1330 {
1331 # grab qualifier ID from object
1332 $QualifierIdOrObject = $QualifierIdOrObject->Id();
1333 }
1334
1335 # delete intersection record from database
1336 $this->DB->Query("DELETE FROM FieldQualifierInts WHERE QualifierId = "
1337 .$QualifierIdOrObject." AND MetadataFieldId = ".
1338 $this->Id());
1339 }
1340
1341 # retrieve item factory object for this field
1342 function GetFactory()
1343 {
1344 switch ($this->Type())
1345 {
1346 case MetadataSchema::MDFTYPE_TREE:
1347 $Factory = new ClassificationFactory($this->Id());
1348 break;
1349
1350 case MetadataSchema::MDFTYPE_CONTROLLEDNAME:
1351 case MetadataSchema::MDFTYPE_OPTION:
1352 $Factory = new ControlledNameFactory($this->Id());
1353 break;
1354
1355 default:
1356 $Factory = NULL;
1357 break;
1358 }
1359
1360 return $Factory;
1361 }
1362
1367 function Viewable()
1368 {
1369 # the field should not be viewed if it is disabled
1370 if (!$this->Enabled())
1371 {
1372 return FALSE;
1373 }
1374
1375 $User = $GLOBALS["G_User"];
1376
1377 # the user can view the field if they can edit it
1378 if ($this->EditingPrivileges()->MeetsRequirements($User))
1379 {
1380 return TRUE;
1381 }
1382
1383 # if the user can view the field
1384 if ($this->ViewingPrivileges()->MeetsRequirements($User))
1385 {
1386 return TRUE;
1387 }
1388
1389 # the user can't view the field
1390 return FALSE;
1391 }
1392
1393 # ---- PRIVATE INTERFACE -------------------------------------------------
1394
1395 private $DB;
1396 private $Id;
1397 private $DBFields;
1398 private $ErrorStatus;
1399 private $AuthoringPrivileges;
1400 private $EditingPrivileges;
1401 private $ViewingPrivileges;
1402 private $PreviewingPrivileges;
1403
1408 public static $FieldTypeHumanEnums = array(
1409 MetadataSchema::MDFTYPE_TEXT => "Text",
1410 MetadataSchema::MDFTYPE_PARAGRAPH => "Paragraph",
1411 MetadataSchema::MDFTYPE_NUMBER => "Number",
1412 MetadataSchema::MDFTYPE_DATE => "Date",
1413 MetadataSchema::MDFTYPE_TIMESTAMP => "Timestamp",
1414 MetadataSchema::MDFTYPE_FLAG => "Flag",
1415 MetadataSchema::MDFTYPE_TREE => "Tree",
1416 MetadataSchema::MDFTYPE_CONTROLLEDNAME => "Controlled Name",
1417 MetadataSchema::MDFTYPE_OPTION => "Option",
1418 MetadataSchema::MDFTYPE_USER => "User",
1419 MetadataSchema::MDFTYPE_IMAGE => "Image",
1420 MetadataSchema::MDFTYPE_FILE => "File",
1421 MetadataSchema::MDFTYPE_URL => "URL",
1422 MetadataSchema::MDFTYPE_POINT => "Point",
1423 MetadataSchema::MDFTYPE_REFERENCE => "Reference");
1424
1425 # field type DB/PHP enum translations
1426 public static $FieldTypeDBEnums = array(
1427 MetadataSchema::MDFTYPE_TEXT => "Text",
1428 MetadataSchema::MDFTYPE_PARAGRAPH => "Paragraph",
1429 MetadataSchema::MDFTYPE_NUMBER => "Number",
1430 MetadataSchema::MDFTYPE_DATE => "Date",
1431 MetadataSchema::MDFTYPE_TIMESTAMP => "TimeStamp",
1432 MetadataSchema::MDFTYPE_FLAG => "Flag",
1433 MetadataSchema::MDFTYPE_TREE => "Tree",
1434 MetadataSchema::MDFTYPE_CONTROLLEDNAME => "ControlledName",
1435 MetadataSchema::MDFTYPE_OPTION => "Option",
1436 MetadataSchema::MDFTYPE_USER => "User",
1437 MetadataSchema::MDFTYPE_IMAGE => "Still Image",
1438 MetadataSchema::MDFTYPE_FILE => "File",
1439 MetadataSchema::MDFTYPE_URL => "Url",
1440 MetadataSchema::MDFTYPE_POINT => "Point",
1441 MetadataSchema::MDFTYPE_REFERENCE => "Reference"
1442 );
1443 public static $FieldTypeDBAllowedEnums = array(
1444 MetadataSchema::MDFTYPE_TEXT => "Text",
1445 MetadataSchema::MDFTYPE_PARAGRAPH => "Paragraph",
1446 MetadataSchema::MDFTYPE_NUMBER => "Number",
1447 MetadataSchema::MDFTYPE_DATE => "Date",
1448 MetadataSchema::MDFTYPE_TIMESTAMP => "TimeStamp",
1449 MetadataSchema::MDFTYPE_FLAG => "Flag",
1450 MetadataSchema::MDFTYPE_TREE => "Tree",
1451 MetadataSchema::MDFTYPE_CONTROLLEDNAME => "ControlledName",
1452 MetadataSchema::MDFTYPE_OPTION => "Option",
1453 MetadataSchema::MDFTYPE_USER => "User",
1454 MetadataSchema::MDFTYPE_IMAGE => "Still Image",
1455 MetadataSchema::MDFTYPE_FILE => "File",
1456 MetadataSchema::MDFTYPE_URL => "Url",
1457 MetadataSchema::MDFTYPE_POINT => "Point",
1458 MetadataSchema::MDFTYPE_REFERENCE => "Reference"
1459 );
1460 public static $FieldTypePHPEnums = array(
1461 "Text" => MetadataSchema::MDFTYPE_TEXT,
1462 "Paragraph" => MetadataSchema::MDFTYPE_PARAGRAPH,
1463 "Number" => MetadataSchema::MDFTYPE_NUMBER,
1464 "Date" => MetadataSchema::MDFTYPE_DATE,
1465 "TimeStamp" => MetadataSchema::MDFTYPE_TIMESTAMP,
1466 "Flag" => MetadataSchema::MDFTYPE_FLAG,
1467 "Tree" => MetadataSchema::MDFTYPE_TREE,
1468 "ControlledName" => MetadataSchema::MDFTYPE_CONTROLLEDNAME,
1469 "Option" => MetadataSchema::MDFTYPE_OPTION,
1470 "User" => MetadataSchema::MDFTYPE_USER,
1471 "Still Image" => MetadataSchema::MDFTYPE_IMAGE,
1472 "File" => MetadataSchema::MDFTYPE_FILE,
1473 "Url" => MetadataSchema::MDFTYPE_URL,
1474 "Point" => MetadataSchema::MDFTYPE_POINT,
1475 "Reference" => MetadataSchema::MDFTYPE_REFERENCE
1476 );
1477
1478 public static $UpdateTypes = array(
1479 self::UPDATEMETHOD_NOAUTOUPDATE => "Do not update automatically",
1480 self::UPDATEMETHOD_ONRECORDCREATE => "Update on record creation",
1481 self::UPDATEMETHOD_BUTTON => "Provide an update button",
1482 self::UPDATEMETHOD_ONRECORDEDIT => "Update when record is edited",
1483 self::UPDATEMETHOD_ONRECORDCHANGE => "Update when record is changed"
1484 );
1485
1499 static function Create($SchemaId, $FieldType, $FieldName,
1500 $Optional = NULL, $DefaultValue = NULL)
1501 {
1502 # error out if field type is bad
1503 if (empty(self::$FieldTypeDBEnums[$FieldType]))
1504 {
1505 throw new InvalidArgumentException("Bad field type (".$FieldType.").");
1506 }
1507
1508 # error out if field name is duplicate
1509 $DB = new Database();
1510 $FieldName = trim($FieldName);
1511 $DuplicateCount = $DB->Query(
1512 "SELECT COUNT(*) AS RecordCount FROM MetadataFields"
1513 ." WHERE FieldName = '".addslashes($FieldName)."'"
1514 ." AND SchemaId = ".intval($SchemaId),
1515 "RecordCount");
1516 if ($DuplicateCount > 0)
1517 {
1518 throw new InvalidArgumentException("Duplicate field name (".$FieldName.").");
1519 }
1520
1521 # grab current user ID
1522 $UserId = $GLOBALS["G_User"]->Get("UserId");
1523
1524 # normalize schema ID
1525 $Schema = new MetadataSchema($SchemaId);
1526 $SchemaId = $Schema->Id();
1527
1528 # use schema privileges as starting privilege values
1529 $AuthorPrivs = $Schema->AuthoringPrivileges();
1530 $EditPrivs = $Schema->EditingPrivileges();
1531 $ViewPrivs = $Schema->ViewingPrivileges();
1532 $PreviewPrivs = $Schema->ViewingPrivileges();
1533
1534 # lock DB tables and get next temporary field ID
1535 $DB->Query("LOCK TABLES MetadataFields WRITE");
1536 $FieldId = $Schema->GetNextTempItemId();
1537
1538 # add field to MDF table in database
1539 $DB->Query("INSERT INTO MetadataFields"
1540 ." (FieldId, SchemaId, FieldName, FieldType, LastModifiedById,"
1541 ." Optional, AuthoringPrivileges, EditingPrivileges,"
1542 ." ViewingPrivileges, PreviewingPrivileges)"
1543 ." VALUES ("
1544 .intval($FieldId).", "
1545 .intval($SchemaId).","
1546 ." '".addslashes($FieldName)."',"
1547 ." '".self::$FieldTypeDBEnums[$FieldType]."', "
1548 .intval($UserId).", "
1549 .($Optional ? "1" : "0").","
1550 ."'".$DB->EscapeString($AuthorPrivs->Data())."',"
1551 ."'".$DB->EscapeString($EditPrivs->Data())."',"
1552 ."'".$DB->EscapeString($ViewPrivs->Data())."',"
1553 ."'".$DB->EscapeString($PreviewPrivs->Data())."')");
1554
1555 # release DB tables
1556 $DB->Query("UNLOCK TABLES");
1557
1558 # nuke potentially stale cache information
1559 self::$FieldCache = NULL;
1560
1561 # load field object
1562 $Field = new MetadataField($FieldId);
1563
1564 # set field defaults
1565 $Field->SetDefaults();
1566
1567 # set the default value if specified
1568 if ($DefaultValue !== NULL)
1569 {
1570 $Field->DefaultValue($DefaultValue);
1571 }
1572
1573 # return newly-constructed field to caller
1574 return $Field;
1575 }
1576
1583 function __construct($FieldId)
1584 {
1585 # assume everything will be okay
1586 $this->ErrorStatus = MetadataSchema::MDFSTAT_OK;
1587
1588 # check if we have cached field info
1589 $this->DB = new Database();
1590 if (self::$FieldCache === NULL)
1591 {
1592 # if not, retrieve field info from database
1593 $this->DB->Query("SELECT * FROM MetadataFields");
1594 while ($Row = $this->DB->FetchRow())
1595 {
1596 self::$FieldCache[$Row["FieldId"]] = $Row;
1597 }
1598 }
1599
1600 # error if requested field did not exist
1601 if (!array_key_exists($FieldId, self::$FieldCache) )
1602 {
1603 throw new InvalidArgumentException("Invalid metadata field ID ("
1604 .$FieldId.")");
1605 }
1606 $Row = self::$FieldCache[$FieldId];
1607 $this->DBFields = $Row;
1608 $this->Id = $FieldId;
1609
1610 # if privileges have not yet been initialized
1611 if (!strlen($this->DBFields["AuthoringPrivileges"]))
1612 {
1613 # set default values for privileges from metadata schema
1614 $Schema = new MetadataSchema($Row["SchemaId"]);
1615 $this->AuthoringPrivileges($Schema->AuthoringPrivileges());
1616 $this->EditingPrivileges($Schema->EditingPrivileges());
1617 $this->ViewingPrivileges($Schema->ViewingPrivileges());
1618 $this->PreviewingPrivileges($Schema->ViewingPrivileges());
1619 }
1620 else
1621 {
1622 # set privileges from stored values
1623 $this->AuthoringPrivileges = new PrivilegeSet(
1624 $Row["AuthoringPrivileges"]);
1625 $this->EditingPrivileges = new PrivilegeSet(
1626 $Row["EditingPrivileges"]);
1627 $this->ViewingPrivileges = new PrivilegeSet(
1628 $Row["ViewingPrivileges"]);
1629 $this->PreviewingPrivileges = new PrivilegeSet(
1630 $Row["PreviewingPrivileges"]);
1631 }
1632
1633 # set database column name
1634 $this->DBFields["DBFieldName"] =
1635 $this->NormalizeFieldNameForDB($this->DBFields["FieldName"]);
1636 }
1637
1642 public static $FixedDefaults = array(
1643 "Label" => NULL,
1644 "Description" => NULL,
1645 "Instructions" => NULL,
1646 "Enabled" => TRUE,
1647 "Optional" => TRUE,
1648 "Editable" => TRUE,
1649 "CopyOnResourceDuplication" => TRUE,
1650 "AllowMultiple" => FALSE,
1651 "IncludeInKeywordSearch" => FALSE,
1652 "IncludeInAdvancedSearch" => FALSE,
1653 "IncludeInFacetedSearch" => FALSE,
1654 "IncludeInSortOptions" => TRUE,
1655 "IncludeInRecommender" => FALSE,
1656 "ParagraphRows" => 4,
1657 "ParagraphCols" => 50,
1658 "MinValue" => 1,
1659 "FlagOnLabel" => "On",
1660 "FlagOffLabel" => "Off",
1661 "DateFormat" => NULL,
1662 "RecommenderWeight" => 1,
1663 "MaxHeight" => 500,
1664 "MaxWidth" => 500,
1665 "MaxPreviewHeight" => 100,
1666 "MaxPreviewWidth" => 100,
1667 "MaxThumbnailHeight" => 50,
1668 "MaxThumbnailWidth" => 50,
1669 "DefaultAltText" => NULL,
1670 "UsesQualifiers" => FALSE,
1671 "HasItemLevelQualifiers" => FALSE,
1672 "ShowQualifiers" => FALSE,
1673 "DefaultQualifier" => NULL,
1674 "AllowHTML" => FALSE,
1675 "UseWysiwygEditor" => FALSE,
1676 "UseForOaiSets" => FALSE,
1677 "DisplayAsListForAdvancedSearch" => FALSE,
1678 "OptionListThreshold" => 25,
1679 "AjaxThreshold" => 50,
1680 "NumAjaxResults" => 50,
1681 "PointPrecision" => 8,
1682 "PointDecimalDigits" => 5,
1683 "UserPrivilegeRestrictions" => array(),
1684 "UpdateMethod" => "NoAutoUpdate",
1685 # 9999 is the default max value because default number field length is 4
1686 "MaxValue" => 9999);
1687
1692 public static $TypeBasedDefaults = array(
1693 MetadataSchema::MDFTYPE_TEXT => array(
1694 "DefaultValue" => NULL,
1695 "SearchWeight" => 1,
1696 "TextFieldSize" => 50,
1697 "MaxLength" => 100),
1698 MetadataSchema::MDFTYPE_PARAGRAPH => array(
1699 "DefaultValue" => NULL,
1700 "SearchWeight" => 1,
1701 "TextFieldSize" => 50,
1702 "MaxLength" => 100),
1703 MetadataSchema::MDFTYPE_NUMBER => array(
1704 "DefaultValue" => NULL,
1705 "SearchWeight" => 1,
1706 "TextFieldSize" => 4,
1707 "MaxLength" => 100),
1708 MetadataSchema::MDFTYPE_DATE => array(
1709 "DefaultValue" => NULL,
1710 "SearchWeight" => 1,
1711 "TextFieldSize" => 10,
1712 "MaxLength" => 100),
1713 MetadataSchema::MDFTYPE_TIMESTAMP => array(
1714 "DefaultValue" => NULL,
1715 "SearchWeight" => 1,
1716 "TextFieldSize" => 50,
1717 "MaxLength" => 100),
1718 MetadataSchema::MDFTYPE_FLAG => array(
1719 "DefaultValue" => NULL,
1720 "SearchWeight" => 1,
1721 "TextFieldSize" => 50,
1722 "MaxLength" => 100),
1723 MetadataSchema::MDFTYPE_TREE => array(
1724 "DefaultValue" => NULL,
1725 "SearchWeight" => 1,
1726 "TextFieldSize" => 50,
1727 "MaxLength" => 100),
1728 MetadataSchema::MDFTYPE_CONTROLLEDNAME => array(
1729 "DefaultValue" => NULL,
1730 "SearchWeight" => 3,
1731 "TextFieldSize" => 50,
1732 "MaxLength" => 100),
1733 MetadataSchema::MDFTYPE_OPTION => array(
1734 "DefaultValue" => NULL,
1735 "SearchWeight" => 3,
1736 "TextFieldSize" => 50,
1737 "MaxLength" => 100),
1738 MetadataSchema::MDFTYPE_USER => array(
1739 "DefaultValue" => NULL,
1740 "SearchWeight" => 1,
1741 "TextFieldSize" => 50,
1742 "MaxLength" => 100),
1743 MetadataSchema::MDFTYPE_IMAGE => array(
1744 "DefaultValue" => NULL,
1745 "CopyOnResourceDuplication" => FALSE,
1746 "SearchWeight" => 1,
1747 "TextFieldSize" => 50,
1748 "MaxLength" => 100),
1749 MetadataSchema::MDFTYPE_FILE => array(
1750 "DefaultValue" => NULL,
1751 "CopyOnResourceDuplication" => FALSE,
1752 "SearchWeight" => 1,
1753 "TextFieldSize" => 50,
1754 "MaxLength" => 100),
1755 MetadataSchema::MDFTYPE_URL => array(
1756 "DefaultValue" => NULL,
1757 "SearchWeight" => 1,
1758 "TextFieldSize" => 50,
1759 "MaxLength" => 255),
1760 MetadataSchema::MDFTYPE_POINT => array(
1761 "DefaultValue" => array("X" => NULL, "Y" => NULL),
1762 "SearchWeight" => 1,
1763 "TextFieldSize" => 10,
1764 "MaxLength" => 100),
1765 MetadataSchema::MDFTYPE_REFERENCE => array(
1766 "DefaultValue" => NULL,
1767 "SearchWeight" => 1,
1768 "TextFieldSize" => 50,
1769 "MaxLength" => 100));
1770
1775 function SetDefaults()
1776 {
1777 # set defaults that are the same for every field
1778 foreach (self::$FixedDefaults as $Key => $Value)
1779 {
1780 $this->$Key($Value);
1781 }
1782
1783 # set defaults that depend on the type of the field
1784 foreach (self::$TypeBasedDefaults[$this->Type()] as $Key => $Value)
1785 {
1786 $this->$Key($Value);
1787 }
1788
1789 # tweak the update method if dealing with the date of record creation
1790 if ($this->Name() == "Date Of Record Creation")
1791 {
1792 $this->UpdateMethod("OnRecordCreate");
1793 }
1794 }
1795
1796 # remove field from database (only for use by MetadataSchema object)
1797 function Drop()
1798 {
1799 # clear other database entries as appropriate for field type
1800 $DB = $this->DB;
1801 $DBFieldName = $this->DBFields["DBFieldName"];
1802 $Schema = new MetadataSchema($this->SchemaId());
1803 switch (self::$FieldTypePHPEnums[$this->DBFields["FieldType"]])
1804 {
1805 case MetadataSchema::MDFTYPE_TEXT:
1806 case MetadataSchema::MDFTYPE_PARAGRAPH:
1807 case MetadataSchema::MDFTYPE_NUMBER:
1808 case MetadataSchema::MDFTYPE_USER:
1809 case MetadataSchema::MDFTYPE_IMAGE:
1810 case MetadataSchema::MDFTYPE_TIMESTAMP:
1811 case MetadataSchema::MDFTYPE_URL:
1812 case MetadataSchema::MDFTYPE_FLAG:
1813 # remove field from resources table
1814 if ($DB->FieldExists("Resources", $DBFieldName))
1815 {
1816 $DB->Query("ALTER TABLE Resources DROP COLUMN `".$DBFieldName."`");
1817 }
1818 break;
1819
1820 case MetadataSchema::MDFTYPE_POINT:
1821 if ($DB->FieldExists("Resources", $DBFieldName."X"))
1822 {
1823 $DB->Query("ALTER TABLE Resources DROP COLUMN `".$DBFieldName."X`");
1824 $DB->Query("ALTER TABLE Resources DROP COLUMN `".$DBFieldName."Y`");
1825 }
1826 break;
1827
1828 case MetadataSchema::MDFTYPE_DATE:
1829 # remove fields from resources table
1830 if ($DB->FieldExists("Resources", $DBFieldName."Begin"))
1831 {
1832 $DB->Query("ALTER TABLE Resources "
1833 ."DROP COLUMN `".$DBFieldName."Begin`");
1834 $DB->Query("ALTER TABLE Resources "
1835 ."DROP COLUMN `".$DBFieldName."End`");
1836 $DB->Query("ALTER TABLE Resources "
1837 ."DROP COLUMN `".$DBFieldName."Precision`");
1838 }
1839 break;
1840
1841 case MetadataSchema::MDFTYPE_TREE:
1842 $DB->Query("SELECT ClassificationId FROM Classifications "
1843 ."WHERE FieldId = ".$this->Id());
1844 $TempDB = new Database();
1845 while ($ClassificationId = $DB->FetchField("ClassificationId"))
1846 {
1847 # remove any resource / name intersections
1848 $TempDB->Query("DELETE FROM ResourceClassInts WHERE "
1849 ."ClassificationId = ".$ClassificationId);
1850
1851 # remove controlled name
1852 $TempDB->Query("DELETE FROM Classifications WHERE "
1853 ."ClassificationId = ".$ClassificationId);
1854 }
1855 break;
1856
1857 case MetadataSchema::MDFTYPE_CONTROLLEDNAME:
1858 case MetadataSchema::MDFTYPE_OPTION:
1859 $DB->Query("SELECT ControlledNameId FROM ControlledNames "
1860 ."WHERE FieldId = ".$this->Id());
1861 $TempDB = new Database();
1862 while ($ControlledNameId = $DB->FetchField("ControlledNameId"))
1863 {
1864 # remove any resource / name intersections
1865 $TempDB->Query("DELETE FROM ResourceNameInts WHERE "
1866 ."ControlledNameId = ".$ControlledNameId);
1867
1868 # remove any variant names
1869 $TempDB->Query("DELETE FROM VariantNames WHERE "
1870 ."ControlledNameId = ".$ControlledNameId);
1871
1872 # remove controlled name
1873 $TempDB->Query("DELETE FROM ControlledNames WHERE "
1874 ."ControlledNameId = ".$ControlledNameId);
1875 }
1876 break;
1877
1878 case MetadataSchema::MDFTYPE_FILE:
1879 # for each file associated with this field
1880 $DB->Query("SELECT FileId FROM Files WHERE FieldId = '".$this->Id()."'");
1881 while ($FileId = $DB->FetchRow())
1882 {
1883 # delete file
1884 $File = new File(intval($FileId));
1885 $File->Delete();
1886 }
1887 break;
1888
1889 case MetadataSchema::MDFTYPE_REFERENCE:
1890 # remove any resource references for the field
1891 $DB->Query("
1892 DELETE FROM ReferenceInts
1893 WHERE FieldId = '".addslashes($this->Id())."'");
1894 break;
1895 }
1896
1897 # remove field from database
1898 $DB->Query("DELETE FROM MetadataFields "
1899 ."WHERE FieldId = '".$this->DBFields["FieldId"]."'");
1900
1901 # remove any qualifier associations
1902 $DB->Query("DELETE FROM FieldQualifierInts WHERE MetadataFieldId = '"
1903 .$this->DBFields["FieldId"]."'");
1904
1905 # get the order objects the field is part of
1906 foreach (MetadataFieldOrder::GetOrdersForSchema($Schema) as $Order)
1907 {
1908 # remove it if it's a direct descendant
1909 $Order->RemoveItem($this->Id(), "MetadataField");
1910
1911 # also make sure to remove it if it's part of a group
1912 foreach ($Order->GetItemIds() as $Item)
1913 {
1914 if ($Item["Type"] == "MetadataFieldGroup")
1915 {
1916 $Group = new MetadataFieldGroup($Item["ID"]);
1917 $Group->RemoveItem($this->Id(), "MetadataField");
1918 }
1919 }
1920 }
1921
1922 # nuke stale field cache
1923 self::$FieldCache = NULL;
1924 }
1925
1926 # modify any database fields
1927 private function ModifyField($NewName = NULL, $NewType = NULL)
1928 {
1929 # grab old DB field name
1930 $OldDBFieldName = $this->DBFields["DBFieldName"];
1931 $OldFieldType = NULL;
1932
1933 # if new field name supplied
1934 if ($NewName != NULL)
1935 {
1936 # cache the old name for options and controllednames below
1937 $OldName = $this->DBFields["FieldName"];
1938
1939 # store new name
1940 $this->UpdateValue("FieldName", $NewName);
1941
1942 # determine new DB field name
1943 $NewDBFieldName = $this->NormalizeFieldNameForDB($NewName);
1944
1945 # store new database field name
1946 $this->DBFields["DBFieldName"] = $NewDBFieldName;
1947 }
1948 else
1949 {
1950 # set new field name equal to old field name
1951 $NewDBFieldName = $OldDBFieldName;
1952 }
1953
1954 # if new type supplied
1955 if ($NewType != NULL)
1956 {
1957 # grab old field type
1958 $OldFieldType = self::$FieldTypePHPEnums[$this->DBFields["FieldType"]];
1959
1960 # store new field type
1961 $this->UpdateValue("FieldType", self::$FieldTypeDBEnums[$NewType]);
1962 }
1963
1964 # if this is not a temporary field
1965 if ($this->Id() >= 0)
1966 {
1967 # modify field in DB as appropriate for field type
1968 $DB = $this->DB;
1969 $FieldType = self::$FieldTypePHPEnums[$this->DBFields["FieldType"]];
1970 switch ($FieldType)
1971 {
1972 case MetadataSchema::MDFTYPE_TEXT:
1973 case MetadataSchema::MDFTYPE_PARAGRAPH:
1974 case MetadataSchema::MDFTYPE_URL:
1975 # alter field declaration in Resources table
1976 $DB->Query("ALTER TABLE Resources CHANGE COLUMN `"
1977 .$OldDBFieldName."` `"
1978 .$NewDBFieldName."` TEXT "
1979 .($this->DBFields["Optional"] ? "" : "NOT NULL"));
1980 break;
1981
1982 case MetadataSchema::MDFTYPE_NUMBER:
1983 case MetadataSchema::MDFTYPE_USER:
1984 # alter field declaration in Resources table
1985 $DB->Query("ALTER TABLE Resources CHANGE COLUMN `"
1986 .$OldDBFieldName."` `"
1987 .$NewDBFieldName."` INT "
1988 .($this->DBFields["Optional"] ? "" : "NOT NULL"));
1989 break;
1990
1991 case MetadataSchema::MDFTYPE_POINT:
1992 $Precision = $this->UpdateValue("PointPrecision",
1993 DB_NOVALUE);
1994 $Digits = $this->UpdateValue("PointDecimalDigits",
1995 DB_NOVALUE);
1996 $DB->Query("ALTER TABLE Resources CHANGE COLUMN "
1997 ."`".$OldDBFieldName."X` "
1998 ."`".$NewDBFieldName."X`".
1999 " DECIMAL(".$Precision.",".$Digits.")");
2000 $DB->Query("ALTER TABLE Resources CHANGE COLUMN "
2001 ."`".$OldDBFieldName."Y` "
2002 ."`".$NewDBFieldName."Y`".
2003 " DECIMAL(".$Precision.",".$Digits.")");
2004 break;
2005
2006 case MetadataSchema::MDFTYPE_FILE:
2007 # if DB field name has changed
2008 if ($NewDBFieldName != $OldDBFieldName)
2009 {
2010 # alter field declaration in Resources table
2011 $DB->Query("ALTER TABLE Resources CHANGE COLUMN `"
2012 .$OldDBFieldName."` `"
2013 .$NewDBFieldName."` TEXT");
2014 }
2015 break;
2016
2017 case MetadataSchema::MDFTYPE_FLAG:
2018 # alter field declaration in Resources table
2019 $DB->Query("ALTER TABLE Resources CHANGE COLUMN `"
2020 .$OldDBFieldName."` `"
2021 .$NewDBFieldName."` INT"
2022 ." DEFAULT ".intval($this->DefaultValue()));
2023
2024 # set any unset values to default
2025 $DB->Query("UPDATE Resources SET `".$NewDBFieldName
2026 ."` = ".intval($this->DefaultValue())
2027 ." WHERE `".$NewDBFieldName."` IS NULL");
2028 break;
2029
2030 case MetadataSchema::MDFTYPE_DATE:
2031 # if new type supplied and new type is different from old
2032 if (($NewType != NULL) && ($NewType != $OldFieldType))
2033 {
2034 # if old type was time stamp
2035 if ($OldFieldType == MetadataSchema::MDFTYPE_TIMESTAMP)
2036 {
2037 # change time stamp field in resources table to begin date
2038 $DB->Query("ALTER TABLE Resources CHANGE COLUMN `"
2039 .$OldDBFieldName."` `"
2040 .$NewDBFieldName."Begin` DATE "
2041 .($this->DBFields["Optional"] ? "" : "NOT NULL"));
2042
2043 # add end date and precision fields
2044 $DB->Query("ALTER TABLE Resources "
2045 ."ADD COLUMN `".$NewDBFieldName."End` DATE");
2046 $DB->Query("ALTER TABLE Resources "
2047 ."ADD COLUMN `".$NewDBFieldName."Precision`"
2048 ." INT ".($Optional ? "" : "NOT NULL"));
2049
2050 # set precision to reflect time stamp content
2051 $DB->Query("UPDATE Resources "
2052 ."SET `".$NewDBFieldName."Precision` = "
2053 .(DATEPRE_BEGINYEAR|DATEPRE_BEGINMONTH
2054 |DATEPRE_BEGINDAY));
2055 }
2056 else
2057 {
2058 exit("<br>ERROR: Attempt to convert metadata field "
2059 ."to date from type other than timestamp<br>\n");
2060 }
2061 }
2062 else
2063 {
2064 # change name of fields
2065 $DB->Query("ALTER TABLE Resources CHANGE COLUMN `"
2066 .$OldDBFieldName."Begin` `"
2067 .$NewDBFieldName."Begin` DATE "
2068 .($this->DBFields["Optional"] ? "" : "NOT NULL"));
2069 $DB->Query("ALTER TABLE Resources CHANGE COLUMN `"
2070 .$OldDBFieldName."End` `"
2071 .$NewDBFieldName."End` DATE "
2072 .($this->DBFields["Optional"] ? "" : "NOT NULL"));
2073 $DB->Query("ALTER TABLE Resources CHANGE COLUMN `"
2074 .$OldDBFieldName."Precision` `"
2075 .$NewDBFieldName."Precision` INT "
2076 .($this->DBFields["Optional"] ? "" : "NOT NULL"));
2077 }
2078 break;
2079
2080 case MetadataSchema::MDFTYPE_TIMESTAMP:
2081 # if new type supplied and new type is different from old
2082 if (($NewType != NULL) && ($NewType != $OldFieldType))
2083 {
2084 # if old type was date
2085 if ($OldFieldType == MetadataSchema::MDFTYPE_DATE)
2086 {
2087 # change begin date field in resource table to time stamp
2088 $DB->Query("ALTER TABLE Resources CHANGE COLUMN `"
2089 .$OldDBFieldName."Begin` `"
2090 .$NewDBFieldName."` DATETIME "
2091 .($this->DBFields["Optional"] ? "" : "NOT NULL"));
2092
2093 # drop end date and precision fields
2094 $DB->Query("ALTER TABLE Resources DROP COLUMN `"
2095 .$OldDBFieldName."End`");
2096 $DB->Query("ALTER TABLE Resources DROP COLUMN `"
2097 .$OldDBFieldName."Precision`");
2098 }
2099 else
2100 {
2101 exit("<br>ERROR: Attempt to convert metadata field to "
2102 ."time stamp from type other than date<br>\n");
2103 }
2104 }
2105 else
2106 {
2107 # change name of field
2108 $DB->Query("ALTER TABLE Resources CHANGE COLUMN `"
2109 .$OldDBFieldName."` `"
2110 .$NewDBFieldName."` DATETIME "
2111 .($this->DBFields["Optional"] ? "" : "NOT NULL"));
2112 }
2113 break;
2114
2115 case MetadataSchema::MDFTYPE_TREE:
2116 case MetadataSchema::MDFTYPE_CONTROLLEDNAME:
2117 case MetadataSchema::MDFTYPE_OPTION:
2118 case MetadataSchema::MDFTYPE_REFERENCE:
2119 case MetadataSchema::MDFTYPE_IMAGE:
2120 break;
2121 }
2122
2123 # if qualifier DB field exists
2124 if ($DB->FieldExists("Resources", $OldDBFieldName."Qualifier"))
2125 {
2126 # rename qualifier DB field
2127 $DB->Query("ALTER TABLE Resources CHANGE COLUMN `"
2128 .$OldDBFieldName."Qualifier` `"
2129 .$NewDBFieldName."Qualifier` INT ");
2130 }
2131 }
2132 }
2133
2134 # convenience functions to supply parameters to Database->UpdateValue()
2135 private function UpdateValue($FieldName, $NewValue)
2136 {
2137 # nuke stale field cache
2138 self::$FieldCache = NULL;
2139
2140 return $this->DB->UpdateValue("MetadataFields", $FieldName, $NewValue,
2141 "FieldId = ".intval($this->DBFields["FieldId"]),
2142 $this->DBFields);
2143 }
2144 private function UpdateIntValue($FieldName, $NewValue)
2145 {
2146 # nuke stale field cache
2147 self::$FieldCache = NULL;
2148
2149 return $this->DB->UpdateIntValue("MetadataFields", $FieldName, $NewValue,
2150 "FieldId = ".intval($this->DBFields["FieldId"]),
2151 $this->DBFields);
2152 }
2153 private function UpdateFloatValue($FieldName, $NewValue)
2154 {
2155 # nuke stale field cache
2156 self::$FieldCache = NULL;
2157
2158 return $this->DB->UpdateFloatValue("MetadataFields", $FieldName, $NewValue,
2159 "FieldId = ".intval($this->DBFields["FieldId"]),
2160 $this->DBFields);
2161 }
2162 private function UpdateBoolValue($FieldName, $NewValue)
2163 {
2164 # nuke stale field cache
2165 self::$FieldCache = NULL;
2166
2167 $NewValue = $this->TranslateStringToConstants($NewValue);
2168 return $this->DB->UpdateIntValue("MetadataFields", $FieldName, $NewValue,
2169 "FieldId = ".intval($this->DBFields["FieldId"]),
2170 $this->DBFields);
2171 }
2172 private function UpdateConstValue($FieldName, $NewValue, $ClassName=NULL)
2173 {
2174 # nuke stale field cache
2175 self::$FieldCache = NULL;
2176
2177 $NewValue = $this->TranslateStringToConstants($NewValue, $ClassName);
2178 return $this->DB->UpdateIntValue("MetadataFields", $FieldName, $NewValue,
2179 "FieldId = ".intval($this->DBFields["FieldId"]),
2180 $this->DBFields);
2181 }
2182
2183 # normalize field name for use as database field name
2184 private function NormalizeFieldNameForDB($Name)
2185 {
2186 return preg_replace("/[^a-z0-9]/i", "", $Name)
2187 .(($this->SchemaId() != MetadataSchema::SCHEMAID_DEFAULT)
2188 ? $this->SchemaId() : "");
2189 }
2190
2191 # add any needed database fields and/or entries
2192 private function AddDatabaseFields()
2193 {
2194 # grab values for common use
2195 $DB = $this->DB;
2196 $FieldName = $this->Name();
2197 $DBFieldName = $this->DBFieldName();
2198 $Optional = $this->Optional();
2199 $DefaultValue = $this->DefaultValue();
2200
2201 if ($DefaultValue != NULL && !is_array($DefaultValue) )
2202 {
2203 if ($this->Type() == MetadataSchema::MDFTYPE_NUMBER ||
2204 $this->Type() == MetadataSchema::MDFTYPE_FLAG)
2205 {
2206 $DefaultSql = "DEFAULT ".intval($DefaultValue);
2207 }
2208 else
2209 {
2210 $DefaultSql = "DEFAULT '".addslashes($DefaultValue)."'";
2211 }
2212 }
2213 else
2214 {
2215 $DefaultSql = "DEFAULT NULL";
2216 }
2217
2218 # set up field(s) based on field type
2219 switch ($this->Type())
2220 {
2221 case MetadataSchema::MDFTYPE_TEXT:
2222 case MetadataSchema::MDFTYPE_PARAGRAPH:
2223 case MetadataSchema::MDFTYPE_URL:
2224 # add field to resources table (if not already present)
2225 if (!$DB->FieldExists("Resources", $DBFieldName))
2226 {
2227 $DB->Query("ALTER TABLE Resources ADD COLUMN `".$DBFieldName
2228 ."` TEXT ".$DefaultSql);
2229 }
2230
2231 break;
2232
2233 case MetadataSchema::MDFTYPE_NUMBER:
2234 # add field to resources table (if not already present)
2235 if (!$DB->FieldExists("Resources", $DBFieldName))
2236 {
2237 $DB->Query("ALTER TABLE Resources ADD COLUMN `".$DBFieldName
2238 ."` INT ".$DefaultSql);
2239 }
2240 break;
2241
2242 case MetadataSchema::MDFTYPE_POINT:
2243 if (!$DB->FieldExists("Resources", $DBFieldName."X"))
2244 {
2245 $Precision = $this->UpdateValue("PointPrecision",
2246 DB_NOVALUE);
2247 $Digits = $this->UpdateValue("PointDecimalDigits",
2248 DB_NOVALUE);
2249
2250 $DB->Query("ALTER TABLE Resources ADD COLUMN `"
2251 .$DBFieldName."X`".
2252 " DECIMAL(".$Precision.",".$Digits.") DEFAULT NULL");
2253 $DB->Query("ALTER TABLE Resources ADD COLUMN `"
2254 .$DBFieldName."Y`".
2255 " DECIMAL(".$Precision.",".$Digits.") DEFAULT NULL");
2256 }
2257
2258 break;
2259 case MetadataSchema::MDFTYPE_FLAG:
2260 # if field is not already present in database
2261 if (!$DB->FieldExists("Resources", $DBFieldName))
2262 {
2263 # add field to resources table
2264 $DB->Query("ALTER TABLE Resources ADD COLUMN `".$DBFieldName
2265 ."` INT ".$DefaultSql);
2266 }
2267 break;
2268
2269 case MetadataSchema::MDFTYPE_USER:
2270 # add field to resources table (if not already present)
2271 if (!$DB->FieldExists("Resources", $DBFieldName))
2272 {
2273 $DB->Query("ALTER TABLE Resources ADD COLUMN `".$DBFieldName
2274 ."` INT DEFAULT NULL");
2275 }
2276 break;
2277
2278 case MetadataSchema::MDFTYPE_FILE:
2279 # add fields to resources table (if not already present)
2280 if (!$DB->FieldExists("Resources", $DBFieldName))
2281 {
2282 $DB->Query("ALTER TABLE Resources ADD COLUMN `"
2283 .$DBFieldName."` TEXT DEFAULT NULL");
2284 }
2285 break;
2286
2287 case MetadataSchema::MDFTYPE_IMAGE:
2288 # add fields to resources table (if not already present)
2289 if (!$DB->FieldExists("Resources", $DBFieldName))
2290 {
2291 $DB->Query("ALTER TABLE Resources ADD COLUMN `"
2292 .$DBFieldName."` INT DEFAULT NULL");
2293 }
2294 break;
2295
2296 case MetadataSchema::MDFTYPE_DATE:
2297 # add fields to resources table (if not already present)
2298 if (!$DB->FieldExists("Resources", $DBFieldName."Begin"))
2299 {
2300 $DB->Query("ALTER TABLE Resources ADD COLUMN `".$DBFieldName."Begin`"
2301 ." DATE DEFAULT NULL");
2302 }
2303 if (!$DB->FieldExists("Resources", $DBFieldName."End"))
2304 {
2305 $DB->Query("ALTER TABLE Resources ADD COLUMN `".$DBFieldName."End`"
2306 ." DATE DEFAULT NULL");
2307 }
2308 if (!$DB->FieldExists("Resources", $DBFieldName."Precision"))
2309 {
2310 $DB->Query("ALTER TABLE Resources "
2311 ."ADD COLUMN `".$DBFieldName."Precision`"
2312 ." INT DEFAULT NULL");
2313 }
2314 break;
2315
2316 case MetadataSchema::MDFTYPE_TIMESTAMP:
2317 # add fields to resources table (if not already present)
2318 if (!$DB->FieldExists("Resources", $DBFieldName))
2319 {
2320 $DB->Query("ALTER TABLE Resources ADD COLUMN `".$DBFieldName
2321 ."` DATETIME DEFAULT NULL");
2322 }
2323 break;
2324
2325 case MetadataSchema::MDFTYPE_TREE:
2326 case MetadataSchema::MDFTYPE_CONTROLLEDNAME:
2327 case MetadataSchema::MDFTYPE_OPTION:
2328 case MetadataSchema::MDFTYPE_REFERENCE:
2329 break;
2330
2331 default:
2332 exit("<br>ERROR: Attempt to add database fields "
2333 ."for illegal metadata field type<br>\n");
2334 break;
2335 }
2336 }
2337
2345 private function TranslateStringToConstants($CString, $ClassName = NULL)
2346 {
2347 # if not a string return value unchanged to caller
2348 if (!is_string($CString) || ($CString === DB_NOVALUE))
2349 {
2350 $ReturnValue = $CString;
2351 }
2352 # handle booleans as a special case
2353 elseif (strtoupper(trim($CString)) == "TRUE")
2354 {
2355 $ReturnValue = TRUE;
2356 }
2357 elseif (strtoupper(trim($CString)) == "FALSE")
2358 {
2359 $ReturnValue = FALSE;
2360 }
2361 else
2362 {
2363 # assume no values will be found
2364 $ReturnValue = NULL;
2365
2366 # split apart any ORed-together values
2367 $Values = explode("|", $CString);
2368
2369 # for each value found
2370 foreach ($Values as $Value)
2371 {
2372 # trim off any extraneous whitespace
2373 $Value = trim($Value);
2374
2375 # add class name prefix to constant name if requested
2376 if ($ClassName) { $Value = $ClassName."::".$Value; }
2377
2378 # if value corresponds to a constant
2379 if (defined($Value))
2380 {
2381 # add constant to return value
2382 $ReturnValue = ($ReturnValue === NULL)
2383 ? constant($Value)
2384 : ($ReturnValue | constant($Value));
2385 }
2386 }
2387
2388 # if no corresponding constants were found
2389 if ($ReturnValue === NULL)
2390 {
2391 # return original value to caller
2392 $ReturnValue = $CString;
2393 }
2394 }
2395
2396 # return result to caller
2397 return $ReturnValue;
2398 }
2399
2403 private static $FieldCache = NULL;
2404 }
MetadataSchema\MDFSTAT_ILLEGALLABEL
const MDFSTAT_ILLEGALLABEL
Definition: MetadataSchema.php:49
MetadataSchema\MDFTYPE_IMAGE
const MDFTYPE_IMAGE
Definition: MetadataSchema.php:30
MetadataField\DefaultQualifier
DefaultQualifier($NewValue=DB_NOVALUE)
Definition: MetadataField.php:668
MetadataField\$FieldTypeDBEnums
static $FieldTypeDBEnums
Definition: MetadataField.php:1426
MetadataField\ViewingPrivileges
ViewingPrivileges(PrivilegeSet $NewValue=NULL)
Get/set privileges that allowing viewing values for this field.
Definition: MetadataField.php:378
MetadataField\$FixedDefaults
static $FixedDefaults
The metadata field defaults that are the same for all field types.
Definition: MetadataField.php:1642
DATEPRE_BEGINDAY
const DATEPRE_BEGINDAY
Definition: Axis--Date.php:747
MetadataField\$FieldTypeDBAllowedEnums
static $FieldTypeDBAllowedEnums
Definition: MetadataField.php:1443
MetadataField\SetDefaults
SetDefaults()
Set defaults values for the field.
Definition: MetadataField.php:1775
MetadataSchema\MDFTYPE_TIMESTAMP
const MDFTYPE_TIMESTAMP
Definition: MetadataSchema.php:24
MetadataField\Owner
Owner($NewValue=DB_NOVALUE)
Get/set field owner.
Definition: MetadataField.php:455
MetadataField\MaxPreviewHeight
MaxPreviewHeight($NewValue=DB_NOVALUE)
Definition: MetadataField.php:633
MetadataSchema\MDFTYPE_FILE
const MDFTYPE_FILE
Definition: MetadataSchema.php:31
MetadataSchema
Metadata schema (in effect a Factory class for MetadataField).
Definition: MetadataSchema.php:13
MetadataField\$FieldTypePHPEnums
static $FieldTypePHPEnums
Definition: MetadataField.php:1460
MetadataField\Status
Status()
Get current error status of object.
Definition: MetadataField.php:34
MetadataField\IncludeInFacetedSearch
IncludeInFacetedSearch($NewValue=DB_NOVALUE)
Get/set whether to include field in faceted search.
Definition: MetadataField.php:532
MetadataField\UPDATEMETHOD_ONRECORDCHANGE
const UPDATEMETHOD_ONRECORDCHANGE
Definition: MetadataField.php:22
MetadataField\GetValueForId
GetValueForId($Id)
Definition: MetadataField.php:1107
MetadataField\__construct
__construct($FieldId)
Object contstructor, used to load an existing metadata field.
Definition: MetadataField.php:1583
MetadataField\Instructions
Instructions($NewValue=DB_NOVALUE)
Get/set field instructions.
Definition: MetadataField.php:445
MetadataField\Create
static Create($SchemaId, $FieldType, $FieldName, $Optional=NULL, $DefaultValue=NULL)
Create a new metadata field.
Definition: MetadataField.php:1499
MetadataField\ValueUseCount
ValueUseCount($Value)
Check how many times a specific value is currently used for this field.
Definition: MetadataField.php:1147
MetadataField\UseForOaiSets
UseForOaiSets($NewValue=DB_NOVALUE)
Definition: MetadataField.php:683
MetadataField\AllowHTML
AllowHTML($NewValue=DB_NOVALUE)
Definition: MetadataField.php:673
MetadataField\UnassociatedQualifierList
UnassociatedQualifierList()
Definition: MetadataField.php:1269
MetadataField\USERISVALUE_UNSET
const USERISVALUE_UNSET
Definition: MetadataField.php:26
MetadataField\IncludeInRecommender
IncludeInRecommender($NewValue=DB_NOVALUE)
Get/set whether to include field in recommender system comparisons.
Definition: MetadataField.php:554
Database
SQL database abstraction object with smart query caching.
Definition: Axis--Database.php:22
MetadataSchema\MDFTYPE_REFERENCE
const MDFTYPE_REFERENCE
Definition: MetadataSchema.php:34
DB_NOVALUE
const DB_NOVALUE
Definition: Axis--Database.php:1331
MetadataField\GetFactory
GetFactory()
Definition: MetadataField.php:1342
MetadataField\AuthoringPrivileges
AuthoringPrivileges(PrivilegeSet $NewValue=NULL)
Get/set privileges that allowing authoring values for this field.
Definition: MetadataField.php:340
MetadataField\ShowQualifiers
ShowQualifiers($NewValue=DB_NOVALUE)
Definition: MetadataField.php:663
MetadataField\FlagOffLabel
FlagOffLabel($NewValue=DB_NOVALUE)
Definition: MetadataField.php:603
MetadataField\PointPrecision
PointPrecision($NewValue=DB_NOVALUE)
Definition: MetadataField.php:835
MetadataField\OptionListThreshold
OptionListThreshold($NewValue=DB_NOVALUE)
Definition: MetadataField.php:693
MetadataSchema\MDFSTAT_OK
const MDFSTAT_OK
Definition: MetadataSchema.php:42
MetadataSchema\MDFTYPE_NUMBER
const MDFTYPE_NUMBER
Definition: MetadataSchema.php:22
MetadataField\ViewingUserValue
ViewingUserValue($NewValue=DB_NOVALUE)
Definition: MetadataField.php:790
MetadataField\USERISVALUE_OR
const USERISVALUE_OR
Definition: MetadataField.php:25
MetadataField\USERISVALUE_AND
const USERISVALUE_AND
Definition: MetadataField.php:27
MetadataField\AllowMultiple
AllowMultiple($NewValue=DB_NOVALUE)
Get/set whether to allow multiple values for field.
Definition: MetadataField.php:499
MetadataField\$TypeBasedDefaults
static $TypeBasedDefaults
The metadata field defaults that vary depending on the field type.
Definition: MetadataField.php:1692
MetadataField\Description
Description($NewValue=DB_NOVALUE)
Get/set field description.
Definition: MetadataField.php:435
MetadataField\EditingUserValue
EditingUserValue($NewValue=DB_NOVALUE)
Definition: MetadataField.php:800
MetadataField\MaxThumbnailHeight
MaxThumbnailHeight($NewValue=DB_NOVALUE)
Definition: MetadataField.php:643
MetadataField\SearchWeight
SearchWeight($NewValue=DB_NOVALUE)
Definition: MetadataField.php:613
PrivilegeSet
Set of privileges used to access resource information or other parts of the system.
Definition: PrivilegeSet.php:16
MetadataField\HasItemLevelQualifiers
HasItemLevelQualifiers($NewValue=DB_NOVALUE)
Definition: MetadataField.php:1210
MetadataField\AssociateWithQualifier
AssociateWithQualifier($Qualifier)
DEPRECATED METHOD.
Definition: MetadataField.php:1320
MetadataField\AuthoringPrivilege
AuthoringPrivilege($NewValue=DB_NOVALUE)
Definition: MetadataField.php:720
MetadataField\DefaultAltText
DefaultAltText($NewValue=DB_NOVALUE)
Definition: MetadataField.php:653
MetadataFieldGroup
Class that builds on the foldering functionality to provide groups of metadata fields.
Definition: MetadataFieldGroup.php:14
Qualifier
Definition: Qualifier.php:10
MetadataSchema\MDFTYPE_TREE
const MDFTYPE_TREE
Definition: MetadataSchema.php:26
MetadataField\AjaxThreshold
AjaxThreshold($NewValue=DB_NOVALUE)
Definition: MetadataField.php:698
MetadataSchema\MDFTYPE_OPTION
const MDFTYPE_OPTION
Definition: MetadataSchema.php:28
QualifierFactory
Factory class for Qualifier.
Definition: QualifierFactory.php:13
MetadataSchema\MDFTYPE_FLAG
const MDFTYPE_FLAG
Definition: MetadataSchema.php:25
MetadataSchema\MDFTYPE_CONTROLLEDNAME
const MDFTYPE_CONTROLLEDNAME
Definition: MetadataSchema.php:27
MetadataField\$UpdateTypes
static $UpdateTypes
Definition: MetadataField.php:1478
MetadataField\Viewable
Viewable()
This function has been deprecated and should not be used.
Definition: MetadataField.php:1367
CWUserFactory
CWIS-specific user factory class.
Definition: CWUserFactory.php:13
MetadataField\$FieldTypeHumanEnums
static $FieldTypeHumanEnums
A map of metadata field types to human-readable strings.
Definition: MetadataField.php:1408
MetadataField\MaxPreviewWidth
MaxPreviewWidth($NewValue=DB_NOVALUE)
Definition: MetadataField.php:638
MetadataField\UPDATEMETHOD_ONRECORDEDIT
const UPDATEMETHOD_ONRECORDEDIT
Definition: MetadataField.php:21
MetadataField\UserPrivilegeRestrictions
UserPrivilegeRestrictions($NewValue=DB_NOVALUE)
Definition: MetadataField.php:810
PHP
PHP
Definition: RSSClient--Test.php:12
MetadataField\AddQualifier
AddQualifier($Qualifier)
Associate qualifier with field.
Definition: MetadataField.php:1286
MetadataField\SchemaId
SchemaId()
Get ID of schema for field.
Definition: MetadataField.php:73
MetadataField\IncludeInSortOptions
IncludeInSortOptions($NewValue=DB_NOVALUE)
Get/set whether to include field in search result sort options.
Definition: MetadataField.php:543
MetadataField\DefaultValue
DefaultValue($NewValue=DB_NOVALUE)
Definition: MetadataField.php:884
MetadataSchema\SCHEMAID_DEFAULT
const SCHEMAID_DEFAULT
Definition: MetadataSchema.php:52
MetadataField\DisplayAsListForAdvancedSearch
DisplayAsListForAdvancedSearch($NewValue=DB_NOVALUE)
Definition: MetadataField.php:688
MetadataField\TypeAsName
TypeAsName()
Get type of field as string.
Definition: MetadataField.php:64
DATEPRE_BEGINMONTH
const DATEPRE_BEGINMONTH
Definition: Axis--Date.php:746
MetadataField\MaxLength
MaxLength($NewValue=DB_NOVALUE)
Definition: MetadataField.php:573
MetadataField\MaxValue
MaxValue($NewValue=DB_NOVALUE)
Definition: MetadataField.php:593
MetadataField\PointDecimalDigits
PointDecimalDigits($NewValue=DB_NOVALUE)
Definition: MetadataField.php:859
MetadataField\GetAllowedConversionTypes
GetAllowedConversionTypes()
Get metadata field types that this field can be converted to.
Definition: MetadataField.php:182
MetadataField\Optional
Optional($NewValue=DB_NOVALUE)
Get/set whether a value is required for this field.
Definition: MetadataField.php:477
MetadataField\ViewingPrivilege
ViewingPrivilege($NewValue=DB_NOVALUE)
Definition: MetadataField.php:708
MetadataField\ParagraphRows
ParagraphRows($NewValue=DB_NOVALUE)
Definition: MetadataField.php:578
MetadataField\EditingPrivilege
EditingPrivilege($NewValue=DB_NOVALUE)
Definition: MetadataField.php:732
MetadataField\RequiredBySPT
RequiredBySPT($NewValue=DB_NOVALUE)
Definition: MetadataField.php:805
MetadataField\AuthoringUserIsValue
AuthoringUserIsValue($NewValue=DB_NOVALUE)
Definition: MetadataField.php:779
MetadataField\UsesQualifiers
UsesQualifiers($NewValue=DB_NOVALUE)
Definition: MetadataField.php:658
MetadataField\MaxThumbnailWidth
MaxThumbnailWidth($NewValue=DB_NOVALUE)
Definition: MetadataField.php:648
MetadataField\Enabled
Enabled($NewValue=DB_NOVALUE)
Get/set whether field is enabled.
Definition: MetadataField.php:466
MetadataField\AssociatedQualifierList
AssociatedQualifierList()
Definition: MetadataField.php:1247
ControlledNameFactory
Factory for manipulating ControlledName objects.
Definition: ControlledNameFactory.php:13
MetadataField\UPDATEMETHOD_NOAUTOUPDATE
const UPDATEMETHOD_NOAUTOUPDATE
Definition: MetadataField.php:18
MetadataField
Object representing a locally-defined type of metadata field.
Definition: MetadataField.php:13
MetadataField\NumAjaxResults
NumAjaxResults($NewValue=DB_NOVALUE)
Definition: MetadataField.php:703
MetadataField\Drop
Drop()
Definition: MetadataField.php:1797
MetadataSchema\MDFTYPE_PARAGRAPH
const MDFTYPE_PARAGRAPH
Definition: MetadataSchema.php:21
MetadataField\TextFieldSize
TextFieldSize($NewValue=DB_NOVALUE)
Definition: MetadataField.php:568
MetadataSchema\MDFTYPE_DATE
const MDFTYPE_DATE
Definition: MetadataSchema.php:23
MetadataField\ViewingUserIsValue
ViewingUserIsValue($NewValue=DB_NOVALUE)
Definition: MetadataField.php:774
MetadataSchema\MDFTYPE_URL
const MDFTYPE_URL
Definition: MetadataSchema.php:32
MetadataField\EnableOnOwnerReturn
EnableOnOwnerReturn($NewValue=DB_NOVALUE)
Definition: MetadataField.php:769
MetadataField\FlagOnLabel
FlagOnLabel($NewValue=DB_NOVALUE)
Definition: MetadataField.php:598
MetadataField\TreeBrowsingPrivilege
TreeBrowsingPrivilege($NewValue=DB_NOVALUE)
Definition: MetadataField.php:757
MetadataSchema\MDFTYPE_TEXT
const MDFTYPE_TEXT
Definition: MetadataSchema.php:20
MetadataField\UPDATEMETHOD_BUTTON
const UPDATEMETHOD_BUTTON
Definition: MetadataField.php:20
MetadataField\UseWysiwygEditor
UseWysiwygEditor($NewValue=DB_NOVALUE)
Definition: MetadataField.php:678
MetadataField\EditingUserIsValue
EditingUserIsValue($NewValue=DB_NOVALUE)
Definition: MetadataField.php:785
MetadataField\GetPossibleValues
GetPossibleValues($MaxNumberOfValues=NULL, $Offset=0)
Definition: MetadataField.php:962
MetadataSchema\MDFSTAT_ILLEGALNAME
const MDFSTAT_ILLEGALNAME
Definition: MetadataSchema.php:47
MetadataField\EditingPrivileges
EditingPrivileges(PrivilegeSet $NewValue=NULL)
Get/set privileges that allowing editing values for this field.
Definition: MetadataField.php:359
MetadataFieldOrder\GetOrdersForSchema
static GetOrdersForSchema(MetadataSchema $Schema)
Get all of the orders associated with a schema.
Definition: MetadataFieldOrder.php:640
MetadataField\GetIdForValue
GetIdForValue($Value)
Definition: MetadataField.php:1075
MetadataField\RecommenderWeight
RecommenderWeight($NewValue=DB_NOVALUE)
Definition: MetadataField.php:618
MetadataSchema\MDFTYPE_USER
const MDFTYPE_USER
Definition: MetadataSchema.php:29
MetadataField\Label
Label($NewLabel=DB_NOVALUE)
Get/set label for field.
Definition: MetadataField.php:151
MetadataField\Type
Type($NewValue=DB_NOVALUE)
Get/set type of metadata field (enumerated value).
Definition: MetadataField.php:45
MetadataField\Id
Id()
Get metadata field ID.
Definition: MetadataField.php:415
MetadataField\DBFieldName
DBFieldName()
Get base name of database column used to store metadata field value.
Definition: MetadataField.php:425
MetadataField\ImagePreviewPrivilege
ImagePreviewPrivilege($NewValue=DB_NOVALUE)
Definition: MetadataField.php:744
MetadataField\DateFormat
DateFormat($NewValue=DB_NOVALUE)
Definition: MetadataField.php:608
MetadataField\MaxWidth
MaxWidth($NewValue=DB_NOVALUE)
Definition: MetadataField.php:628
MetadataField\MaxHeight
MaxHeight($NewValue=DB_NOVALUE)
Definition: MetadataField.php:623
MetadataField\UPDATEMETHOD_ONRECORDCREATE
const UPDATEMETHOD_ONRECORDCREATE
Definition: MetadataField.php:19
MetadataSchema\MDFSTAT_DUPLICATENAME
const MDFSTAT_DUPLICATENAME
Definition: MetadataSchema.php:44
ClassificationFactory
Factory for producing and manipulating Classification objects.
Definition: ClassificationFactory.php:14
MetadataField\PreviewingPrivileges
PreviewingPrivileges(PrivilegeSet $NewValue=NULL)
Get/set privileges that allowing previewing values for this field.
Definition: MetadataField.php:397
MetadataField\ParagraphCols
ParagraphCols($NewValue=DB_NOVALUE)
Definition: MetadataField.php:583
MetadataField\UnassociateWithQualifier
UnassociateWithQualifier($QualifierIdOrObject)
Definition: MetadataField.php:1326
MetadataSchema\MDFTYPE_POINT
const MDFTYPE_POINT
Definition: MetadataSchema.php:33
File
Class representing a stored (usually uploaded) file.
Definition: File.php:13
MetadataField\IncludeInKeywordSearch
IncludeInKeywordSearch($NewValue=DB_NOVALUE)
Get/set whether to include field in keyword search.
Definition: MetadataField.php:510
MetadataField\Editable
Editable($NewValue=DB_NOVALUE)
Get/set whether this field is editable.
Definition: MetadataField.php:488
MetadataField\CopyOnResourceDuplication
CopyOnResourceDuplication($NewValue=DB_NOVALUE)
Get/set whether to duplciate this field when a resource is duplicated.
Definition: MetadataField.php:563
MetadataField\IsTempItem
IsTempItem($NewSetting=NULL)
Get/set whether field is temporary instance.
Definition: MetadataField.php:244
MetadataField\Name
Name($NewName=DB_NOVALUE)
Get/set name of field.
Definition: MetadataField.php:94
MetadataField\IncludeInAdvancedSearch
IncludeInAdvancedSearch($NewValue=DB_NOVALUE)
Get/set whether to include field in advanced search.
Definition: MetadataField.php:521
MetadataField\GetCountOfPossibleValues
GetCountOfPossibleValues()
Definition: MetadataField.php:1037
MetadataField\GetDisplayName
GetDisplayName()
Get display name for field.
Definition: MetadataField.php:83
MetadataField\MinValue
MinValue($NewValue=DB_NOVALUE)
Definition: MetadataField.php:588
MetadataField\AuthoringUserValue
AuthoringUserValue($NewValue=DB_NOVALUE)
Definition: MetadataField.php:795
MetadataField\UpdateMethod
UpdateMethod($NewValue=DB_NOVALUE)
Get/set method by which field is updated.
Definition: MetadataField.php:954