CWIS Developer Documentation
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
MetadataFieldOrder Class Reference

Class to build metadata field ordering functionality on top of the foldering functionality. More...

Inheritance diagram for MetadataFieldOrder:
Inheritance graph
[legend]
Collaboration diagram for MetadataFieldOrder:
Collaboration graph
[legend]

Public Member Functions

 __construct ($Id)
 Load an existing metadata field order. More...
 
 SchemaId ()
 Get the ID of the metadata schema with which the metadata field order is associated. More...
 
 OrderName ()
 Get the name of the metadata field order. More...
 
 Delete ()
 Delete the metadata field order. More...
 
 MendIssues ()
 Fix any issues found in case an unfound bug causes something to go awry. More...
 
 GetItems ()
 Transform the item IDs of the metadata field order object into objects. More...
 
 CreateGroup ($Name)
 Create a new metadata field group with the given name. More...
 
 DeleteGroup (MetadataFieldGroup $Group)
 Move the metadata fields out of the given metadata group to the metadata field order and then delete it. More...
 
 GetFields ()
 Get all the fields in this metadata field ordering in order. More...
 
 GetGroups ()
 Get all the groups in this metadata field ordering in order. More...
 
 MoveItemUp ($Item, $Filter=NULL)
 Move the given item up in the order. More...
 
 MoveItemDown ($Item, $Filter=NULL)
 Move the given item down in the order. More...
 
 MoveItemToTop ($Item)
 Move the given item to the top of the order. More...
 
 MoveFieldToTopOfGroup (MetadataFieldGroup $Group, MetadataField $Field)
 Move the given item to the top of the order. More...
 
 MoveItemAfter ($Target, $Item)
 Move the given item after the given target item. More...
 
 ItemInOrder ($Item)
 Determine whether the given item is a member of this order. More...
 
- Public Member Functions inherited from Folder
 Folder ($FolderId)
 Object constructor – load an existing folder. More...
 
 Delete ()
 Delete folder. More...
 
 Id ()
 Get folder ID. More...
 
 Name ($NewValue=DB_NOVALUE)
 Get/set folder name. More...
 
 NormalizedName ($NewValue=DB_NOVALUE)
 Get/set normalized version of folder name. More...
 
 IsShared ($NewValue=DB_NOVALUE)
 Get/set whether folder is publically-viewable. More...
 
 OwnerId ($NewValue=DB_NOVALUE)
 Get/set user ID of folder owner. More...
 
 Note ($NewValue=DB_NOVALUE)
 Get/set note text for folder. More...
 
 InsertItemBefore ($TargetItemOrItemId, $NewItemOrItemId, $TargetItemType=NULL, $NewItemType=NULL)
 Insert item into folder before specified item. More...
 
 InsertItemAfter ($TargetItemOrItemId, $NewItemOrItemId, $TargetItemType=NULL, $NewItemType=NULL)
 Insert item into folder after specified item. More...
 
 PrependItem ($ItemOrItemId, $ItemType=NULL)
 Add item to folder as the first item. More...
 
 AppendItem ($ItemOrItemId, $ItemType=NULL)
 Add item to folder as the last item. More...
 
 GetItemIds ()
 Retrieve array of IDs of items in folder, in the order that they appear in the folder. More...
 
 GetItemCount ()
 Get number of items in folder. More...
 
 RemoveItem ($ItemId, $ItemType=NULL)
 Remove item from folder, if present. More...
 
 NoteForItem ($ItemId, $NewValue=DB_NOVALUE, $ItemType=NULL)
 Get/set note text for specific item within folder. More...
 
 ContainsItem ($ItemId, $ItemType=NULL)
 Check whether specified item is contained in folder. More...
 

Static Public Member Functions

static Create (MetadataSchema $Schema, $Name, array $FieldOrder=array())
 Create a new metadata field order, optionally specifying the order of the fields. More...
 
static GetOrderForSchema (MetadataSchema $Schema, $Name)
 Get a metadata field order with a specific name for a given metadata schema. More...
 
static GetOrderForSchemaId ($SchemaId, $Name)
 Get a metadata field order with a specific name for a given metadata schema ID. More...
 
static GetOrdersForSchema (MetadataSchema $Schema)
 Get all of the orders associated with a schema. More...
 
static GetOrdersForSchemaId ($SchemaId)
 Get all of the orders associated with a schema ID. More...
 
- Static Public Member Functions inherited from Folder
static NormalizeFolderName ($Name)
 Convert folder name to normalized form (lower-case alphanumeric only). More...
 

