CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

MetadataFieldOrder.php
Go to the documentation of this file.
1 <?PHP
2 #
3 # FILE: MetadataFieldOrder.php
4 #
5 # Part of the Collection Workflow Integration System (CWIS)
6 # Copyright 2013-2016 Edward Almasy and Internet Scout Research Group
7 # http://scout.wisc.edu/cwis/
8 #
9
14 class MetadataFieldOrder extends Folder
15 {
16
21 const DEFAULT_FOLDER_NAME = "FieldOrder";
22
28 public function __construct($Id)
29 {
30 # being loading by calling the superclass method
31 parent::__construct($Id);
32
33 # create a class-wide database
34 $this->Database = new Database();
35
36 # query for order associations from the database
37 $this->Database->Query("
38 SELECT * FROM MetadataFieldOrders
39 WHERE OrderId = '".addslashes($Id)."'");
40
41 # the ID is invalid
42 if ($this->Database->NumRowsSelected() < 1)
43 {
44 throw new Exception("Unknown metadata field order ID");
45 }
46
47 # fetch the data
48 $Row = $this->Database->FetchRow();
49
50 # set the values
51 $this->SchemaId = $Row["SchemaId"];
52 $this->OrderName = $Row["OrderName"];
53 }
54
61 public function SchemaId()
62 {
63 return $this->SchemaId;
64 }
65
70 public function OrderName()
71 {
72 return $this->OrderName;
73 }
74
80 public function Delete()
81 {
82 # remove the order from the orders associated with schemas
83 $this->Database->Query("
84 DELETE FROM MetadataFieldOrders
85 WHERE OrderId = '".addslashes($this->Id())."'");
86
87 # remove the folder by calling the superclass method
88 parent::Delete();
89 }
90
94 public function MendIssues()
95 {
96 $Schema = new MetadataSchema($this->SchemaId);
97
98 # get all the fields including disabled fields but excluding temp fields
99 $Fields = $Schema->GetFields(NULL, NULL, TRUE);
100
101 foreach ($Fields as $Field)
102 {
103 # add the field if it isn't already in the order
104 if (!$this->ItemInOrder($Field))
105 {
106 $this->AppendItem($Field->Id(), "MetadataField");
107 }
108 }
109 }
110
115 public function GetItems()
116 {
117 $ItemIds = $this->GetItemIds();
118 $Items = array();
119
120 foreach ($ItemIds as $Info)
121 {
122 try
123 {
124 $Items[] = new $Info["Type"]($Info["ID"]);
125 }
126
127 # skip invalid fields
128 catch (InvalidArgumentException $Exception)
129 {
130 continue;
131 }
132 }
133
134 return $Items;
135 }
136
142 public function CreateGroup($Name)
143 {
144 $FolderFactory = new FolderFactory();
145
146 # create the new group
147 $Folder = $FolderFactory->CreateMixedFolder($Name);
148 $Group = new MetadataFieldGroup($Folder->Id());
149
150 # and add it to this ordering
151 $this->AppendItem($Group->Id(), "MetadataFieldGroup");
152
153 return $Group;
154 }
155
161 public function DeleteGroup(MetadataFieldGroup $Group)
162 {
163 if ($this->ContainsItem($Group->Id(), "MetadataFieldGroup"))
164 {
165 $this->MoveFieldsToOrder($Group);
166 $this->RemoveItem($Group->Id(), "MetadataFieldGroup");
167 }
168 }
169
174 public function GetFields()
175 {
176 $Fields = array();
177
178 foreach ($this->GetItems() as $Item)
179 {
180 # add fields to the list
181 if ($Item instanceof MetadataField)
182 {
183 $Fields[$Item->Id()] = $Item;
184 }
185
186 # add fields of groups to the list
187 else if ($Item instanceof MetadataFieldGroup)
188 {
189 foreach ($Item->GetFields() as $Field)
190 {
191 $Fields[$Field->Id()] = $Field;
192 }
193 }
194 }
195
196 return $Fields;
197 }
198
203 public function GetGroups()
204 {
205 $ItemIds = $this->GetItemIds();
206 $GroupIds = array_filter($ItemIds, array($this, "GroupFilterCallback"));
207
208 $Groups = array();
209
210 # transform group info to group objects
211 foreach ($GroupIds as $GroupId)
212 {
213 try
214 {
215 $Groups[$GroupId["ID"]] = new $GroupId["Type"]($GroupId["ID"]);
216 }
217 catch (Exception $Exception)
218 {
219 # (moving to next item just to avoid empty catch statement)
220 continue;
221 }
222 }
223
224 return $Groups;
225 }
226
235 public function MoveItemUp($Item, $Filter=NULL)
236 {
237 # make sure the item is a field or group
238 if (!$this->IsFieldOrGroup($Item))
239 {
240 throw new Exception("Item must be a field or group");
241 }
242
243 # make sure the item is in the order
244 if (!$this->ItemInOrder($Item))
245 {
246 throw new Exception("Item must exist in the ordering");
247 }
248
249 # make sure the filter is callable if set
250 if (!is_null($Filter) && !is_callable($Filter))
251 {
252 throw new Exception("Filter callback must be callable");
253 }
254
255 $ItemType = $this->GetItemType($Item);
256 $Enclosure = $this->GetEnclosure($Item);
257 $EnclosureType = $this->GetItemType($Enclosure);
258 $Previous = $this->GetSiblingItem($Item, -1, $Filter);
259 $PreviousId = $this->GetItemId($Previous);
260 $PreviousType = $this->GetItemType($Previous);
261
262 # determine if the item is at the top of the list
263 $ItemAtTop = is_null($Previous);
264
265 # determine if a field needs to be moved into a group
266 $FieldToGroup = $ItemType == "MetadataField";
267 $FieldToGroup = $FieldToGroup && $EnclosureType == "MetadataFieldOrder";
268 $FieldToGroup = $FieldToGroup && $PreviousType == "MetadataFieldGroup";
269
270 # determine if a field needs to be moved out of a group
271 $FieldToOrder = $ItemType == "MetadataField";
272 $FieldToOrder = $FieldToOrder && $EnclosureType == "MetadataFieldGroup";
273 $FieldToOrder = $FieldToOrder && $ItemAtTop;
274
275 # move a field into a group if necessary
276 if ($FieldToGroup)
277 {
278 $this->MoveFieldToGroup($Previous, $Item, "append");
279 }
280
281 # or move a field from a group to the order if necessary
282 else if ($FieldToOrder)
283 {
284 $this->MoveFieldToOrder($Enclosure, $Item, "before");
285 }
286
287 # otherwise just move the item up if not at the top of the list
288 else if (!$ItemAtTop)
289 {
290 $this->MoveItemAfter($Item, $Previous);
291 }
292 }
293
302 public function MoveItemDown($Item, $Filter=NULL)
303 {
304 # make sure the item is a field or group
305 if (!$this->IsFieldOrGroup($Item))
306 {
307 throw new Exception("Item must be a field or group");
308 }
309
310 # make sure the item is in the order
311 if (!$this->ItemInOrder($Item))
312 {
313 throw new Exception("Item must exist in the ordering");
314 }
315
316 # make sure the filter is callable if set
317 if (!is_null($Filter) && !is_callable($Filter))
318 {
319 throw new Exception("Filter callback must be callable");
320 }
321
322 $ItemType = $this->GetItemType($Item);
323 $Enclosure = $this->GetEnclosure($Item);
324 $EnclosureType = $this->GetItemType($Enclosure);
325 $Next = $this->GetSiblingItem($Item, 1, $Filter);
326 $NextId = $this->GetItemId($Next);
327 $NextType = $this->GetItemType($Next);
328
329 # determine if the item is at the bottom of the list
330 $ItemAtBottom = is_null($Next);
331
332 # determine if a field needs to be moved into a group
333 $FieldToGroup = $ItemType == "MetadataField";
334 $FieldToGroup = $FieldToGroup && $EnclosureType == "MetadataFieldOrder";
335 $FieldToGroup = $FieldToGroup && $NextType == "MetadataFieldGroup";
336
337 # determine if a field needs to be moved out of a group
338 $FieldToOrder = $ItemType == "MetadataField";
339 $FieldToOrder = $FieldToOrder && $EnclosureType == "MetadataFieldGroup";
340 $FieldToOrder = $FieldToOrder && $ItemAtBottom;
341
342 # move a field into a group if necessary
343 if ($FieldToGroup)
344 {
345 $this->MoveFieldToGroup($Next, $Item, "prepend");
346 }
347
348 # or move a field from a group to the order if necessary
349 else if ($FieldToOrder)
350 {
351 $this->MoveFieldToOrder($Enclosure, $Item, "after");
352 }
353
354 # otherwise just move the item down if not at the bottom
355 else if (!$ItemAtBottom)
356 {
357 $this->MoveItemAfter($Next, $Item);
358 }
359 }
360
367 public function MoveItemToTop($Item)
368 {
369 # make sure the item is either a field or group
370 if (!$this->IsFieldOrGroup($Item))
371 {
372 throw new Exception("Item must be a either field or group");
373 }
374
375 # make sure the item is in the order
376 if (!$this->ItemInOrder($Item))
377 {
378 throw new Exception("Item must exist in the ordering");
379 }
380
381 $OrderId = $this->GetItemId($this);
382 $OrderType = $this->GetItemType($this);
383 $ItemId = $this->GetItemId($Item);
384 $ItemType = $this->GetItemType($Item);
385 $ItemEnclosure = $this->GetEnclosure($Item);
386 $ItemEnclosureId = $this->GetItemId($ItemEnclosure);
387 $ItemEnclosureType = $this->GetItemType($ItemEnclosure);
388
389 $SameEnclosureId = $OrderId == $ItemEnclosureId;
390 $SameEnclosureType = $OrderType == $ItemEnclosureType;
391
392 # remove the item from its enclosure if necessary
393 if (!$SameEnclosureId || !$SameEnclosureType)
394 {
395 $ItemEnclosure->RemoveItem($ItemId, $ItemType);
396 }
397
398 # move the item to the top of the order
399 $this->PrependItem($ItemId, $ItemType);
400 }
401
408 public function MoveFieldToTopOfGroup(
409 MetadataFieldGroup $Group,
410 MetadataField $Field)
411 {
412 # make sure the items are in the order
413 if (!$this->ItemInOrder($Group) || !$this->ItemInOrder($Field))
414 {
415 throw new Exception("Item must exist in the ordering");
416 }
417
418 $GroupId = $this->GetItemId($Group);
419 $GroupType = $this->GetItemType($Group);
420 $FieldId = $this->GetItemId($Field);
421 $FieldType = $this->GetItemType($Field);
422 $FieldEnclosure = $this->GetEnclosure($Field);
423 $FieldEnclosureId = $this->GetItemId($FieldEnclosure);
424 $FieldEnclosureType = $this->GetItemType($FieldEnclosure);
425
426 $SameEnclosureId = $GroupId == $FieldEnclosureId;
427 $SameEnclosureType = $GroupType == $FieldEnclosureType;
428
429 # remove the item from its enclosure if necessary
430 if (!$SameEnclosureId || !$SameEnclosureType)
431 {
432 $FieldEnclosure->RemoveItem($FieldId, $FieldType);
433 }
434
435 # move the item to the top of the group
436 $Group->PrependItem($FieldId, $FieldType);
437 }
438
447 public function MoveItemAfter($Target, $Item)
448 {
449 # make sure the items are either a field or group
450 if (!$this->IsFieldOrGroup($Target) || !$this->IsFieldOrGroup($Item))
451 {
452 throw new Exception("Items must be a either field or group");
453 }
454
455 # make sure the items are in the order
456 if (!$this->ItemInOrder($Target) || !$this->ItemInOrder($Item))
457 {
458 throw new Exception("Items must exist in the ordering");
459 }
460
461 $TargetId = $this->GetItemId($Target);
462 $TargetType = $this->GetItemType($Target);
463 $ItemId = $this->GetItemId($Item);
464 $ItemType = $this->GetItemType($Item);
465 $TargetEnclosure = $this->GetEnclosure($Target);
466 $TargetEnclosureId = $this->GetItemId($TargetEnclosure);
467 $TargetEnclosureType = $this->GetItemType($TargetEnclosure);
468 $ItemEnclosure = $this->GetEnclosure($Item);
469 $ItemEnclosureId = $this->GetItemId($ItemEnclosure);
470 $ItemEnclosureType = $this->GetItemType($ItemEnclosure);
471
472 $TargetInGroup = $TargetEnclosure instanceof MetadataFieldGroup;
473 $ItemIsField = $Item instanceof MetadataField;
474
475 # make sure only fields are placed in groups
476 if ($TargetInGroup && !$ItemIsField)
477 {
478 throw new Exception("Only fields can go into field groups");
479 }
480
481 $SameEnclosureId = $TargetEnclosureId == $ItemEnclosureId;
482 $SameEnclosureType = $TargetEnclosureType == $ItemEnclosureType;
483
484 # move a field into a group if necessary
485 if (!$SameEnclosureId || !$SameEnclosureType)
486 {
487 $ItemEnclosure->RemoveItem($ItemId, $ItemType);
488 }
489
490 # move the item after the target
491 $TargetEnclosure->InsertItemAfter(
492 $TargetId,
493 $ItemId,
494 $TargetType,
495 $ItemType);
496 }
497
503 public function ItemInOrder($Item)
504 {
505 # the item would have to be a field or group to be in the order
506 if (!$this->IsFieldOrGroup($Item))
507 {
508 return FALSE;
509 }
510
511 $ItemId = $this->GetItemId($Item);
512 $ItemType = $this->GetItemType($Item);
513
514 # if the item is in the order, i.e., not in a group
515 if ($this->ContainsItem($ItemId, $ItemType))
516 {
517 return TRUE;
518 }
519
520 # the item is in one of the groups, so search each one for it
521 foreach ($this->GetGroups() as $Group)
522 {
523 if ($Group->ContainsItem($ItemId, $ItemType))
524 {
525 return TRUE;
526 }
527 }
528
529 # the item was not found
530 return FALSE;
531 }
532
543 public static function Create(
544 MetadataSchema $Schema,
545 $Name,
546 array $FieldOrder=array())
547 {
548 $ExistingOrders = self::GetOrdersForSchema($Schema);
549
550 # remove existing orders with the same name
551 if (array_key_exists($Name, $ExistingOrders))
552 {
553 $ExistingOrders[$Name]->Delete();
554 }
555
556 # create the folder
557 $FolderFactory = new FolderFactory();
558 $Folder = $FolderFactory->CreateMixedFolder(self::DEFAULT_FOLDER_NAME);
559
560 # get all the fields including disabled fields but excluding temp fields
561 $Fields = $Schema->GetFields(NULL, NULL, TRUE);
562
563 # first, add each field from the given order
564 foreach ($FieldOrder as $FieldId)
565 {
566 # skip invalid field IDs
567 if (!array_key_exists($FieldId, $Fields))
568 {
569 continue;
570 }
571
572 # remove the field from the array of fields so that we'll know after
573 # looping which fields weren't added
574 unset($Fields[$FieldId]);
575
576 # add the metadata field to the folder
577 $Folder->AppendItem($FieldId, "MetadataField");
578 }
579
580 # finally, add any remaining fields that weren't removed in the loop
581 # above
582 foreach ($Fields as $FieldId => $Field)
583 {
584 $Folder->AppendItem($FieldId, "MetadataField");
585 }
586
587 $Database = new Database();
588
589 # associate the order with the schema in the database
590 $Database->Query("
591 INSERT INTO MetadataFieldOrders
592 SET SchemaId = '".addslashes($Schema->Id())."',
593 OrderId = '".addslashes($Folder->Id())."',
594 OrderName = '".addslashes($Name)."'");
595
596 # reconstruct the folder as a metadata schema order object and return
597 return new MetadataFieldOrder($Folder->Id());
598 }
599
608 public static function GetOrderForSchema(MetadataSchema $Schema, $Name)
609 {
610 return self::GetOrderForSchemaId($Schema->Id(), $Name);
611 }
612
621 public static function GetOrderForSchemaId($SchemaId, $Name)
622 {
623 $Orders = self::GetOrdersForSchemaId($SchemaId);
624
625 # return NULL if the order doesn't exist
626 if (!array_key_exists($Name, $Orders))
627 {
628 return NULL;
629 }
630
631 # return the order
632 return $Orders[$Name];
633 }
634
641 public static function GetOrdersForSchema(MetadataSchema $Schema)
642 {
643 return self::GetOrdersForSchemaId($Schema->Id());
644 }
645
652 public static function GetOrdersForSchemaId($SchemaId)
653 {
654 $Orders = array();
655 $Database = new Database();
656
657 # query the database for the orders associated with the schema
658 $Database->Query("
659 SELECT * FROM MetadataFieldOrders
660 WHERE SchemaId = '".addslashes($SchemaId)."'");
661
662 # loop through each found record
663 foreach ($Database->FetchRows() as $Row)
664 {
665 try
666 {
667 # construct an object using the ID and add it to the array
668 $Orders[$Row["OrderName"]] = new MetadataFieldOrder($Row["OrderId"]);
669 }
670
671 # remove invalid orders when encountered
672 catch (Exception $Exception)
673 {
674 $Database->Query("
675 DELETE FROM MetadataFieldOrders
676 WHERE OrderId = '".addslashes($Row["OrderId"])."'");
677 }
678 }
679
680 return $Orders;
681 }
682
688 protected function IsFieldOrGroup($Item)
689 {
690 if ($Item instanceof MetadataField)
691 {
692 return TRUE;
693 }
694
695 if ($Item instanceof MetadataFieldGroup)
696 {
697 return TRUE;
698 }
699
700 return FALSE;
701 }
702
708 protected function GetItemId($Item)
709 {
710 return is_object($Item) ? $Item->Id() : NULL;
711 }
712
718 protected function GetItemType($Item)
719 {
720 return is_object($Item) ? get_class($Item) : NULL;
721 }
722
729 protected function GroupFilterCallback($Item)
730 {
731 return $Item["Type"] == "MetadataFieldGroup";
732 }
733
741 protected function GetEnclosure($Item)
742 {
743 $ItemId = $this->GetItemId($Item);
744 $ItemType = $this->GetItemType($Item);
745
746 # the item is in the order, i.e., not in a group
747 if ($this->ContainsItem($ItemId, $ItemType))
748 {
749 return $this;
750 }
751
752 # the item is in one of the groups, so search each one for it
753 foreach ($this->GetGroups() as $Group)
754 {
755 if ($Group->ContainsItem($ItemId, $ItemType))
756 {
757 return $Group;
758 }
759 }
760
761 # the item was not found
762 return NULL;
763 }
764
772 protected function GetSiblingItem($Item, $Offset, $Filter=NULL)
773 {
774 $Id = $this->GetItemId($Item);
775 $Type = $this->GetItemType($Item);
776 $Sibling = NULL;
777
778 # the sibling is in the order, i.e., not in a group
779 if ($this->ContainsItem($Id, $Type))
780 {
781 return $this->FindSiblingItem($this, $Item, $Offset, $Filter);
782 }
783
784 # otherwise search for it in the groups
785 foreach ($this->GetGroups() as $Group)
786 {
787 if ($Group->ContainsItem($Id, $Type))
788 {
789 try
790 {
791 $Sibling = $this->FindSiblingItem(
792 $Group,
793 $Item,
794 $Offset,
795 $Filter);
796
797 if ($Sibling)
798 {
799 return $Sibling;
800 }
801 }
802 catch (Exception $Exception)
803 {
804 # (moving to next item just to avoid empty catch statement)
805 continue;
806 }
807
808 break;
809 }
810 }
811
812 return NULL;
813 }
814
824 protected function FindSiblingItem($Enclosure, $Item, $Offset, $Filter=NULL)
825 {
826 $ItemIds = $Enclosure->GetItemIds();
827
828 # filter items if necessary
829 if (is_callable($Filter))
830 {
831 $ItemIds = array_filter($ItemIds, $Filter);
832
833 # maintain continuous indices
834 ksort($ItemIds);
835 $ItemIds = array_values($ItemIds);
836 }
837
838 $Id = $this->GetItemId($Item);
839 $Type = $this->GetItemType($Item);
840 $Index = array_search(array("ID" => $Id, "Type" => $Type), $ItemIds);
841
842 if (!is_null($Index) && array_key_exists($Index+$Offset, $ItemIds))
843 {
844 $SiblingInfo = $ItemIds[$Index+$Offset];
845 return new $SiblingInfo["Type"]($SiblingInfo["ID"]);
846 }
847
848 return NULL;
849 }
850
858 protected function MoveFieldToGroup(
859 MetadataFieldGroup $Group,
860 MetadataField $Field,
861 $Placement)
862 {
863 # determine which action to use based on the placement value
864 $Action = $Placement == "prepend" ? "PrependItem" : "AppendItem";
865
866 $GroupId = $this->GetItemId($Group);
867 $FieldId = $this->GetItemId($Field);
868
869 $OrderHasGroup = $this->ContainsItem($GroupId, "MetadataFieldGroup");
870 $OrderHasField = $this->ContainsItem($FieldId, "MetadataField");
871
872 # make sure the field and group are in the order before editing
873 if ($OrderHasGroup && $OrderHasField)
874 {
875 $this->RemoveItem($FieldId, "MetadataField");
876 $Group->$Action($FieldId, "MetadataField");
877 }
878 }
879
887 protected function MoveFieldToOrder(
888 MetadataFieldGroup $Group,
889 MetadataField $Field,
890 $Placement)
891 {
892 # determine which action to use based on the placement value
893 $Action = $Placement == "before" ? "InsertItemBefore" : "InsertItemAfter";
894
895 $GroupId = $this->GetItemId($Group);
896 $FieldId = $this->GetItemId($Field);
897
898 $OrderHasGroup = $this->ContainsItem($GroupId, "MetadataFieldGroup");
899 $GroupHasField = $Group->ContainsItem($FieldId, "MetadataField");
900
901 # make sure the field is in the group and the group is in the order
902 if ($OrderHasGroup && $GroupHasField)
903 {
904 $Group->RemoveItem($FieldId, "MetadataField");
905 $this->$Action(
906 $GroupId,
907 $FieldId,
908 "MetadataFieldGroup",
909 "MetadataField");
910 }
911 }
912
918 protected function MoveFieldsToOrder(MetadataFieldGroup $Group)
919 {
920 $ItemIds = $Group->GetItemIds();
921 $PreviousItemId = $Group->Id();
922 $PreviousItemType = "MetadataFieldGroup";
923
924 foreach ($ItemIds as $ItemInfo)
925 {
926 $ItemId = $ItemInfo["ID"];
927 $ItemType = $ItemInfo["Type"];
928
929 $this->InsertItemAfter(
930 $PreviousItemId,
931 $ItemId,
932 $PreviousItemType,
933 $ItemType);
934
935 $PreviousItemId = $ItemId;
936 $PreviousItemType = $ItemType;
937 }
938 }
939
943 protected $Database;
944
949 protected $SchemaId;
950
954 protected $OrderName;
955 }
956
MetadataFieldOrder\MoveFieldToOrder
MoveFieldToOrder(MetadataFieldGroup $Group, MetadataField $Field, $Placement)
Move the field with the given ID from the group with the given ID to the order, optionally specifying...
Definition: MetadataFieldOrder.php:887
MetadataFieldOrder\MoveFieldsToOrder
MoveFieldsToOrder(MetadataFieldGroup $Group)
Move all the metadata fields out of the given metadata field group and into the main order...
Definition: MetadataFieldOrder.php:918
MetadataFieldOrder\DEFAULT_FOLDER_NAME
const DEFAULT_FOLDER_NAME
The default name given to the folders that are really metadata field orders.
Definition: MetadataFieldOrder.php:21
MetadataSchema
Metadata schema (in effect a Factory class for MetadataField).
Definition: MetadataSchema.php:13
MetadataFieldOrder
Class to build metadata field ordering functionality on top of the foldering functionality.
Definition: MetadataFieldOrder.php:14
Folder\AppendItem
AppendItem($ItemOrItemId, $ItemType=NULL)
Add item to folder as the last item.
Definition: Folder.php:255
MetadataFieldOrder\$OrderName
$OrderName
The name of the metadata field order.
Definition: MetadataFieldOrder.php:954
Folder\Id
Id()
Get folder ID.
Definition: Folder.php:109
MetadataFieldOrder\GetGroups
GetGroups()
Get all the groups in this metadata field ordering in order.
Definition: MetadataFieldOrder.php:203
MetadataFieldOrder\GetSiblingItem
GetSiblingItem($Item, $Offset, $Filter=NULL)
Get the item object of the item that is the given distance from the item.
Definition: MetadataFieldOrder.php:772
Database
SQL database abstraction object with smart query caching.
Definition: Database.php:22
MetadataFieldOrder\MoveItemDown
MoveItemDown($Item, $Filter=NULL)
Move the given item down in the order.
Definition: MetadataFieldOrder.php:302
MetadataFieldOrder\GroupFilterCallback
GroupFilterCallback($Item)
Callback for the filter to retrieve groups only from the metadata field order.
Definition: MetadataFieldOrder.php:729
MetadataFieldOrder\__construct
__construct($Id)
Load an existing metadata field order.
Definition: MetadataFieldOrder.php:28
Database\FetchRow
FetchRow()
Get next database row retrieved by most recent query.
Definition: Database.php:642
MetadataFieldOrder\Delete
Delete()
Delete the metadata field order.
Definition: MetadataFieldOrder.php:80
MetadataFieldOrder\GetItems
GetItems()
Transform the item IDs of the metadata field order object into objects.
Definition: MetadataFieldOrder.php:115
MetadataFieldOrder\ItemInOrder
ItemInOrder($Item)
Determine whether the given item is a member of this order.
Definition: MetadataFieldOrder.php:503
FolderFactory
Factory object for Folder class, used to retrieve and manage Folders and groups of Folders...
Definition: FolderFactory.php:14
MetadataFieldGroup
Class that builds on the foldering functionality to provide groups of metadata fields.
Definition: MetadataFieldGroup.php:14
Folder
Folder object used to create and manage groups of items.
Definition: Folder.php:17
MetadataFieldOrder\GetItemType
GetItemType($Item)
Get the type of the given item.
Definition: MetadataFieldOrder.php:718
Folder\RemoveItem
RemoveItem($ItemId, $ItemType=NULL)
Remove item from folder, if present.
Definition: Folder.php:376
PHP
PHP
Definition: RSSClient--Test.php:12
Folder\InsertItemAfter
InsertItemAfter($TargetItemOrItemId, $NewItemOrItemId, $TargetItemType=NULL, $NewItemType=NULL)
Insert item into folder after specified item.
Definition: Folder.php:226
MetadataFieldOrder\MoveItemUp
MoveItemUp($Item, $Filter=NULL)
Move the given item up in the order.
Definition: MetadataFieldOrder.php:235
MetadataFieldOrder\GetItemId
GetItemId($Item)
Get the ID of the given item.
Definition: MetadataFieldOrder.php:708
Database\NumRowsSelected
NumRowsSelected()
Get number of rows returned by last SELECT or SHOW query.
Definition: Database.php:599
MetadataFieldOrder\$SchemaId
$SchemaId
The ID of the metadata schema this metadata field order is associated with.
Definition: MetadataFieldOrder.php:949
MetadataFieldOrder\GetEnclosure
GetEnclosure($Item)
Get the metadata field order or metadata field group that encloses the given item.
Definition: MetadataFieldOrder.php:741
MetadataFieldOrder\MoveFieldToTopOfGroup
MoveFieldToTopOfGroup(MetadataFieldGroup $Group, MetadataField $Field)
Move the given item to the top of the order.
Definition: MetadataFieldOrder.php:408
Database\Query
Query($QueryString, $FieldName="")
Query database (with caching if enabled).
Definition: Database.php:329
MetadataFieldOrder\Create
static Create(MetadataSchema $Schema, $Name, array $FieldOrder=array())
Create a new metadata field order, optionally specifying the order of the fields. ...
Definition: MetadataFieldOrder.php:543
MetadataSchema\GetFields
GetFields($FieldTypes=NULL, $OrderType=NULL, $IncludeDisabledFields=FALSE, $IncludeTempFields=FALSE)
Retrieve array of fields.
Definition: MetadataSchema.php:1212
Folder\ContainsItem
ContainsItem($ItemId, $ItemType=NULL)
Check whether specified item is contained in folder.
Definition: Folder.php:429
MetadataFieldOrder\GetFields
GetFields()
Get all the fields in this metadata field ordering in order.
Definition: MetadataFieldOrder.php:174
MetadataField
Object representing a locally-defined type of metadata field.
Definition: MetadataField.php:13
MetadataFieldOrder\SchemaId
SchemaId()
Get the ID of the metadata schema with which the metadata field order is associated.
Definition: MetadataFieldOrder.php:61
MetadataFieldOrder\FindSiblingItem
FindSiblingItem($Enclosure, $Item, $Offset, $Filter=NULL)
Attempt to find the item that is the given distance from the item within the given enclosure...
Definition: MetadataFieldOrder.php:824
MetadataFieldOrder\GetOrderForSchema
static GetOrderForSchema(MetadataSchema $Schema, $Name)
Get a metadata field order with a specific name for a given metadata schema.
Definition: MetadataFieldOrder.php:608
MetadataFieldOrder\GetOrdersForSchema
static GetOrdersForSchema(MetadataSchema $Schema)
Get all of the orders associated with a schema.
Definition: MetadataFieldOrder.php:641
MetadataFieldOrder\MendIssues
MendIssues()
Fix any issues found in case an unfound bug causes something to go awry.
Definition: MetadataFieldOrder.php:94
MetadataSchema\Id
Id()
Get schema ID.
Definition: MetadataSchema.php:269
MetadataFieldOrder\MoveItemAfter
MoveItemAfter($Target, $Item)
Move the given item after the given target item.
Definition: MetadataFieldOrder.php:447
MetadataFieldOrder\CreateGroup
CreateGroup($Name)
Create a new metadata field group with the given name.
Definition: MetadataFieldOrder.php:142
MetadataFieldOrder\GetOrderForSchemaId
static GetOrderForSchemaId($SchemaId, $Name)
Get a metadata field order with a specific name for a given metadata schema ID.
Definition: MetadataFieldOrder.php:621
MetadataFieldOrder\DeleteGroup
DeleteGroup(MetadataFieldGroup $Group)
Move the metadata fields out of the given metadata group to the metadata field order and then delete ...
Definition: MetadataFieldOrder.php:161
MetadataFieldOrder\MoveItemToTop
MoveItemToTop($Item)
Move the given item to the top of the order.
Definition: MetadataFieldOrder.php:367
Folder\PrependItem
PrependItem($ItemOrItemId, $ItemType=NULL)
Add item to folder as the first item.
Definition: Folder.php:242
MetadataFieldOrder\MoveFieldToGroup
MoveFieldToGroup(MetadataFieldGroup $Group, MetadataField $Field, $Placement)
Move the field with the given ID to the group with the given ID, optionally specifying the place wher...
Definition: MetadataFieldOrder.php:858
Folder\GetItemIds
GetItemIds($Offset=NULL, $Length=NULL)
Retrieve array of IDs of items in folder, in the order that they appear in the folder.
Definition: Folder.php:322
MetadataFieldOrder\GetOrdersForSchemaId
static GetOrdersForSchemaId($SchemaId)
Get all of the orders associated with a schema ID.
Definition: MetadataFieldOrder.php:652
$Items
$Items
Definition: RSSClient--Test.php:26
MetadataFieldOrder\OrderName
OrderName()
Get the name of the metadata field order.
Definition: MetadataFieldOrder.php:70
MetadataFieldOrder\IsFieldOrGroup
IsFieldOrGroup($Item)
Determine if the given item is a metadata field or metadata field group.
Definition: MetadataFieldOrder.php:688
MetadataFieldOrder\$Database
$Database
Database object with which to query the database.
Definition: MetadataFieldOrder.php:943