CWIS Developer Documentation
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 
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() { return $this->ErrorStatus; }
35 
42  function Type($NewValue = DB_NOVALUE)
43  {
44  # if new value supplied
45  if (($NewValue != DB_NOVALUE)
46  && ($NewValue != MetadataField::$FieldTypePHPEnums[
47  $this->DBFields["FieldType"]]))
48  {
49  # update database fields and store new type
50  $this->ModifyField(NULL, $NewValue);
51  }
52 
53  # return type to caller
54  return MetadataField::$FieldTypePHPEnums[$this->DBFields["FieldType"]];
55  }
56 
61  function TypeAsName()
62  {
63  return $this->DBFields["FieldType"];
64  }
65 
70  function SchemaId()
71  {
72  return $this->DBFields["SchemaId"];
73  }
74 
80  function GetDisplayName()
81  {
82  return strlen($this->Label()) ? $this->Label() : $this->Name();
83  }
84 
91  function Name($NewName = DB_NOVALUE)
92  {
93  # if new name specified
94  if ($NewName != DB_NOVALUE
95  && trim($NewName) != $this->DBFields["FieldName"])
96  {
97  $NewName = trim($NewName);
98  $NormalizedName = $this->NormalizeFieldNameForDB(strtolower($NewName));
99 
100  # if field name is invalid
101  if (!preg_match("/^[[:alnum:] \(\)]+$/", $NewName))
102  {
103  # set error status to indicate illegal name
104  $this->ErrorStatus = MetadataSchema::MDFSTAT_ILLEGALNAME;
105  }
106 
107  # if the new name is a reserved word
108  else if ($NormalizedName == "resourceid" || $NormalizedName == "schemaid")
109  {
110  # set error status to indicate illegal name
111  $this->ErrorStatus = MetadataSchema::MDFSTAT_ILLEGALNAME;
112  }
113 
114  # the name is okay but might be a duplicate
115  else
116  {
117  # check for duplicate name
118  $DuplicateCount = $this->DB->Query(
119  "SELECT COUNT(*) AS RecordCount FROM MetadataFields"
120  ." WHERE FieldName = '".addslashes($NewName)."'"
121  ." AND SchemaId = ".intval($this->DBFields["SchemaId"]),
122  "RecordCount");
123 
124  # if field name is duplicate
125  if ($DuplicateCount > 0)
126  {
127  # set error status to indicate duplicate name
128  $this->ErrorStatus = MetadataSchema::MDFSTAT_DUPLICATENAME;
129  }
130  else
131  {
132  # modify database declaration to reflect new field name
133  $this->ErrorStatus = MetadataSchema::MDFSTAT_OK;
134  $this->ModifyField($NewName);
135  }
136  }
137  }
138 
139  # return value to caller
140  return $this->DBFields["FieldName"];
141  }
142 
148  function Label($NewLabel = DB_NOVALUE)
149  {
150  $ValidValueExp = '/^[[:alnum:] ]*$/';
151  $Value = $this->DBFields["Label"];
152 
153  # if a new label was specified
154  if ($NewLabel !== DB_NOVALUE && trim($NewLabel) != $Value)
155  {
156  $NewLabel = trim($NewLabel);
157 
158  # if field label is valid
159  if (preg_match($ValidValueExp, $NewLabel))
160  {
161  $this->UpdateValue("Label", $NewLabel);
162  $Value = $NewLabel;
163  }
164  # the field label is invalid
165  else
166  {
167  $this->ErrorStatus = MetadataSchema::MDFSTAT_ILLEGALLABEL;
168  }
169  }
170 
171  return $Value;
172  }
173 
180  {
181  # determine type list based on our type
182  switch ($this->Type())
183  {
189  $AllowedTypes = array(
191  MetadataSchema::MDFTYPE_PARAGRAPH => "Paragraph",
192  MetadataSchema::MDFTYPE_NUMBER => "Number",
195  );
196  break;
197 
200  $AllowedTypes = array(
201  MetadataSchema::MDFTYPE_CONTROLLEDNAME => "ControlledName",
202  MetadataSchema::MDFTYPE_OPTION => "Option",
203  );
204  break;
205 
207  $AllowedTypes = array(
210  );
211  break;
212 
214  $AllowedTypes = array(
216  MetadataSchema::MDFTYPE_IMAGE => "Still Image",
217  );
218  break;
219 
225  default:
226  $AllowedTypes = array();
227  break;
228  }
229 
230  # return type list to caller
231  return $AllowedTypes;
232  }
233 
241  function IsTempItem($NewSetting = NULL)
242  {
243  $Schema = new MetadataSchema($this->SchemaId());
244  $ItemTableName = "MetadataFields";
245  $ItemIdFieldName = "FieldId";
246  $ItemFactoryObjectName = "MetadataSchema";
247  $ItemAssociationTables = array(
248  "FieldQualifierInts",
249  );
250  $ItemAssociationFieldName = "MetadataFieldId";
251 
252  # if new temp item setting supplied
253  if (!is_null($NewSetting))
254  {
255  # if caller requested to switch
256  if (($this->Id() < 0 && $NewSetting == FALSE)
257  || ($this->Id() >= 0 && $NewSetting == TRUE))
258  {
259  # if field name is invalid
260  if (strlen($this->NormalizeFieldNameForDB($this->Name())) < 1)
261  {
262  # set error status to indicate illegal name
263  $this->ErrorStatus = MetadataSchema::MDFSTAT_ILLEGALNAME;
264  }
265  else
266  {
267  # lock DB tables to prevent next ID from being grabbed
268  $DB = $this->DB;
269  $DB->Query("
270  LOCK TABLES ".$ItemTableName." WRITE,
271  APSessions WRITE, APSessionData WRITE,
272  MetadataSchemas WRITE");
273 
274  # get next temp item ID
275  $OldItemId = $this->Id();
276  $Factory = new $ItemFactoryObjectName();
277  if ($NewSetting == TRUE)
278  {
279  $NewId = $Factory->GetNextTempItemId();
280  }
281  else
282  {
283  $NewId = $Factory->GetNextItemId();
284  }
285 
286  # change item ID
287  $DB->Query("UPDATE ".$ItemTableName." SET ".$ItemIdFieldName." = ".
288  $NewId. " WHERE ".$ItemIdFieldName." = ".$OldItemId);
289 
290  # release DB tables
291  $DB->Query("UNLOCK TABLES");
292 
293  # change associations
294  foreach ($ItemAssociationTables as $TableName)
295  {
296  $DB->Query("UPDATE ".$TableName." SET ".$ItemAssociationFieldName." = ".
297  $NewId. " WHERE ".$ItemAssociationFieldName." = ".$OldItemId);
298  }
299 
300  # if changing item from temp to non-temp
301  if ($NewSetting == FALSE)
302  {
303  # add any needed database fields and/or entries
304  $this->AddDatabaseFields();
305 
306  # Signal that a new (real) field was added:
307  global $AF;
308  $AF->SignalEvent(
309  "EVENT_FIELD_ADDED",
310  array("FieldId" => $NewId ) );
311 
312  # set field order values for new field
313  $Schema->GetDisplayOrder()->AppendItem($NewId, "MetadataField");
314  $Schema->GetEditOrder()->AppendItem($NewId, "MetadataField");
315  }
316 
317  # update metadata field id
318  $this->DBFields["FieldId"] = $NewId;
319  $this->Id = $NewId;
320  }
321  }
322  }
323 
324  # report to caller whether we are a temp item
325  return ($this->Id() < 0) ? TRUE : FALSE;
326  }
327 
333  function AuthoringPrivileges(PrivilegeSet $NewValue = NULL)
334  {
335  # if new privileges supplied
336  if ($NewValue !== NULL)
337  {
338  # store new privileges in database
339  $this->UpdateValue("AuthoringPrivileges", $NewValue->Data());
340  $this->AuthoringPrivileges = $NewValue;
341  }
342 
343  # return current value to caller
344  return $this->AuthoringPrivileges;
345  }
346 
352  function EditingPrivileges(PrivilegeSet $NewValue = NULL)
353  {
354  # if new privileges supplied
355  if ($NewValue !== NULL)
356  {
357  # store new privileges in database
358  $this->UpdateValue("EditingPrivileges", $NewValue->Data());
359  $this->EditingPrivileges = $NewValue;
360  }
361 
362  # return current value to caller
363  return $this->EditingPrivileges;
364  }
365 
371  function ViewingPrivileges(PrivilegeSet $NewValue = NULL)
372  {
373  # if new privileges supplied
374  if ($NewValue !== NULL)
375  {
376  # store new privileges in database
377  $this->UpdateValue("ViewingPrivileges", $NewValue->Data());
378  $this->ViewingPrivileges = $NewValue;
379  }
380 
381  # return current value to caller
382  return $this->ViewingPrivileges;
383  }
384 
390  function PreviewingPrivileges(PrivilegeSet $NewValue = NULL)
391  {
392  # if new privileges supplied
393  if ($NewValue !== NULL)
394  {
395  # store new privileges in database
396  $this->UpdateValue("PreviewingPrivileges", $NewValue->Data());
397  $this->PreviewingPrivileges = $NewValue;
398  }
399 
400  # return current value to caller
401  return $this->PreviewingPrivileges;
402  }
403 
408  function Id() { return $this->Id; }
409 
415  function DBFieldName() { return $this->DBFields["DBFieldName"]; }
416 
422  function Description($NewValue = DB_NOVALUE)
423  { return $this->UpdateValue("Description", $NewValue); }
424 
430  function Instructions($NewValue = DB_NOVALUE)
431  { return $this->UpdateValue("Instructions", $NewValue); }
432 
438  function Owner($NewValue = DB_NOVALUE)
439  { return $this->UpdateValue("Owner", $NewValue); }
440 
447  function Enabled($NewValue = DB_NOVALUE)
448  { return $this->UpdateBoolValue("Enabled", $NewValue); }
449 
456  function Optional($NewValue = DB_NOVALUE)
457  { return $this->UpdateBoolValue("Optional", $NewValue); }
458 
465  function Editable($NewValue = DB_NOVALUE)
466  { return $this->UpdateBoolValue("Editable", $NewValue); }
467 
474  function AllowMultiple($NewValue = DB_NOVALUE)
475  { return $this->UpdateBoolValue("AllowMultiple", $NewValue); }
476 
483  function IncludeInKeywordSearch($NewValue = DB_NOVALUE)
484  { return $this->UpdateBoolValue("IncludeInKeywordSearch", $NewValue); }
485 
492  function IncludeInAdvancedSearch($NewValue = DB_NOVALUE)
493  { return $this->UpdateBoolValue("IncludeInAdvancedSearch", $NewValue); }
494 
501  function IncludeInFacetedSearch($NewValue = DB_NOVALUE)
502  { return $this->UpdateBoolValue("IncludeInFacetedSearch", $NewValue); }
503 
510  function IncludeInSortOptions($NewValue = DB_NOVALUE)
511  { return $this->UpdateBoolValue("IncludeInSortOptions", $NewValue); }
512 
519  function IncludeInRecommender($NewValue = DB_NOVALUE)
520  { return $this->UpdateBoolValue("IncludeInRecommender", $NewValue); }
521  function TextFieldSize($NewValue = DB_NOVALUE)
522  { return $this->UpdateIntValue("TextFieldSize", $NewValue); }
523  function MaxLength($NewValue = DB_NOVALUE)
524  { return $this->UpdateIntValue("MaxLength", $NewValue); }
525  function ParagraphRows($NewValue = DB_NOVALUE)
526  { return $this->UpdateIntValue("ParagraphRows", $NewValue); }
527  function ParagraphCols($NewValue = DB_NOVALUE)
528  { return $this->UpdateIntValue("ParagraphCols", $NewValue); }
529  function MinValue($NewValue = DB_NOVALUE)
530  { return $this->UpdateFloatValue("MinValue", $NewValue); }
531  function MaxValue($NewValue = DB_NOVALUE)
532  { return $this->UpdateFloatValue("MaxValue", $NewValue); }
533  function FlagOnLabel($NewValue = DB_NOVALUE)
534  { return $this->UpdateValue("FlagOnLabel", $NewValue); }
535  function FlagOffLabel($NewValue = DB_NOVALUE)
536  { return $this->UpdateValue("FlagOffLabel", $NewValue); }
537  function DateFormat($NewValue = DB_NOVALUE)
538  { return $this->UpdateValue("DateFormat", $NewValue); }
539  function SearchWeight($NewValue = DB_NOVALUE)
540  { return $this->UpdateIntValue("SearchWeight", $NewValue); }
541  function RecommenderWeight($NewValue = DB_NOVALUE)
542  { return $this->UpdateIntValue("RecommenderWeight", $NewValue); }
543  function MaxHeight($NewValue = DB_NOVALUE)
544  { return $this->UpdateIntValue("MaxHeight", $NewValue); }
545  function MaxWidth($NewValue = DB_NOVALUE)
546  { return $this->UpdateIntValue("MaxWidth", $NewValue); }
547  function MaxPreviewHeight($NewValue = DB_NOVALUE)
548  { return $this->UpdateIntValue("MaxPreviewHeight", $NewValue); }
549  function MaxPreviewWidth($NewValue = DB_NOVALUE)
550  { return $this->UpdateIntValue("MaxPreviewWidth", $NewValue); }
551  function MaxThumbnailHeight($NewValue = DB_NOVALUE)
552  { return $this->UpdateIntValue("MaxThumbnailHeight", $NewValue); }
553  function MaxThumbnailWidth($NewValue = DB_NOVALUE)
554  { return $this->UpdateIntValue("MaxThumbnailWidth", $NewValue); }
555  function DefaultAltText($NewValue = DB_NOVALUE)
556  { return $this->UpdateValue("DefaultAltText", $NewValue); }
557  function UsesQualifiers($NewValue = DB_NOVALUE)
558  { return $this->UpdateBoolValue("UsesQualifiers", $NewValue); }
559  function ShowQualifiers($NewValue = DB_NOVALUE)
560  { return $this->UpdateBoolValue("ShowQualifiers", $NewValue); }
561  function DefaultQualifier($NewValue = DB_NOVALUE)
562  { return $this->UpdateValue("DefaultQualifier", $NewValue); }
563  function AllowHTML($NewValue = DB_NOVALUE)
564  { return $this->UpdateBoolValue("AllowHTML", $NewValue); }
565  function UseWysiwygEditor($NewValue = DB_NOVALUE)
566  { return $this->UpdateBoolValue("UseWysiwygEditor", $NewValue); }
567  function UseForOaiSets($NewValue = DB_NOVALUE)
568  { return $this->UpdateBoolValue("UseForOaiSets", $NewValue); }
570  { return $this->UpdateBoolValue("DisplayAsListForAdvancedSearch", $NewValue); }
571  function OptionListThreshold($NewValue = DB_NOVALUE)
572  { return $this->UpdateIntValue("OptionListThreshold", $NewValue); }
573  function AjaxThreshold($NewValue = DB_NOVALUE)
574  { return $this->UpdateIntValue("AjaxThreshold", $NewValue); }
575  function NumAjaxResults($NewValue = DB_NOVALUE)
576  { return $this->UpdateIntValue("NumAjaxResults", $NewValue); }
577  function ViewingPrivilege($NewValue = DB_NOVALUE)
578  {
579  if ($NewValue === DB_NOVALUE)
580  return $this->ViewingPrivileges();
581  else
582  throw new Exception("Deprecated ".__METHOD__."() called -- ".
583  __METHOD__."s() should be used instead.");
584  }
585  function AuthoringPrivilege($NewValue = DB_NOVALUE)
586  {
587  if ($NewValue === DB_NOVALUE)
588  return $this->AuthoringPrivileges();
589  else
590  throw new Exception("Deprecated ".__METHOD__."() called -- ".
591  __METHOD__."s() should be used instead.");
592  }
593  function EditingPrivilege($NewValue = DB_NOVALUE)
594  {
595  if ($NewValue === DB_NOVALUE)
596  return $this->EditingPrivileges();
597  else
598  throw new Exception("Deprecated ".__METHOD__."() called -- ".
599  __METHOD__."s() should be used instead.");
600  }
601  function ImagePreviewPrivilege($NewValue = DB_NOVALUE)
602  { return $this->UpdateConstValue("ImagePreviewPrivilege", $NewValue); }
603  function TreeBrowsingPrivilege($NewValue = DB_NOVALUE)
604  {
605  if ($NewValue === DB_NOVALUE)
606  return $this->ViewingPrivileges();
607  else
608  throw new Exception("Deprecated ".__METHOD__."() called -- ".
609  "this should probably be using ViewingPrivileges() instead.");
610  }
611  function EnableOnOwnerReturn($NewValue = DB_NOVALUE)
612  { return $this->UpdateBoolValue("EnableOnOwnerReturn", $NewValue); }
613  function ViewingUserIsValue($NewValue = DB_NOVALUE)
614  { return $this->UpdateConstValue("ViewingUserIsValue", $NewValue, "MetadataField"); }
615  function AuthoringUserIsValue($NewValue = DB_NOVALUE)
616  { return $this->UpdateConstValue("AuthoringUserIsValue", $NewValue, "MetadataField"); }
617  function EditingUserIsValue($NewValue = DB_NOVALUE)
618  { return $this->UpdateConstValue("EditingUserIsValue", $NewValue, "MetadataField"); }
619  function ViewingUserValue($NewValue = DB_NOVALUE)
620  { return $this->UpdateIntValue("ViewingUserValue", $NewValue, "MetadataField"); }
621  function AuthoringUserValue($NewValue = DB_NOVALUE)
622  { return $this->UpdateIntValue("AuthoringUserValue", $NewValue, "MetadataField"); }
623  function EditingUserValue($NewValue = DB_NOVALUE)
624  { return $this->UpdateIntValue("EditingUserValue", $NewValue, "MetadataField"); }
625  function RequiredBySPT($NewValue = DB_NOVALUE)
626  { return $this->UpdateBoolValue("RequiredBySPT", $NewValue); }
627 
628  function UserPrivilegeRestrictions($NewValue = DB_NOVALUE)
629  {
630  # new value
631  if ($NewValue != DB_NOVALUE)
632  {
633  $NewValue = serialize((array) $NewValue);
634  }
635 
636  $Value = $this->UpdateValue("UserPrivilegeRestrictions", $NewValue);
637 
638  # value set
639  if (strlen($Value))
640  {
641  $Value = (array) unserialize($Value);
642  }
643 
644  # no value set, set it to an empty array
645  else
646  {
647  $Value = $this->UserPrivilegeRestrictions(array());
648  }
649 
650  return $Value;
651  }
652 
653  function PointPrecision($NewValue = DB_NOVALUE)
654  {
655  if ($NewValue !== DB_NOVALUE && $this->Id() >= 0
656  && $this->Type() == MetadataSchema::MDFTYPE_POINT)
657  {
658  $OldValue = $this->UpdateValue("PointPrecision", DB_NOVALUE);
659 
660  if ($NewValue != $OldValue)
661  {
662  $Decimals = $this->UpdateValue("PointDecimalDigits", DB_NOVALUE);
663  $TotalDigits = $NewValue + $Decimals;
664 
665  $this->DB->Query("ALTER TABLE Resources MODIFY COLUMN "
666  ."`".$this->DBFields["DBFieldName"]."X` "
667  ."DECIMAL(".$TotalDigits.",".$Decimals.")");
668  $this->DB->Query("ALTER TABLE Resources MODIFY COLUMN "
669  ."`".$this->DBFields["DBFieldName"]."Y` "
670  ."DECIMAL(".$TotalDigits.",".$Decimals.")");
671  }
672  }
673 
674  return $this->UpdateValue("PointPrecision", $NewValue);
675  }
676 
677  function PointDecimalDigits($NewValue = DB_NOVALUE)
678  {
679  if ($NewValue !== DB_NOVALUE && $this->Id() >= 0
680  && $this->Type() == MetadataSchema::MDFTYPE_POINT)
681  {
682  $OldValue = $this->UpdateValue("PointDecimalDigits", DB_NOVALUE);
683 
684  if ($NewValue != $OldValue)
685  {
686  $Precision = $this->UpdateValue("PointPrecision", DB_NOVALUE);
687 
688  $TotalDigits = $NewValue + $Precision;
689 
690  $this->DB->Query("ALTER TABLE Resources MODIFY COLUMN "
691  ."`".$this->DBFields["DBFieldName"]."X` "
692  ."DECIMAL(".$TotalDigits.",".$NewValue.")");
693  $this->DB->Query("ALTER TABLE Resources MODIFY COLUMN "
694  ."`".$this->DBFields["DBFieldName"]."Y` "
695  ."DECIMAL(".$TotalDigits.",".$NewValue.")");
696  }
697  }
698 
699  return $this->UpdateValue("PointDecimalDigits", $NewValue);
700  }
701 
702  function DefaultValue($NewValue = DB_NOVALUE)
703  {
704  if ($this->Type() == MetadataSchema::MDFTYPE_POINT)
705  {
706  # valid value given
707  if ($NewValue !== DB_NOVALUE &&
708  isset($NewValue["X"]) && isset($NewValue["Y"]))
709  {
710  $NewValue = $NewValue["X"].",".$NewValue["Y"];
711  }
712 
713  # invalid value given
714  else
715  {
716  $NewValue = DB_NOVALUE;
717  }
718 
719  $Value = $this->UpdateValue("DefaultValue", $NewValue);
720 
721  if (is_array($Value))
722  {
723  $tmp = explode(",", $Value);
724 
725  if (count($tmp)==2)
726  {
727  return array("X" => $tmp[0], "Y" => $tmp[1]);
728  }
729  }
730 
731  return array("X" => NULL, "Y" => NULL);
732  }
733 
734  else if ($this->Type() == MetadataSchema::MDFTYPE_OPTION)
735  {
736  # multiple default values to set
737  if (is_array($NewValue))
738  {
739  # empty array
740  if (count($NewValue) == 0)
741  {
742  $NewValue = NULL;
743  }
744 
745  # multiple defaults are allowed
746  else if ($this->AllowMultiple())
747  {
748  $NewValue = serialize($NewValue);
749  }
750 
751  # only one default is allowed so get the first one
752  else
753  {
754  $NewValue = array_shift($NewValue);
755  }
756  }
757 
758  $Result = $this->UpdateValue("DefaultValue", $NewValue);
759 
760  return empty($Result) || is_numeric($Result) ?
761  $Result : unserialize($Result);
762  }
763 
764  return $this->UpdateValue("DefaultValue", $NewValue);
765  }
766 
772  function UpdateMethod($NewValue = DB_NOVALUE)
773  {
774  return $this->UpdateValue("UpdateMethod", $NewValue);
775  }
776 
777  # get possible values (only meaningful for Trees, Controlled Names, Options,
778  # Flags, and Users)
779  # (index for returned array is IDs for values)
780  function GetPossibleValues($MaxNumberOfValues = NULL, $Offset=0)
781  {
782  # retrieve values based on field type
783  switch ($this->Type())
784  {
786  $QueryString = "SELECT ClassificationId, ClassificationName"
787  ." FROM Classifications WHERE FieldId = ".$this->Id()
788  ." ORDER BY ClassificationName";
789  if ($MaxNumberOfValues)
790  {
791  $QueryString .= " LIMIT ".intval($MaxNumberOfValues)." OFFSET "
792  .intval($Offset);
793  }
794  $this->DB->Query($QueryString);
795  $PossibleValues = $this->DB->FetchColumn(
796  "ClassificationName", "ClassificationId");
797  break;
798 
801  $QueryString = "SELECT ControlledNameId, ControlledName"
802  ." FROM ControlledNames WHERE FieldId = ".$this->Id()
803  ." ORDER BY ControlledName";
804  if ($MaxNumberOfValues)
805  {
806  $QueryString .= " LIMIT ".intval($MaxNumberOfValues)." OFFSET "
807  .intval($Offset);
808  }
809  $this->DB->Query($QueryString);
810  $PossibleValues = $this->DB->FetchColumn(
811  "ControlledName", "ControlledNameId");
812  break;
813 
815  $PossibleValues[0] = $this->FlagOffLabel();
816  $PossibleValues[1] = $this->FlagOnLabel();
817  break;
818 
820  $UserFactory = new CWUserFactory();
821  $Restrictions = $this->UserPrivilegeRestrictions();
822  $PossibleValues = array();
823 
824  if (count($Restrictions))
825  {
826  $PossibleValues = call_user_func_array(
827  array($UserFactory, "GetUsersWithPrivileges"),
828  $Restrictions);
829  }
830 
831  else
832  {
833  $Users = $UserFactory->GetMatchingUsers(".*.");
834 
835  foreach ($Users as $Id => $Data)
836  {
837  $PossibleValues[$Id] = $Data["UserName"];
838  }
839  }
840 
841  break;
842 
843  default:
844  # for everything else return an empty array
845  $PossibleValues = array();
846  break;
847  }
848 
849  # return array of possible values to caller
850  return $PossibleValues;
851  }
852 
853  # get count of possible values (only meaningful for Trees, Controlled Names,
854  # Options, and Users)
856  {
857  # retrieve values based on field type
858  switch ($this->Type())
859  {
861  $Count = $this->DB->Query("SELECT count(*) AS ValueCount"
862  ." FROM Classifications WHERE FieldId = ".$this->Id(),
863  "ValueCount");
864  break;
865 
868  $Count = $this->DB->Query("SELECT count(*) AS ValueCount"
869  ." FROM ControlledNames WHERE FieldId = ".$this->Id(),
870  "ValueCount");
871  break;
872 
874  $Count = 2;
875  break;
876 
878  $Count = count($this->GetPossibleValues());
879  break;
880 
881  default:
882  # for everything else return an empty array
883  $Count = 0;
884  break;
885  }
886 
887  # return count of possible values to caller
888  return $Count;
889  }
890 
891  # get ID for specified value (only meaningful for Trees / Controlled Names / Options)
892  # (returns NULL if value not found)
893  function GetIdForValue($Value)
894  {
895  # retrieve ID based on field type
896  switch ($this->Type())
897  {
899  $Id = $this->DB->Query("SELECT ClassificationId FROM Classifications"
900  ." WHERE ClassificationName = '".addslashes($Value)."'"
901  ." AND FieldId = ".$this->Id(),
902  "ClassificationId");
903  break;
904 
907  $Id = $this->DB->Query("SELECT ControlledNameId FROM ControlledNames"
908  ." WHERE ControlledName = '".addslashes($Value)."'"
909  ." AND FieldId = ".$this->Id(),
910  "ControlledNameId");
911  break;
912 
913  default:
914  # for everything else return NULL
915  $Id = NULL;
916  break;
917  }
918 
919  # return ID for value to caller
920  return $Id;
921  }
922 
923  # get value for specified ID (only meaningful for Trees / Controlled Names / Options)
924  # (returns NULL if ID not found)
925  function GetValueForId($Id)
926  {
927  # retrieve ID based on field type
928  switch ($this->Type())
929  {
931  $Value = $this->DB->Query("SELECT ClassificationName FROM Classifications"
932  ." WHERE ClassificationId = '".intval($Id)."'"
933  ." AND FieldId = ".$this->Id(),
934  "ClassificationName");
935  break;
936 
939  $Value = $this->DB->Query("SELECT ControlledName FROM ControlledNames"
940  ." WHERE ControlledNameId = '".intval($Id)."'"
941  ." AND FieldId = ".$this->Id(),
942  "ControlledName");
943  break;
944 
945  default:
946  # for everything else return NULL
947  $Value = NULL;
948  break;
949  }
950 
951  # return ID for value to caller
952  return $Value;
953  }
954 
965  function ValueUseCount($Value)
966  {
967  # retrieve ID if object passed in
968  if (is_object($Value) && method_exists($Value, "Id"))
969  {
970  $Value = $Value->Id();
971  }
972 
973  # check value based on field type
974  $DBFieldName = $this->DBFields["DBFieldName"];
975  switch ($this->Type())
976  {
986  $UseCount = $this->DB->Query("SELECT COUNT(*) AS UseCount"
987  ." FROM Resources"
988  ." WHERE `".$DBFieldName."` = '".addslashes($Value)."'"
989  ." AND SchemaId = ".intval($this->DBFields["SchemaId"]),
990  "UseCount");
991  break;
992 
994  $UseCount = $this->DB->Query("SELECT COUNT(*) AS UseCount"
995  ." FROM ResourceClassInts"
996  ." WHERE ClassificationId = ".intval($Value),
997  "UseCount");
998  break;
999 
1002  $UseCount = $this->DB->Query("SELECT COUNT(*) AS UseCount"
1003  ." FROM ResourceNameInts"
1004  ." WHERE ControlledNameId = ".intval($Value),
1005  "UseCount");
1006  break;
1007 
1009  $UseCount = $this->DB->Query("SELECT COUNT(*) AS UseCount"
1010  ." FROM Resources"
1011  ." WHERE `".$DBFieldName."X` = '".$Value["X"]."'"
1012  ." AND `".$DBFieldName."Y` = '".$Value["Y"]."'"
1013  ." AND SchemaId = ".intval($this->DBFields["SchemaId"]),
1014  "UseCount");
1015  break;
1016 
1017  default:
1018  throw new Exception(__CLASS__."::".__METHOD__."() called for"
1019  ." unsupported field type (".$this->Type().").");
1020  break;
1021  }
1022 
1023  # report use count to caller
1024  return $UseCount;
1025  }
1026 
1027  # get/set whether field uses item-level qualifiers
1028  function HasItemLevelQualifiers($NewValue = DB_NOVALUE)
1029  {
1030  # if value provided different from present value
1031  if (($NewValue != DB_NOVALUE)
1032  && ($NewValue != $this->DBFields["HasItemLevelQualifiers"]))
1033  {
1034  # check if qualifier column currently exists
1035  $QualColName = $this->DBFieldName()."Qualifier";
1036  $QualColExists = $this->DB->FieldExists("Resources", $QualColName);
1037 
1038  # if new value indicates qualifiers should now be used
1039  if ($NewValue == TRUE)
1040  {
1041  # if qualifier column does not exist in DB for this field
1042  if ($QualColExists == FALSE)
1043  {
1044  # add qualifier column in DB for this field
1045  $this->DB->Query("ALTER TABLE Resources ADD COLUMN `"
1046  .$QualColName."` INT");
1047  }
1048  }
1049  else
1050  {
1051  # if qualifier column exists in DB for this field
1052  if ($QualColExists == TRUE)
1053  {
1054  # remove qualifier column from DB for this field
1055  $this->DB->Query("ALTER TABLE Resources DROP COLUMN `"
1056  .$QualColName."`");
1057  }
1058  }
1059  }
1060 
1061  return $this->UpdateValue("HasItemLevelQualifiers", $NewValue);
1062  }
1063 
1064  # get list of qualifiers associated with field
1066  {
1067  # start with empty list
1068  $List = array();
1069 
1070  # for each associated qualifier
1071  $this->DB->Query("SELECT QualifierId FROM FieldQualifierInts"
1072  ." WHERE MetadataFieldId = ".$this->DBFields["FieldId"]);
1073  while ($Record = $this->DB->FetchRow())
1074  {
1075  # load qualifier object
1076  $Qual = new Qualifier($Record["QualifierId"]);
1077 
1078  # add qualifier ID and name to list
1079  $List[$Qual->Id()] = $Qual->Name();
1080  }
1081 
1082  # return list to caller
1083  return $List;
1084  }
1085 
1086  # get list of qualifiers not associated with field
1088  {
1089  # grab list of associated qualifiers
1090  $AssociatedQualifiers = $this->AssociatedQualifierList();
1091 
1092  # get list of all qualifiers
1093  $QFactory = new QualifierFactory();
1094  $AllQualifiers = $QFactory->GetItemNames();
1095 
1096  # return list of unassociated qualifiers
1097  return array_diff($AllQualifiers, $AssociatedQualifiers);
1098  }
1099 
1104  function AddQualifier($Qualifier)
1105  {
1106  # if qualifier object passed in
1107  if (is_object($Qualifier))
1108  {
1109  # grab qualifier ID from object
1110  $Qualifier = $Qualifier->Id();
1111  }
1112  # else if string passed in does not look like ID
1113  elseif (!preg_match('/^[0-9]+$/', $Qualifier))
1114  {
1115  # assume string passed in is name and use it to retrieve ID
1116  $QFact = new QualifierFactory();
1117  $Qualifier = $QFact->GetItemIdByName($Qualifier);
1118  }
1119 
1120  # if not already associated
1121  $RecordCount = $this->DB->Query(
1122  "SELECT COUNT(*) AS RecordCount FROM FieldQualifierInts"
1123  ." WHERE QualifierId = ".$Qualifier
1124  ." AND MetadataFieldId = ".$this->Id(), "RecordCount");
1125  if ($RecordCount < 1)
1126  {
1127  # associate field with qualifier
1128  $this->DB->Query("INSERT INTO FieldQualifierInts SET"
1129  ." QualifierId = ".$Qualifier.","
1130  ." MetadataFieldId = ".$this->Id());
1131  }
1132  }
1138  function AssociateWithQualifier($Qualifier)
1139  { $this->AddQualifier($Qualifier); }
1140 
1141  # delete qualifier association
1142  function UnassociateWithQualifier($QualifierIdOrObject)
1143  {
1144  # if qualifier object passed in
1145  if (is_object($QualifierIdOrObject))
1146  {
1147  # grab qualifier ID from object
1148  $QualifierIdOrObject = $QualifierIdOrObject->Id();
1149  }
1150 
1151  # delete intersection record from database
1152  $this->DB->Query("DELETE FROM FieldQualifierInts WHERE QualifierId = "
1153  .$QualifierIdOrObject." AND MetadataFieldId = ".
1154  $this->Id());
1155  }
1156 
1157  # retrieve item factory object for this field
1158  function GetFactory()
1159  {
1160  switch ($this->Type())
1161  {
1163  $Factory = new ClassificationFactory($this->Id());
1164  break;
1165 
1168  $Factory = new ControlledNameFactory($this->Id());
1169  break;
1170 
1171  default:
1172  $Factory = NULL;
1173  break;
1174  }
1175 
1176  return $Factory;
1177  }
1178 
1183  function Viewable()
1184  {
1185  # the field should not be viewed if it is disabled
1186  if (!$this->Enabled())
1187  {
1188  return FALSE;
1189  }
1190 
1191  $UserPrivs = $GLOBALS["G_User"]->Privileges();
1192 
1193  # the user can view the field if they can edit it
1194  if ($UserPrivs->IsGreaterThan($this->EditingPrivileges()))
1195  {
1196  return TRUE;
1197  }
1198 
1199  # if the user can view the field
1200  if ($UserPrivs->IsGreaterThan($this->ViewingPrivileges()))
1201  {
1202  return TRUE;
1203  }
1204 
1205  # the user can't view the field
1206  return FALSE;
1207  }
1208 
1209  # ---- PRIVATE INTERFACE -------------------------------------------------
1210 
1211  private $DB;
1212  private $Id;
1213  private $DBFields;
1214  private $ErrorStatus;
1215  private $AuthoringPrivileges;
1216  private $EditingPrivileges;
1217  private $ViewingPrivileges;
1218  private $PreviewingPrivileges;
1219 
1224  public static $FieldTypeHumanEnums = array(
1225  MetadataSchema::MDFTYPE_TEXT => "Text",
1226  MetadataSchema::MDFTYPE_PARAGRAPH => "Paragraph",
1227  MetadataSchema::MDFTYPE_NUMBER => "Number",
1228  MetadataSchema::MDFTYPE_DATE => "Date",
1229  MetadataSchema::MDFTYPE_TIMESTAMP => "Timestamp",
1230  MetadataSchema::MDFTYPE_FLAG => "Flag",
1231  MetadataSchema::MDFTYPE_TREE => "Tree",
1232  MetadataSchema::MDFTYPE_CONTROLLEDNAME => "Controlled Name",
1233  MetadataSchema::MDFTYPE_OPTION => "Option",
1234  MetadataSchema::MDFTYPE_USER => "User",
1235  MetadataSchema::MDFTYPE_IMAGE => "Image",
1236  MetadataSchema::MDFTYPE_FILE => "File",
1237  MetadataSchema::MDFTYPE_URL => "URL",
1238  MetadataSchema::MDFTYPE_POINT => "Point",
1239  MetadataSchema::MDFTYPE_REFERENCE => "Reference");
1240 
1241  # field type DB/PHP enum translations
1242  public static $FieldTypeDBEnums = array(
1243  MetadataSchema::MDFTYPE_TEXT => "Text",
1244  MetadataSchema::MDFTYPE_PARAGRAPH => "Paragraph",
1245  MetadataSchema::MDFTYPE_NUMBER => "Number",
1246  MetadataSchema::MDFTYPE_DATE => "Date",
1247  MetadataSchema::MDFTYPE_TIMESTAMP => "TimeStamp",
1248  MetadataSchema::MDFTYPE_FLAG => "Flag",
1249  MetadataSchema::MDFTYPE_TREE => "Tree",
1250  MetadataSchema::MDFTYPE_CONTROLLEDNAME => "ControlledName",
1251  MetadataSchema::MDFTYPE_OPTION => "Option",
1252  MetadataSchema::MDFTYPE_USER => "User",
1253  MetadataSchema::MDFTYPE_IMAGE => "Still Image",
1254  MetadataSchema::MDFTYPE_FILE => "File",
1255  MetadataSchema::MDFTYPE_URL => "Url",
1256  MetadataSchema::MDFTYPE_POINT => "Point",
1257  MetadataSchema::MDFTYPE_REFERENCE => "Reference"
1258  );
1259  public static $FieldTypeDBAllowedEnums = array(
1260  MetadataSchema::MDFTYPE_TEXT => "Text",
1261  MetadataSchema::MDFTYPE_PARAGRAPH => "Paragraph",
1262  MetadataSchema::MDFTYPE_NUMBER => "Number",
1263  MetadataSchema::MDFTYPE_DATE => "Date",
1264  MetadataSchema::MDFTYPE_TIMESTAMP => "TimeStamp",
1265  MetadataSchema::MDFTYPE_FLAG => "Flag",
1266  MetadataSchema::MDFTYPE_TREE => "Tree",
1267  MetadataSchema::MDFTYPE_CONTROLLEDNAME => "ControlledName",
1268  MetadataSchema::MDFTYPE_OPTION => "Option",
1269  MetadataSchema::MDFTYPE_USER => "User",
1270  MetadataSchema::MDFTYPE_IMAGE => "Still Image",
1271  MetadataSchema::MDFTYPE_FILE => "File",
1272  MetadataSchema::MDFTYPE_URL => "Url",
1273  MetadataSchema::MDFTYPE_POINT => "Point",
1274  MetadataSchema::MDFTYPE_REFERENCE => "Reference"
1275  );
1276  public static $FieldTypePHPEnums = array(
1277  "Text" => MetadataSchema::MDFTYPE_TEXT,
1278  "Paragraph" => MetadataSchema::MDFTYPE_PARAGRAPH,
1279  "Number" => MetadataSchema::MDFTYPE_NUMBER,
1280  "Date" => MetadataSchema::MDFTYPE_DATE,
1281  "TimeStamp" => MetadataSchema::MDFTYPE_TIMESTAMP,
1282  "Flag" => MetadataSchema::MDFTYPE_FLAG,
1283  "Tree" => MetadataSchema::MDFTYPE_TREE,
1284  "ControlledName" => MetadataSchema::MDFTYPE_CONTROLLEDNAME,
1285  "Option" => MetadataSchema::MDFTYPE_OPTION,
1286  "User" => MetadataSchema::MDFTYPE_USER,
1287  "Still Image" => MetadataSchema::MDFTYPE_IMAGE,
1288  "File" => MetadataSchema::MDFTYPE_FILE,
1289  "Url" => MetadataSchema::MDFTYPE_URL,
1290  "Point" => MetadataSchema::MDFTYPE_POINT,
1291  "Reference" => MetadataSchema::MDFTYPE_REFERENCE
1292  );
1293 
1294  public static $UpdateTypes = array(
1295  MetadataField::UPDATEMETHOD_NOAUTOUPDATE => "Do not update automatically",
1296  MetadataField::UPDATEMETHOD_ONRECORDCREATE => "Update on record creation",
1297  MetadataField::UPDATEMETHOD_BUTTON => "Provide an update button",
1298  MetadataField::UPDATEMETHOD_ONRECORDEDIT => "Update when record is edited",
1299  MetadataField::UPDATEMETHOD_ONRECORDCHANGE => "Update when record is changed"
1300  );
1301 
1315  static function Create($SchemaId, $FieldType, $FieldName,
1316  $Optional = NULL, $DefaultValue = NULL)
1317  {
1318  # error out if field type is bad
1319  if (empty(MetadataField::$FieldTypeDBEnums[$FieldType]))
1320  {
1321  throw new InvalidArgumentException("Bad field type (".$FieldType.").");
1322  }
1323 
1324  # error out if field name is duplicate
1325  $DB = new Database();
1326  $FieldName = trim($FieldName);
1327  $DuplicateCount = $DB->Query(
1328  "SELECT COUNT(*) AS RecordCount FROM MetadataFields"
1329  ." WHERE FieldName = '".addslashes($FieldName)."'"
1330  ." AND SchemaId = ".intval($SchemaId),
1331  "RecordCount");
1332  if ($DuplicateCount > 0)
1333  {
1334  throw new InvalidArgumentException("Duplicate field name (".$FieldName.").");
1335  }
1336 
1337  # grab current user ID
1338  $UserId = $GLOBALS["G_User"]->Get("UserId");
1339 
1340  # normalize schema ID
1341  $Schema = new MetadataSchema($SchemaId);
1342  $SchemaId = $Schema->Id();
1343 
1344  # use schema privileges as starting privilege values
1345  $AuthorPrivs = $Schema->AuthoringPrivileges();
1346  $EditPrivs = $Schema->EditingPrivileges();
1347  $ViewPrivs = $Schema->ViewingPrivileges();
1348  $PreviewPrivs = $Schema->ViewingPrivileges();
1349 
1350  # lock DB tables and get next temporary field ID
1351  $DB->Query("LOCK TABLES MetadataFields WRITE");
1352  $FieldId = $Schema->GetNextTempItemId();
1353 
1354  # add field to MDF table in database
1355  $DB->Query("INSERT INTO MetadataFields"
1356  ." (FieldId, SchemaId, FieldName, FieldType, LastModifiedById,"
1357  ." Optional, AuthoringPrivileges, EditingPrivileges,"
1358  ." ViewingPrivileges, PreviewingPrivileges)"
1359  ." VALUES ("
1360  .intval($FieldId).", "
1361  .intval($SchemaId).","
1362  ." '".addslashes($FieldName)."',"
1363  ." '".MetadataField::$FieldTypeDBEnums[$FieldType]."', "
1364  .intval($UserId).", "
1365  .($Optional ? "1" : "0").","
1366  ."'".mysql_escape_string($AuthorPrivs->Data())."',"
1367  ."'".mysql_escape_string($EditPrivs->Data())."',"
1368  ."'".mysql_escape_string($ViewPrivs->Data())."',"
1369  ."'".mysql_escape_string($PreviewPrivs->Data())."')");
1370 
1371  # release DB tables
1372  $DB->Query("UNLOCK TABLES");
1373 
1374  # load field object
1375  $Field = new MetadataField($FieldId);
1376 
1377  # set field defaults
1378  $Field->SetDefaults();
1379 
1380  # set the default value if specified
1381  if ($DefaultValue !== NULL)
1382  {
1383  $Field->DefaultValue($DefaultValue);
1384  }
1385 
1386  # return newly-constructed field to caller
1387  return $Field;
1388  }
1389 
1396  function __construct($FieldId)
1397  {
1398  # assume everything will be okay
1399  $this->ErrorStatus = MetadataSchema::MDFSTAT_OK;
1400 
1401  # retrieve field info from database
1402  $this->DB = new Database();
1403  $Result = $this->DB->Query("SELECT * FROM MetadataFields"
1404  ." WHERE FieldId = ".intval($FieldId));
1405  if ($this->DB->NumRowsSelected() == 0)
1406  {
1407  throw new InvalidArgumentException("Invalid metadata field ID ("
1408  .$FieldId.")");
1409  }
1410  $Row = $this->DB->FetchRow();
1411  $this->DBFields = $Row;
1412  $this->Id = $FieldId;
1413 
1414  # if privileges have not yet been initialized
1415  if (!strlen($this->DBFields["AuthoringPrivileges"]))
1416  {
1417  # set default values for privileges from metadata schema
1418  $Schema = new MetadataSchema($Row["SchemaId"]);
1419  $this->AuthoringPrivileges($Schema->AuthoringPrivileges());
1420  $this->EditingPrivileges($Schema->EditingPrivileges());
1421  $this->ViewingPrivileges($Schema->ViewingPrivileges());
1422  $this->PreviewingPrivileges($Schema->ViewingPrivileges());
1423  }
1424  else
1425  {
1426  # set privileges from stored values
1427  $this->AuthoringPrivileges = new PrivilegeSet(
1428  $Row["AuthoringPrivileges"]);
1429  $this->EditingPrivileges = new PrivilegeSet(
1430  $Row["EditingPrivileges"]);
1431  $this->ViewingPrivileges = new PrivilegeSet(
1432  $Row["ViewingPrivileges"]);
1433  $this->PreviewingPrivileges = new PrivilegeSet(
1434  $Row["PreviewingPrivileges"]);
1435  }
1436 
1437  # set database column name
1438  $this->DBFields["DBFieldName"] =
1439  $this->NormalizeFieldNameForDB($this->DBFields["FieldName"]);
1440  }
1441 
1446  public static $FixedDefaults = array(
1447  "Label" => NULL,
1448  "Description" => NULL,
1449  "Instructions" => NULL,
1450  "Enabled" => TRUE,
1451  "Optional" => TRUE,
1452  "Editable" => TRUE,
1453  "AllowMultiple" => FALSE,
1454  "IncludeInKeywordSearch" => FALSE,
1455  "IncludeInAdvancedSearch" => FALSE,
1456  "IncludeInFacetedSearch" => FALSE,
1457  "IncludeInSortOptions" => TRUE,
1458  "IncludeInRecommender" => FALSE,
1459  "ParagraphRows" => 4,
1460  "ParagraphCols" => 50,
1461  "MinValue" => 1,
1462  "FlagOnLabel" => "On",
1463  "FlagOffLabel" => "Off",
1464  "DateFormat" => NULL,
1465  "RecommenderWeight" => 1,
1466  "MaxHeight" => 500,
1467  "MaxWidth" => 500,
1468  "MaxPreviewHeight" => 100,
1469  "MaxPreviewWidth" => 100,
1470  "MaxThumbnailHeight" => 50,
1471  "MaxThumbnailWidth" => 50,
1472  "DefaultAltText" => NULL,
1473  "UsesQualifiers" => FALSE,
1474  "HasItemLevelQualifiers" => FALSE,
1475  "ShowQualifiers" => FALSE,
1476  "DefaultQualifier" => NULL,
1477  "AllowHTML" => FALSE,
1478  "UseWysiwygEditor" => FALSE,
1479  "UseForOaiSets" => FALSE,
1480  "DisplayAsListForAdvancedSearch" => FALSE,
1481  "OptionListThreshold" => 25,
1482  "AjaxThreshold" => 50,
1483  "NumAjaxResults" => 50,
1484  "PointPrecision" => 8,
1485  "PointDecimalDigits" => 5,
1486  "UserPrivilegeRestrictions" => array(),
1487  "UpdateMethod" => "NoAutoUpdate",
1488  # 9999 is the default max value because default number field length is 4
1489  "MaxValue" => 9999);
1490 
1495  public static $TypeBasedDefaults = array(
1497  "DefaultValue" => NULL,
1498  "SearchWeight" => 1,
1499  "TextFieldSize" => 50,
1500  "MaxLength" => 100),
1502  "DefaultValue" => NULL,
1503  "SearchWeight" => 1,
1504  "TextFieldSize" => 50,
1505  "MaxLength" => 100),
1507  "DefaultValue" => NULL,
1508  "SearchWeight" => 1,
1509  "TextFieldSize" => 4,
1510  "MaxLength" => 100),
1512  "DefaultValue" => NULL,
1513  "SearchWeight" => 1,
1514  "TextFieldSize" => 10,
1515  "MaxLength" => 100),
1517  "DefaultValue" => NULL,
1518  "SearchWeight" => 1,
1519  "TextFieldSize" => 50,
1520  "MaxLength" => 100),
1522  "DefaultValue" => NULL,
1523  "SearchWeight" => 1,
1524  "TextFieldSize" => 50,
1525  "MaxLength" => 100),
1527  "DefaultValue" => NULL,
1528  "SearchWeight" => 1,
1529  "TextFieldSize" => 50,
1530  "MaxLength" => 100),
1532  "DefaultValue" => NULL,
1533  "SearchWeight" => 3,
1534  "TextFieldSize" => 50,
1535  "MaxLength" => 100),
1537  "DefaultValue" => NULL,
1538  "SearchWeight" => 3,
1539  "TextFieldSize" => 50,
1540  "MaxLength" => 100),
1542  "DefaultValue" => NULL,
1543  "SearchWeight" => 1,
1544  "TextFieldSize" => 50,
1545  "MaxLength" => 100),
1547  "DefaultValue" => NULL,
1548  "SearchWeight" => 1,
1549  "TextFieldSize" => 50,
1550  "MaxLength" => 100),
1552  "DefaultValue" => NULL,
1553  "SearchWeight" => 1,
1554  "TextFieldSize" => 50,
1555  "MaxLength" => 100),
1556  MetadataSchema::MDFTYPE_URL => array(
1557  "DefaultValue" => NULL,
1558  "SearchWeight" => 1,
1559  "TextFieldSize" => 50,
1560  "MaxLength" => 255),
1562  "DefaultValue" => array("X" => NULL, "Y" => NULL),
1563  "SearchWeight" => 1,
1564  "TextFieldSize" => 10,
1565  "MaxLength" => 100),
1567  "DefaultValue" => NULL,
1568  "SearchWeight" => 1,
1569  "TextFieldSize" => 50,
1570  "MaxLength" => 100));
1571 
1576  function SetDefaults()
1577  {
1578  # set defaults that are the same for every field
1579  foreach (self::$FixedDefaults as $Key => $Value)
1580  {
1581  $this->$Key($Value);
1582  }
1583 
1584  # set defaults that depend on the type of the field
1585  foreach (self::$TypeBasedDefaults[$this->Type()] as $Key => $Value)
1586  {
1587  $this->$Key($Value);
1588  }
1589 
1590  # tweak the update method if dealing with the date of record creation
1591  if ($this->Name() == "Date Of Record Creation")
1592  {
1593  $this->UpdateMethod("OnRecordCreate");
1594  }
1595  }
1596 
1597  # remove field from database (only for use by MetadataSchema object)
1598  function Drop()
1599  {
1600  # clear other database entries as appropriate for field type
1601  $DB = $this->DB;
1602  $DBFieldName = $this->DBFields["DBFieldName"];
1603  $Schema = new MetadataSchema($this->SchemaId());
1604  switch (MetadataField::$FieldTypePHPEnums[$this->DBFields["FieldType"]])
1605  {
1614  # remove field from resources table
1615  if ($DB->FieldExists("Resources", $DBFieldName))
1616  {
1617  $DB->Query("ALTER TABLE Resources DROP COLUMN `".$DBFieldName."`");
1618  }
1619  break;
1620 
1622  if ($DB->FieldExists("Resources", $DBFieldName."X"))
1623  {
1624  $DB->Query("ALTER TABLE Resources DROP COLUMN `".$DBFieldName."X`");
1625  $DB->Query("ALTER TABLE Resources DROP COLUMN `".$DBFieldName."Y`");
1626  }
1627  break;
1628 
1630  # remove fields from resources table
1631  if ($DB->FieldExists("Resources", $DBFieldName."Begin"))
1632  {
1633  $DB->Query("ALTER TABLE Resources DROP COLUMN `".$DBFieldName."Begin`");
1634  $DB->Query("ALTER TABLE Resources DROP COLUMN `".$DBFieldName."End`");
1635  $DB->Query("ALTER TABLE Resources DROP COLUMN `".$DBFieldName."Precision`");
1636  }
1637  break;
1638 
1640  $DB->Query("SELECT ClassificationId FROM Classifications "
1641  ."WHERE FieldId = ".$this->Id());
1642  $TempDB = new Database();
1643  while ($ClassificationId = $DB->FetchField("ClassificationId"))
1644  {
1645  # remove any resource / name intersections
1646  $TempDB->Query("DELETE FROM ResourceClassInts WHERE "
1647  ."ClassificationId = ".$ClassificationId);
1648 
1649  # remove controlled name
1650  $TempDB->Query("DELETE FROM Classifications WHERE "
1651  ."ClassificationId = ".$ClassificationId);
1652  }
1653  break;
1654 
1657  $DB->Query("SELECT ControlledNameId FROM ControlledNames "
1658  ."WHERE FieldId = ".$this->Id());
1659  $TempDB = new Database();
1660  while ($ControlledNameId = $DB->FetchField("ControlledNameId"))
1661  {
1662  # remove any resource / name intersections
1663  $TempDB->Query("DELETE FROM ResourceNameInts WHERE "
1664  ."ControlledNameId = ".$ControlledNameId);
1665 
1666  # remove any variant names
1667  $TempDB->Query("DELETE FROM VariantNames WHERE "
1668  ."ControlledNameId = ".$ControlledNameId);
1669 
1670  # remove controlled name
1671  $TempDB->Query("DELETE FROM ControlledNames WHERE "
1672  ."ControlledNameId = ".$ControlledNameId);
1673  }
1674  break;
1675 
1677  # for each file associated with this field
1678  $DB->Query("SELECT FileId FROM Files WHERE FieldId = '".$this->Id()."'");
1679  while ($FileId = $DB->FetchRow())
1680  {
1681  # delete file
1682  $File = new File(intval($FileId));
1683  $File->Delete();
1684  }
1685  break;
1686 
1688  # remove any resource references for the field
1689  $DB->Query("
1690  DELETE FROM ReferenceInts
1691  WHERE FieldId = '".addslashes($this->Id())."'");
1692  break;
1693  }
1694 
1695  # remove field from database
1696  $DB->Query("DELETE FROM MetadataFields "
1697  ."WHERE FieldId = '".$this->DBFields["FieldId"]."'");
1698 
1699  # remove any qualifier associations
1700  $DB->Query("DELETE FROM FieldQualifierInts WHERE MetadataFieldId = '"
1701  .$this->DBFields["FieldId"]."'");
1702 
1703  # get the order objects the field is part of
1704  foreach (MetadataFieldOrder::GetOrdersForSchema($Schema) as $Order)
1705  {
1706  # remove it if it's a direct descendant
1707  $Order->RemoveItem($this->Id(), "MetadataField");
1708 
1709  # also make sure to remove it if it's part of a group
1710  foreach ($Order->GetItemIds() as $Item)
1711  {
1712  if ($Item["Type"] == "MetadataFieldGroup")
1713  {
1714  $Group = new MetadataFieldGroup($Item["ID"]);
1715  $Group->RemoveItem($this->Id(), "MetadataField");
1716  }
1717  }
1718  }
1719  }
1720 
1721  # modify any database fields
1722  private function ModifyField($NewName = NULL, $NewType = NULL)
1723  {
1724  # grab old DB field name
1725  $OldDBFieldName = $this->DBFields["DBFieldName"];
1726  $OldFieldType = NULL;
1727 
1728  # if new field name supplied
1729  if ($NewName != NULL)
1730  {
1731  # cache the old name for options and controllednames below
1732  $OldName = $this->DBFields["FieldName"];
1733 
1734  # store new name
1735  $this->UpdateValue("FieldName", $NewName);
1736 
1737  # determine new DB field name
1738  $NewDBFieldName = $this->NormalizeFieldNameForDB($NewName);
1739 
1740  # store new database field name
1741  $this->DBFields["DBFieldName"] = $NewDBFieldName;
1742  }
1743  else
1744  {
1745  # set new field name equal to old field name
1746  $NewDBFieldName = $OldDBFieldName;
1747  }
1748 
1749  # if new type supplied
1750  if ($NewType != NULL)
1751  {
1752  # grab old field type
1753  $OldFieldType = MetadataField::$FieldTypePHPEnums[$this->DBFields["FieldType"]];
1754 
1755  # store new field type
1756  $this->UpdateValue("FieldType", MetadataField::$FieldTypeDBEnums[$NewType]);
1757  }
1758 
1759  # if this is not a temporary field
1760  if ($this->Id() >= 0)
1761  {
1762  # modify field in DB as appropriate for field type
1763  $DB = $this->DB;
1764  $FieldType = MetadataField::$FieldTypePHPEnums[$this->DBFields["FieldType"]];
1765  switch ($FieldType)
1766  {
1770  # alter field declaration in Resources table
1771  $DB->Query("ALTER TABLE Resources CHANGE COLUMN `"
1772  .$OldDBFieldName."` `"
1773  .$NewDBFieldName."` TEXT "
1774  .($this->DBFields["Optional"] ? "" : "NOT NULL"));
1775  break;
1776 
1779  # alter field declaration in Resources table
1780  $DB->Query("ALTER TABLE Resources CHANGE COLUMN `"
1781  .$OldDBFieldName."` `"
1782  .$NewDBFieldName."` INT "
1783  .($this->DBFields["Optional"] ? "" : "NOT NULL"));
1784  break;
1785 
1787  $Precision = $this->UpdateValue("PointPrecision",
1788  DB_NOVALUE);
1789  $Digits = $this->UpdateValue("PointDecimalDigits",
1790  DB_NOVALUE);
1791  $DB->Query("ALTER TABLE Resources CHANGE COLUMN "
1792  ."`".$OldDBFieldName."X` "
1793  ."`".$NewDBFieldName."X`".
1794  " DECIMAL(".$Precision.",".$Digits.")");
1795  $DB->Query("ALTER TABLE Resources CHANGE COLUMN "
1796  ."`".$OldDBFieldName."Y` "
1797  ."`".$NewDBFieldName."Y`".
1798  " DECIMAL(".$Precision.",".$Digits.")");
1799  break;
1800 
1802  # if DB field name has changed
1803  if ($NewDBFieldName != $OldDBFieldName)
1804  {
1805  # alter field declaration in Resources table
1806  $DB->Query("ALTER TABLE Resources CHANGE COLUMN `"
1807  .$OldDBFieldName."` `"
1808  .$NewDBFieldName."` TEXT");
1809  }
1810  break;
1811 
1813  # alter field declaration in Resources table
1814  $DB->Query("ALTER TABLE Resources CHANGE COLUMN `"
1815  .$OldDBFieldName."` `"
1816  .$NewDBFieldName."` INT"
1817  ." DEFAULT ".intval($this->DefaultValue()));
1818 
1819  # set any unset values to default
1820  $DB->Query("UPDATE Resources SET `".$NewDBFieldName
1821  ."` = ".intval($this->DefaultValue())
1822  ." WHERE `".$NewDBFieldName."` IS NULL");
1823  break;
1824 
1826  # if new type supplied and new type is different from old
1827  if (($NewType != NULL) && ($NewType != $OldFieldType))
1828  {
1829  # if old type was time stamp
1830  if ($OldFieldType == MetadataSchema::MDFTYPE_TIMESTAMP)
1831  {
1832  # change time stamp field in resources table to begin date
1833  $DB->Query("ALTER TABLE Resources CHANGE COLUMN `"
1834  .$OldDBFieldName."` `"
1835  .$NewDBFieldName."Begin` DATE "
1836  .($this->DBFields["Optional"] ? "" : "NOT NULL"));
1837 
1838  # add end date and precision fields
1839  $DB->Query("ALTER TABLE Resources ADD COLUMN `".$NewDBFieldName."End"
1840  ."` DATE");
1841  $DB->Query("ALTER TABLE Resources ADD COLUMN `".$NewDBFieldName."Precision`"
1842  ." INT ".($Optional ? "" : "NOT NULL"));
1843 
1844  # set precision to reflect time stamp content
1845  $DB->Query("UPDATE Resources SET `".$NewDBFieldName."Precision` = "
1846  .(DATEPRE_BEGINYEAR|DATEPRE_BEGINMONTH|DATEPRE_BEGINDAY));
1847  }
1848  else
1849  {
1850  exit("<br>ERROR: Attempt to convert metadata field to date from type other than timestamp<br>\n");
1851  }
1852  }
1853  else
1854  {
1855  # change name of fields
1856  $DB->Query("ALTER TABLE Resources CHANGE COLUMN `"
1857  .$OldDBFieldName."Begin` `"
1858  .$NewDBFieldName."Begin` DATE "
1859  .($this->DBFields["Optional"] ? "" : "NOT NULL"));
1860  $DB->Query("ALTER TABLE Resources CHANGE COLUMN `"
1861  .$OldDBFieldName."End` `"
1862  .$NewDBFieldName."End` DATE "
1863  .($this->DBFields["Optional"] ? "" : "NOT NULL"));
1864  $DB->Query("ALTER TABLE Resources CHANGE COLUMN `"
1865  .$OldDBFieldName."Precision` `"
1866  .$NewDBFieldName."Precision` INT "
1867  .($this->DBFields["Optional"] ? "" : "NOT NULL"));
1868  }
1869  break;
1870 
1872  # if new type supplied and new type is different from old
1873  if (($NewType != NULL) && ($NewType != $OldFieldType))
1874  {
1875  # if old type was date
1876  if ($OldFieldType == MetadataSchema::MDFTYPE_DATE)
1877  {
1878  # change begin date field in resource table to time stamp
1879  $DB->Query("ALTER TABLE Resources CHANGE COLUMN `"
1880  .$OldDBFieldName."Begin` `"
1881  .$NewDBFieldName."` DATETIME "
1882  .($this->DBFields["Optional"] ? "" : "NOT NULL"));
1883 
1884  # drop end date and precision fields
1885  $DB->Query("ALTER TABLE Resources DROP COLUMN `"
1886  .$OldDBFieldName."End`");
1887  $DB->Query("ALTER TABLE Resources DROP COLUMN `"
1888  .$OldDBFieldName."Precision`");
1889  }
1890  else
1891  {
1892  exit("<br>ERROR: Attempt to convert metadata field to time stamp from type other than date<br>\n");
1893  }
1894  }
1895  else
1896  {
1897  # change name of field
1898  $DB->Query("ALTER TABLE Resources CHANGE COLUMN `"
1899  .$OldDBFieldName."` `"
1900  .$NewDBFieldName."` DATETIME "
1901  .($this->DBFields["Optional"] ? "" : "NOT NULL"));
1902  }
1903  break;
1904 
1910  break;
1911  }
1912 
1913  # if qualifier DB field exists
1914  if ($DB->FieldExists("Resources", $OldDBFieldName."Qualifier"))
1915  {
1916  # rename qualifier DB field
1917  $DB->Query("ALTER TABLE Resources CHANGE COLUMN `"
1918  .$OldDBFieldName."Qualifier` `"
1919  .$NewDBFieldName."Qualifier` INT ");
1920  }
1921  }
1922  }
1923 
1924  # convenience functions to supply parameters to Database->UpdateValue()
1925  private function UpdateValue($FieldName, $NewValue)
1926  {
1927  return $this->DB->UpdateValue("MetadataFields", $FieldName, $NewValue,
1928  "FieldId = ".intval($this->DBFields["FieldId"]),
1929  $this->DBFields);
1930  }
1931  private function UpdateIntValue($FieldName, $NewValue)
1932  {
1933  return $this->DB->UpdateIntValue("MetadataFields", $FieldName, $NewValue,
1934  "FieldId = ".intval($this->DBFields["FieldId"]),
1935  $this->DBFields);
1936  }
1937  private function UpdateFloatValue($FieldName, $NewValue)
1938  {
1939  return $this->DB->UpdateFloatValue("MetadataFields", $FieldName, $NewValue,
1940  "FieldId = ".intval($this->DBFields["FieldId"]),
1941  $this->DBFields);
1942  }
1943  private function UpdateBoolValue($FieldName, $NewValue)
1944  {
1945  $NewValue = $this->TranslateStringToConstants($NewValue);
1946  return $this->DB->UpdateIntValue("MetadataFields", $FieldName, $NewValue,
1947  "FieldId = ".intval($this->DBFields["FieldId"]),
1948  $this->DBFields);
1949  }
1950  private function UpdateConstValue($FieldName, $NewValue, $ClassName=NULL)
1951  {
1952  $NewValue = $this->TranslateStringToConstants($NewValue, $ClassName);
1953  return $this->DB->UpdateIntValue("MetadataFields", $FieldName, $NewValue,
1954  "FieldId = ".intval($this->DBFields["FieldId"]),
1955  $this->DBFields);
1956  }
1957 
1958  # normalize field name for use as database field name
1959  private function NormalizeFieldNameForDB($Name)
1960  {
1961  return preg_replace("/[^a-z0-9]/i", "", $Name)
1962  .(($this->SchemaId() != MetadataSchema::SCHEMAID_DEFAULT)
1963  ? $this->SchemaId() : "");
1964  }
1965 
1966  # add any needed database fields and/or entries
1967  private function AddDatabaseFields()
1968  {
1969  # grab values for common use
1970  $DB = $this->DB;
1971  $FieldName = $this->Name();
1972  $DBFieldName = $this->DBFieldName();
1973  $Optional = $this->Optional();
1974  $DefaultValue = $this->DefaultValue();
1975 
1976  # set up field(s) based on field type
1977  switch ($this->Type())
1978  {
1982  # add field to resources table (if not already present)
1983  if (!$DB->FieldExists("Resources", $DBFieldName))
1984  {
1985  $DB->Query("ALTER TABLE Resources ADD COLUMN `".$DBFieldName
1986  ."` TEXT ".($Optional ? "" : "NOT NULL"));
1987  }
1988 
1989  # if default value supplied
1990  if ($DefaultValue != NULL)
1991  {
1992  # set all existing records to default value
1993  $DB->Query("UPDATE Resources SET `"
1994  .$DBFieldName."` = '".addslashes($DefaultValue)."'");
1995  }
1996  break;
1997 
1999  # add field to resources table (if not already present)
2000  if (!$DB->FieldExists("Resources", $DBFieldName))
2001  {
2002  $DB->Query("ALTER TABLE Resources ADD COLUMN `".$DBFieldName
2003  ."` INT ".($Optional ? "" : "NOT NULL"));
2004  }
2005 
2006  # if default value supplied
2007  if ($DefaultValue != NULL)
2008  {
2009  # set all existing records to default value
2010  $DB->Query("UPDATE Resources SET `"
2011  .$DBFieldName."` = '".addslashes($DefaultValue)."'");
2012  }
2013  break;
2014 
2016  if (!$DB->FieldExists("Resources", $DBFieldName."X"))
2017  {
2018  $Precision = $this->UpdateValue("PointPrecision",
2019  DB_NOVALUE);
2020  $Digits = $this->UpdateValue("PointDecimalDigits",
2021  DB_NOVALUE);
2022 
2023  $DB->Query("ALTER TABLE Resources ADD COLUMN `"
2024  .$DBFieldName."X`".
2025  " DECIMAL(".$Precision.",".$Digits.")");
2026  $DB->Query("ALTER TABLE Resources ADD COLUMN `"
2027  .$DBFieldName."Y`".
2028  " DECIMAL(".$Precision.",".$Digits.")");
2029  }
2030 
2031  break;
2033  # if field is not already present in database
2034  if (!$DB->FieldExists("Resources", $DBFieldName))
2035  {
2036  # add field to resources table
2037  $DB->Query("ALTER TABLE Resources ADD COLUMN `".$DBFieldName
2038  ."` INT DEFAULT ".intval($DefaultValue));
2039 
2040  # set all existing records to default value
2041  $DB->Query("UPDATE Resources SET `"
2042  .$DBFieldName."` = ".intval($DefaultValue));
2043  }
2044  break;
2045 
2047  # add field to resources table (if not already present)
2048  if (!$DB->FieldExists("Resources", $DBFieldName))
2049  {
2050  $DB->Query("ALTER TABLE Resources ADD COLUMN `".$DBFieldName
2051  ."` INT ".($Optional ? "" : "NOT NULL"));
2052  }
2053  break;
2054 
2056  # add fields to resources table (if not already present)
2057  if (!$DB->FieldExists("Resources", $DBFieldName))
2058  {
2059  $DB->Query("ALTER TABLE Resources ADD COLUMN `"
2060  .$DBFieldName."` TEXT");
2061  }
2062  break;
2063 
2065  # add fields to resources table (if not already present)
2066  if (!$DB->FieldExists("Resources", $DBFieldName))
2067  {
2068  $DB->Query("ALTER TABLE Resources ADD COLUMN `"
2069  .$DBFieldName."` INT");
2070  }
2071  break;
2072 
2074  # add fields to resources table (if not already present)
2075  if (!$DB->FieldExists("Resources", $DBFieldName."Begin"))
2076  {
2077  $DB->Query("ALTER TABLE Resources ADD COLUMN `".$DBFieldName."Begin`"
2078  ." DATE ".($Optional ? "" : "NOT NULL"));
2079  }
2080  if (!$DB->FieldExists("Resources", $DBFieldName."End"))
2081  {
2082  $DB->Query("ALTER TABLE Resources ADD COLUMN `".$DBFieldName."End`"
2083  ." DATE");
2084  }
2085  if (!$DB->FieldExists("Resources", $DBFieldName."Precision"))
2086  {
2087  $DB->Query("ALTER TABLE Resources ADD COLUMN `".$DBFieldName."Precision`"
2088  ." INT ".($Optional ? "" : "NOT NULL"));
2089  }
2090  break;
2091 
2093  # add fields to resources table (if not already present)
2094  if (!$DB->FieldExists("Resources", $DBFieldName))
2095  {
2096  $DB->Query("ALTER TABLE Resources ADD COLUMN `".$DBFieldName
2097  ."` DATETIME ".($Optional ? "" : "NOT NULL"));
2098  }
2099  break;
2100 
2105  break;
2106 
2107  default:
2108  exit("<br>ERROR: Attempt to add database fields for illegal metadata field type<br>\n");
2109  break;
2110  }
2111  }
2112 
2120  private function TranslateStringToConstants($CString, $ClassName = NULL)
2121  {
2122  # if not a string return value unchanged to caller
2123  if (!is_string($CString) || ($CString === DB_NOVALUE))
2124  {
2125  $ReturnValue = $CString;
2126  }
2127  # handle booleans as a special case
2128  elseif (strtoupper(trim($CString)) == "TRUE")
2129  {
2130  $ReturnValue = TRUE;
2131  }
2132  elseif (strtoupper(trim($CString)) == "FALSE")
2133  {
2134  $ReturnValue = FALSE;
2135  }
2136  else
2137  {
2138  # assume no values will be found
2139  $ReturnValue = NULL;
2140 
2141  # split apart any ORed-together values
2142  $Values = explode("|", $CString);
2143 
2144  # for each value found
2145  foreach ($Values as $Value)
2146  {
2147  # trim off any extraneous whitespace
2148  $Value = trim($Value);
2149 
2150  # add class name prefix to constant name if requested
2151  if ($ClassName) { $Value = $ClassName."::".$Value; }
2152 
2153  # if value corresponds to a constant
2154  if (defined($Value))
2155  {
2156  # add constant to return value
2157  $ReturnValue = ($ReturnValue === NULL)
2158  ? constant($Value)
2159  : ($ReturnValue | constant($Value));
2160  }
2161  }
2162 
2163  # if no corresponding constants were found
2164  if ($ReturnValue === NULL)
2165  {
2166  # return original value to caller
2167  $ReturnValue = $CString;
2168  }
2169  }
2170 
2171  # return result to caller
2172  return $ReturnValue;
2173  }
2174 
2175 }
const MDFSTAT_ILLEGALLABEL
DefaultQualifier($NewValue=DB_NOVALUE)
static $FieldTypeDBEnums
ViewingPrivileges(PrivilegeSet $NewValue=NULL)
Get/set privileges that allowing viewing values for this field.
static $FixedDefaults
The metadata field defaults that are the same for all field types.
const DATEPRE_BEGINDAY
Definition: Axis--Date.php:747
static $FieldTypeDBAllowedEnums
SetDefaults()
Set defaults values for the field.
Owner($NewValue=DB_NOVALUE)
Get/set field owner.
MaxPreviewHeight($NewValue=DB_NOVALUE)
Metadata schema (in effect a Factory class for MetadataField).
static $FieldTypePHPEnums
Status()
Get current error status of object.
IncludeInFacetedSearch($NewValue=DB_NOVALUE)
Get/set whether to include field in faceted search.
const UPDATEMETHOD_ONRECORDCHANGE
__construct($FieldId)
Object contstructor, used to load an existing metadata field.
Instructions($NewValue=DB_NOVALUE)
Get/set field instructions.
static Create($SchemaId, $FieldType, $FieldName, $Optional=NULL, $DefaultValue=NULL)
Create a new metadata field.
ValueUseCount($Value)
Check how many times a specific value is currently used for this field.
UseForOaiSets($NewValue=DB_NOVALUE)
AllowHTML($NewValue=DB_NOVALUE)
const USERISVALUE_UNSET
IncludeInRecommender($NewValue=DB_NOVALUE)
Get/set whether to include field in recommender system comparisons.
SQL database abstraction object with smart query caching.
const DB_NOVALUE
AuthoringPrivileges(PrivilegeSet $NewValue=NULL)
Get/set privileges that allowing authoring values for this field.
ShowQualifiers($NewValue=DB_NOVALUE)
FlagOffLabel($NewValue=DB_NOVALUE)
PointPrecision($NewValue=DB_NOVALUE)
OptionListThreshold($NewValue=DB_NOVALUE)
ViewingUserValue($NewValue=DB_NOVALUE)
const USERISVALUE_OR
const USERISVALUE_AND
AllowMultiple($NewValue=DB_NOVALUE)
Get/set whether to allow multiple values for field.
static $TypeBasedDefaults
The metadata field defaults that vary depending on the field type.
Description($NewValue=DB_NOVALUE)
Get/set field description.
EditingUserValue($NewValue=DB_NOVALUE)
MaxThumbnailHeight($NewValue=DB_NOVALUE)
SearchWeight($NewValue=DB_NOVALUE)
Set of privileges used to access resource information or other parts of the system.
HasItemLevelQualifiers($NewValue=DB_NOVALUE)
AssociateWithQualifier($Qualifier)
DEPRECATED METHOD.
AuthoringPrivilege($NewValue=DB_NOVALUE)
DefaultAltText($NewValue=DB_NOVALUE)
Class that builds on the foldering functionality to provide groups of metadata fields.
AjaxThreshold($NewValue=DB_NOVALUE)
Factory class for Qualifier.
const MDFTYPE_CONTROLLEDNAME
Viewable()
This function has been deprecated and should not be used.
CWIS-specific user factory class.
static $FieldTypeHumanEnums
A map of metadata field types to human-readable strings.
MaxPreviewWidth($NewValue=DB_NOVALUE)
const UPDATEMETHOD_ONRECORDEDIT
PHP
Definition: OAIClient.php:39
UserPrivilegeRestrictions($NewValue=DB_NOVALUE)
AddQualifier($Qualifier)
Associate qualifier with field.
SchemaId()
Get ID of schema for field.
IncludeInSortOptions($NewValue=DB_NOVALUE)
Get/set whether to include field in search result sort options.
DefaultValue($NewValue=DB_NOVALUE)
DisplayAsListForAdvancedSearch($NewValue=DB_NOVALUE)
TypeAsName()
Get type of field as string.
const DATEPRE_BEGINMONTH
Definition: Axis--Date.php:746
MaxLength($NewValue=DB_NOVALUE)
MaxValue($NewValue=DB_NOVALUE)
PointDecimalDigits($NewValue=DB_NOVALUE)
GetAllowedConversionTypes()
Get metadata field types that this field can be converted to.
Optional($NewValue=DB_NOVALUE)
Get/set whether a value is required for this field.
ViewingPrivilege($NewValue=DB_NOVALUE)
ParagraphRows($NewValue=DB_NOVALUE)
EditingPrivilege($NewValue=DB_NOVALUE)
RequiredBySPT($NewValue=DB_NOVALUE)
AuthoringUserIsValue($NewValue=DB_NOVALUE)
UsesQualifiers($NewValue=DB_NOVALUE)
MaxThumbnailWidth($NewValue=DB_NOVALUE)
Enabled($NewValue=DB_NOVALUE)
Get/set whether field is enabled.
Factory for manipulating ControlledName objects.
const UPDATEMETHOD_NOAUTOUPDATE
Object representing a locally-defined type of metadata field.
NumAjaxResults($NewValue=DB_NOVALUE)
TextFieldSize($NewValue=DB_NOVALUE)
ViewingUserIsValue($NewValue=DB_NOVALUE)
EnableOnOwnerReturn($NewValue=DB_NOVALUE)
FlagOnLabel($NewValue=DB_NOVALUE)
TreeBrowsingPrivilege($NewValue=DB_NOVALUE)
const UPDATEMETHOD_BUTTON
UseWysiwygEditor($NewValue=DB_NOVALUE)
EditingUserIsValue($NewValue=DB_NOVALUE)
GetPossibleValues($MaxNumberOfValues=NULL, $Offset=0)
const MDFSTAT_ILLEGALNAME
EditingPrivileges(PrivilegeSet $NewValue=NULL)
Get/set privileges that allowing editing values for this field.
static GetOrdersForSchema(MetadataSchema $Schema)
Get all of the orders associated with a schema.
GetIdForValue($Value)
RecommenderWeight($NewValue=DB_NOVALUE)
Label($NewLabel=DB_NOVALUE)
Get/set label for field.
Type($NewValue=DB_NOVALUE)
Get/set type of metadata field (enumerated value).
Id()
Get metadata field ID.
DBFieldName()
Get base name of database column used to store metadata field value.
ImagePreviewPrivilege($NewValue=DB_NOVALUE)
DateFormat($NewValue=DB_NOVALUE)
MaxWidth($NewValue=DB_NOVALUE)
MaxHeight($NewValue=DB_NOVALUE)
const UPDATEMETHOD_ONRECORDCREATE
const MDFSTAT_DUPLICATENAME
Factory for producing and manipulating Classification objects.
PreviewingPrivileges(PrivilegeSet $NewValue=NULL)
Get/set privileges that allowing previewing values for this field.
ParagraphCols($NewValue=DB_NOVALUE)
UnassociateWithQualifier($QualifierIdOrObject)
Class representing a stored (usually uploaded) file.
Definition: File.php:13
IncludeInKeywordSearch($NewValue=DB_NOVALUE)
Get/set whether to include field in keyword search.
Editable($NewValue=DB_NOVALUE)
Get/set whether this field is editable.
IsTempItem($NewSetting=NULL)
Get/set whether field is temporary instance.
Name($NewName=DB_NOVALUE)
Get/set name of field.
IncludeInAdvancedSearch($NewValue=DB_NOVALUE)
Get/set whether to include field in advanced search.
GetDisplayName()
Get display name for field.
MinValue($NewValue=DB_NOVALUE)
AuthoringUserValue($NewValue=DB_NOVALUE)
UpdateMethod($NewValue=DB_NOVALUE)
Get/set method by which field is updated.