Public Attributes

const DEFAULT_FOLDER_NAME = "FieldOrder"
 The default name given to the folders that are really metadata field orders. More...
 
- Public Attributes inherited from Folder
const MIXEDCONTENT = -1
 

Protected Member Functions

 IsFieldOrGroup ($Item)
 Determine if the given item is a metadata field or metadata field group. More...
 
 GetItemId ($Item)
 Get the ID of the given item. More...
 
 GetItemType ($Item)
 Get the type of the given item. More...
 
 GroupFilterCallback ($Item)
 Callback for the filter to retrieve groups only from the metadata field order. More...
 
 GetEnclosure ($Item)
 Get the metadata field order or metadata field group that encloses the given item. More...
 
 GetSiblingItem ($Item, $Offset, $Filter=NULL)
 Get the item object of the item that is the given distance from the item. More...
 
 FindSiblingItem ($Enclosure, $Item, $Offset, $Filter=NULL)
 Attempt to find the item that is the given distance from the item within the given enclosure. More...
 
 MoveFieldToGroup (MetadataFieldGroup $Group, MetadataField $Field, $Placement)
 Move the field with the given ID to the group with the given ID, optionally specifying the place where the should be placed. More...
 
 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 where the field should be placed. More...
 
 MoveFieldsToOrder (MetadataFieldGroup $Group)
 Move all the metadata fields out of the given metadata field group and into the main order. More...
 

Protected Attributes

 $Database
 Database object with which to query the database. More...
 
 $SchemaId
 The ID of the metadata schema this metadata field order is associated with. More...
 
 $OrderName
 The name of the metadata field order. More...
 

Detailed Description

Class to build metadata field ordering functionality on top of the foldering functionality.

Definition at line 14 of file MetadataFieldOrder.php.

Constructor & Destructor Documentation

MetadataFieldOrder::__construct (   $Id)

Load an existing metadata field order.

Parameters
int$IdThe ID of the metadata field order to load.
Exceptions
Exceptionif the ID is invalid or the order does not exist.

Definition at line 28 of file MetadataFieldOrder.php.

References Database\FetchRow(), Database\NumRowsSelected(), OrderName(), Database\Query(), and SchemaId().

Member Function Documentation

static MetadataFieldOrder::Create ( MetadataSchema  $Schema,
  $Name,
array  $FieldOrder = array() 
)
static

Create a new metadata field order, optionally specifying the order of the fields.

The array values for the order should be ordered field IDs. This will overwrite any existing orders associated with the schema that have the same name as the one given.

Parameters
MetadataSchema$SchemaSchema with which to associate the order.
string$NameName for the metadata field order.
array$FieldOrderOptional ordered array of field IDs.
Returns
Returns a new MetadataFieldOrder object.

Definition at line 542 of file MetadataFieldOrder.php.

References $Database, MetadataSchema\GetFields(), and MetadataSchema\Id().

Referenced by MetadataSchema\GetDisplayOrder(), and MetadataSchema\GetEditOrder().

Here is the caller graph for this function:

MetadataFieldOrder::CreateGroup (   $Name)

Create a new metadata field group with the given name.

Parameters
string$Namegroup name
Returns
MetadataFieldGroup new metadata field group

Definition at line 142 of file MetadataFieldOrder.php.

References Folder\AppendItem().

MetadataFieldOrder::Delete ( )

Delete the metadata field order.

This removes the association of the order with any schemas and deletes the folder it uses. The object should not be used after calling this method.

Definition at line 80 of file MetadataFieldOrder.php.

References Folder\Id(), and Database\Query().

MetadataFieldOrder::DeleteGroup ( MetadataFieldGroup  $Group)

Move the metadata fields out of the given metadata group to the metadata field order and then delete it.

Parameters
MetadataFieldGroup$Groupmetadata field group
Returns
void

Definition at line 162 of file MetadataFieldOrder.php.

References Folder\ContainsItem(), Folder\Id(), MoveFieldsToOrder(), and Folder\RemoveItem().

MetadataFieldOrder::FindSiblingItem (   $Enclosure,
  $Item,
  $Offset,
  $Filter = NULL 
)
protected

Attempt to find the item that is the given distance from the item within the given enclosure.

Parameters
MetadataFieldGroup | MetadataFieldOrder$Enclosureitem enclosure
MetadataField | MetadataFieldGroup$Itemitem
int$Offsetdistance from the item, negative values are allowed
callback$Filtercallback to filter out items
Returns
array item info, i.e., item ID and type, or NULL if not found

Definition at line 818 of file MetadataFieldOrder.php.

References GetItemId(), and GetItemType().

Referenced by GetSiblingItem().

Here is the caller graph for this function:

MetadataFieldOrder::GetEnclosure (   $Item)
protected

Get the metadata field order or metadata field group that encloses the given item.

Parameters
MetadataField | MetadataFieldGroup$Itemitem
Returns
MetadataFieldGroup|MetadataFieldOrder|null the metadata field order or metadata field group that encloses the item, or NULL otherwise

Definition at line 740 of file MetadataFieldOrder.php.

References Folder\ContainsItem(), GetGroups(), GetItemId(), and GetItemType().

Referenced by MoveFieldToTopOfGroup(), MoveItemAfter(), MoveItemDown(), MoveItemToTop(), and MoveItemUp().

Here is the caller graph for this function:

MetadataFieldOrder::GetFields ( )

Get all the fields in this metadata field ordering in order.

Returns
array array of MetadataField objects

Definition at line 175 of file MetadataFieldOrder.php.

References GetItems().

MetadataFieldOrder::GetGroups ( )

Get all the groups in this metadata field ordering in order.

Returns
array array of MetadataFieldGroup objects

Definition at line 204 of file MetadataFieldOrder.php.

References Folder\GetItemIds().

Referenced by GetEnclosure(), GetSiblingItem(), and ItemInOrder().

Here is the caller graph for this function:

MetadataFieldOrder::GetItemId (   $Item)
protected

Get the ID of the given item.

Parameters
MetadataField | MetadataFieldGroup | MetadataFieldOrder$Itemitem
Returns
int|null the ID of the item or NULL if the item is invalid

Definition at line 707 of file MetadataFieldOrder.php.

Referenced by FindSiblingItem(), GetEnclosure(), GetSiblingItem(), ItemInOrder(), MoveFieldToGroup(), MoveFieldToOrder(), MoveFieldToTopOfGroup(), MoveItemAfter(), MoveItemDown(), MoveItemToTop(), and MoveItemUp().

Here is the caller graph for this function:

MetadataFieldOrder::GetItems ( )

Transform the item IDs of the metadata field order object into objects.

Returns
array an array of metadata field order object items

Definition at line 115 of file MetadataFieldOrder.php.

References $Items, and Folder\GetItemIds().

Referenced by GetFields().

Here is the caller graph for this function:

MetadataFieldOrder::GetItemType (   $Item)
protected

Get the type of the given item.

Parameters
MetadataField | MetadataFieldGroup | MetadataFieldOrder$Itemitem
Returns
string|null the type of the item or NULL if the item is invalid

Definition at line 717 of file MetadataFieldOrder.php.

Referenced by FindSiblingItem(), GetEnclosure(), GetSiblingItem(), ItemInOrder(), MoveFieldToTopOfGroup(), MoveItemAfter(), MoveItemDown(), MoveItemToTop(), and MoveItemUp().

Here is the caller graph for this function:

static MetadataFieldOrder::GetOrderForSchema ( MetadataSchema  $Schema,
  $Name 
)
static

Get a metadata field order with a specific name for a given metadata schema.

Parameters
MetadataSchema$SchemaSchema of which to get the order.
string$NameName of the metadata field order to get.
Returns
Returns a MetadataFieldOrder or NULL if it doesn't exist.
See Also
GetOrderForSchemaId()

Definition at line 607 of file MetadataFieldOrder.php.

References MetadataSchema\Id().

Referenced by MetadataSchema\GetDisplayOrder(), and MetadataSchema\GetEditOrder().

Here is the caller graph for this function:

static MetadataFieldOrder::GetOrderForSchemaId (   $SchemaId,
  $Name 
)
static

Get a metadata field order with a specific name for a given metadata schema ID.

Parameters
int$SchemaIdSchema ID of which to get the order.
string$NameName of the metadata field order to get.
Returns
Returns a MetadataFieldOrder or NULL if it doesn't exist.
See Also
GetOrderForSchema()

Definition at line 620 of file MetadataFieldOrder.php.

References $SchemaId.

static MetadataFieldOrder::GetOrdersForSchema ( MetadataSchema  $Schema)
static

Get all of the orders associated with a schema.

Parameters
MetadataSchema$SchemaSchema of which to get the orders.
Returns
Returns an array of orders associated with the schema.
See Also
GetOrdersForSchemaId()

Definition at line 640 of file MetadataFieldOrder.php.

References MetadataSchema\Id().

Referenced by MetadataField\Drop().

Here is the caller graph for this function:

static MetadataFieldOrder::GetOrdersForSchemaId (   $SchemaId)
static

Get all of the orders associated with a schema ID.

Parameters
int$SchemaIdID of the schema of which to get the orders.
Returns
Returns an array of orders associated with the schema.
See Also
GetOrdersForSchema()

Definition at line 651 of file MetadataFieldOrder.php.

References $Database, and $SchemaId.

MetadataFieldOrder::GetSiblingItem (   $Item,
  $Offset,
  $Filter = NULL 
)
protected

Get the item object of the item that is the given distance from the item.

Parameters
MetadataField | MetadataFieldGroup$Itemitem
int$Offsetdistance from the item, negative values are allowed
callback$Filtercallback to filter out items
Returns
array item info, i.e., item ID and type, or NULL if not found

Definition at line 771 of file MetadataFieldOrder.php.

References Folder\ContainsItem(), FindSiblingItem(), GetGroups(), GetItemId(), and GetItemType().

Referenced by MoveItemDown(), and MoveItemUp().

Here is the caller graph for this function:

MetadataFieldOrder::GroupFilterCallback (   $Item)
protected

Callback for the filter to retrieve groups only from the metadata field order.

Parameters
array$Itemarray of item info, i.e., item ID and type
Returns
bool TRUE if the item is a group or FALSE otherwise

Definition at line 728 of file MetadataFieldOrder.php.

MetadataFieldOrder::IsFieldOrGroup (   $Item)
protected

Determine if the given item is a metadata field or metadata field group.

Parameters
mixed$Itemitem
Returns
TRUE if the item is a metadata field or group, FALSE otherwise

Definition at line 687 of file MetadataFieldOrder.php.

Referenced by ItemInOrder(), MoveItemAfter(), MoveItemDown(), MoveItemToTop(), and MoveItemUp().

Here is the caller graph for this function:

MetadataFieldOrder::ItemInOrder (   $Item)

Determine whether the given item is a member of this order.

Parameters
MetadataField | MetadataFieldGroup$Itemitem
Returns
bool TRUE if the item belongs to the order or FALSE otherwise

Definition at line 502 of file MetadataFieldOrder.php.

References Folder\ContainsItem(), GetGroups(), GetItemId(), GetItemType(), and IsFieldOrGroup().

Referenced by MendIssues(), MoveFieldToTopOfGroup(), MoveItemAfter(), MoveItemDown(), MoveItemToTop(), and MoveItemUp().

Here is the caller graph for this function:

MetadataFieldOrder::MendIssues ( )

Fix any issues found in case an unfound bug causes something to go awry.

Definition at line 94 of file MetadataFieldOrder.php.

References Folder\AppendItem(), ItemInOrder(), and SchemaId().

MetadataFieldOrder::MoveFieldsToOrder ( MetadataFieldGroup  $Group)
protected

Move all the metadata fields out of the given metadata field group and into the main order.

Parameters
MetadataFieldGroup$Groupmetadata field group
Returns
void

Definition at line 914 of file MetadataFieldOrder.php.

References Folder\GetItemIds(), Folder\Id(), and Folder\InsertItemAfter().

Referenced by DeleteGroup().

Here is the caller graph for this function:

MetadataFieldOrder::MoveFieldToGroup ( MetadataFieldGroup  $Group,
MetadataField  $Field,
  $Placement 
)
protected

Move the field with the given ID to the group with the given ID, optionally specifying the place where the should be placed.

Parameters
MetadataFieldGroup$Groupmetadata field group
MetadataField$Fieldmetadata field
string$Placementwhere to place the field ("prepend" or "append")

Definition at line 852 of file MetadataFieldOrder.php.

References Folder\ContainsItem(), GetItemId(), and Folder\RemoveItem().

Referenced by MoveItemDown(), and MoveItemUp().

Here is the caller graph for this function:

MetadataFieldOrder::MoveFieldToOrder ( MetadataFieldGroup  $Group,
MetadataField  $Field,
  $Placement 
)
protected

Move the field with the given ID from the group with the given ID to the order, optionally specifying where the field should be placed.

Parameters
MetadataFieldGroup$Groupmetadata field group
MetadataField$Fieldmetadata field
string$Placementwhere to place the field ("before" or "after")
Returns
void

Definition at line 882 of file MetadataFieldOrder.php.

References Folder\ContainsItem(), GetItemId(), and Folder\RemoveItem().

Referenced by MoveItemDown(), and MoveItemUp().

Here is the caller graph for this function:

MetadataFieldOrder::MoveFieldToTopOfGroup ( MetadataFieldGroup  $Group,
MetadataField  $Field 
)

Move the given item to the top of the order.

Parameters
MetadataFieldGroup$Groupthe group within which to move the field
MetadataField$Fieldthe field to move
Exceptions
Exceptionif the group or field aren't in the order

Definition at line 406 of file MetadataFieldOrder.php.

References GetEnclosure(), GetItemId(), GetItemType(), ItemInOrder(), and Folder\PrependItem().

MetadataFieldOrder::MoveItemAfter (   $Target,
  $Item 
)

Move the given item after the given target item.

Parameters
MetadataField | MetadataFieldGroup$Targetthe item to move after
MetadataField | MetadataFieldGroup$Itemthe item to move
Returns
void
Exceptions
Exceptionif the items aren't a metadata field or metadata group
Exceptionif the items aren't in the order
Exceptionif attempting to put a group into another one

Definition at line 446 of file MetadataFieldOrder.php.

References GetEnclosure(), GetItemId(), GetItemType(), IsFieldOrGroup(), and ItemInOrder().

Referenced by MoveItemDown(), and MoveItemUp().

Here is the caller graph for this function:

MetadataFieldOrder::MoveItemDown (   $Item,
  $Filter = NULL 
)

Move the given item down in the order.

Parameters
MetadataField | MetadataFieldGroup$Item
callback$Filtercallback to filter out items before moving
Returns
void
Exceptions
Exceptionif the item isn't a metadata field or metadata group
Exceptionif the item isn't in the order
Exceptionif a callback is given and it isn't callable

Definition at line 300 of file MetadataFieldOrder.php.

References GetEnclosure(), GetItemId(), GetItemType(), GetSiblingItem(), IsFieldOrGroup(), ItemInOrder(), MoveFieldToGroup(), MoveFieldToOrder(), and MoveItemAfter().

MetadataFieldOrder::MoveItemToTop (   $Item)

Move the given item to the top of the order.

Parameters
MetadataField | MetadataFieldGroup$Itemthe item to move
Exceptions
Exceptionif the item isn't a metadata field or metadata group
Exceptionif the item isn't in the order

Definition at line 365 of file MetadataFieldOrder.php.

References GetEnclosure(), GetItemId(), GetItemType(), IsFieldOrGroup(), ItemInOrder(), and Folder\PrependItem().

MetadataFieldOrder::MoveItemUp (   $Item,
  $Filter = NULL 
)

Move the given item up in the order.

Parameters
MetadataField | MetadataFieldGroup$Itemitem
callback$Filtercallback to filter out items before moving
Returns
void
Exceptions
Exceptionif the item isn't a metadata field or metadata group
Exceptionif the item isn't in the order
Exceptionif a callback is given and it isn't callable

Definition at line 232 of file MetadataFieldOrder.php.

References GetEnclosure(), GetItemId(), GetItemType(), GetSiblingItem(), IsFieldOrGroup(), ItemInOrder(), MoveFieldToGroup(), MoveFieldToOrder(), and MoveItemAfter().

MetadataFieldOrder::OrderName ( )

Get the name of the metadata field order.

Returns
Returns the name of the metadata field order.

Definition at line 70 of file MetadataFieldOrder.php.

References $OrderName.

Referenced by __construct().

Here is the caller graph for this function:

MetadataFieldOrder::SchemaId ( )

Get the ID of the metadata schema with which the metadata field order is associated.

Returns
Returns the ID of the metadata schema with which the metadata field order is associated.

Definition at line 61 of file MetadataFieldOrder.php.

References $SchemaId.

Referenced by __construct(), and MendIssues().

Here is the caller graph for this function:

Member Data Documentation

MetadataFieldOrder::$Database
protected

Database object with which to query the database.

Definition at line 939 of file MetadataFieldOrder.php.

Referenced by Create(), and GetOrdersForSchemaId().

MetadataFieldOrder::$OrderName
protected

The name of the metadata field order.

Definition at line 950 of file MetadataFieldOrder.php.

Referenced by OrderName().

MetadataFieldOrder::$SchemaId
protected

The ID of the metadata schema this metadata field order is associated with.

Definition at line 945 of file MetadataFieldOrder.php.

Referenced by GetOrderForSchemaId(), GetOrdersForSchemaId(), and SchemaId().

const MetadataFieldOrder::DEFAULT_FOLDER_NAME = "FieldOrder"

The default name given to the folders that are really metadata field orders.

Definition at line 21 of file MetadataFieldOrder.php.


The documentation for this class was generated from the following file: