CWIS Developer Documentation

- Home
- Main Page
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Protected Attributes | List of all members
ItemFactory Class Reference

Common factory class for item manipulation. More...

Inheritance diagram for ItemFactory:
[legend]

## Public Member Functions
| ItemFactory ($ItemClassName, $ItemTableName, $ItemIdFieldName, $ItemNameFieldName=NULL, $OrderOpsAllowed=FALSE, $SqlCondition=NULL)
| Class constructor. More...
| GetItemClassName ()
| Get class name of items manipulated by factory. More...
| GetCurrentEditedItemId ()
| Get ID of currently edited item. More...
| SetCurrentEditedItemId ($NewId)
| Set ID of currently edited item. More...
| ClearCurrentEditedItemId ()
| Clear currently edited item ID. More...
| ClearCurrentEditedItem ()
| Delete currently edited item and clear currently edited item ID. More...
| CleanOutStaleTempItems ($MinutesUntilStale=10080)
| Clear out (call the Delete() method) for any temp items more than specified number of minutes old. More...
| GetLastTempItemId ()
| Retrieve most recent temp item ID for currently-logged-in user. More...
| GetNextItemId ()
| Retrieve next available (non-temp) item ID. More...
| GetHighestItemId ($IgnoreSqlCondition=FALSE)
| Retrieve highest item ID in use. More...
| GetNextTempItemId ()
| Return next available temporary item ID. More...
| GetItemCount ($Condition=NULL, $IncludeTempItems=FALSE)
| Get count of items. More...
| GetItemIds ($Condition=NULL, $IncludeTempItems=FALSE, $SortField=NULL, $SortAscending=TRUE)
| Return array of item IDs. More...
| GetLatestModificationDate ($Condition=NULL)
| Get newest modification date (based on values in "DateLastModified" column in database table). More...
| GetItem ($ItemId)
| Retrieve item by item ID. More...
| ItemExists ($ItemId, $IgnoreSqlCondition=FALSE)
| Check that item exists with specified ID. More...
| GetItemByName ($Name, $IgnoreCase=FALSE)
| Retrieve item by name. More...
| GetItemIdByName ($Name, $IgnoreCase=FALSE)
| Retrieve item ID by name. More...
| GetItemNames ($SqlCondition=NULL)
| Retrieve item names. More...
| GetItems ($SqlCondition=NULL)
| Retrieve items. More...
| GetItemsAsOptionList ($OptionListName, $SelectedItemId=NULL, $SqlCondition=NULL, $DisplaySize=1, $SubmitOnChange=FALSE)
| Retrieve items of specified type as HTML option list with item names as labels and item IDs as value attributes. More...
| NameIsInUse ($Name, $IgnoreCase=FALSE)
| Check whether item name is currently in use. More...
| SearchForItemNames ($SearchString, $NumberOfResults=100, $IncludeVariants=FALSE, $UseBooleanMode=TRUE, $Offset=0, $IdExclusions=array(), $ValueExclusions=array())
| Retrieve items with names matching search string. More...
| GetCountForItemNames ($SearchString, $IncludeVariants=FALSE, $UseBooleanMode=TRUE, $IdExclusions=array(), $ValueExclusions=array())
| Retrieve count of items with names matching search string. More...
| AddItem ($ItemName, $AdditionalValues=NULL)
| Add new item. More...
| DeleteItem ($ItemId)
| Delete item. More...
| SetOrderOpsCondition ($Condition)
| Set SQL condition (added to WHERE clause) used to select items for ordering operations. More...
| InsertBefore ($TargetItem, $NewItem)
| Insert item into order before specified item. More...
| InsertAfter ($TargetItem, $NewItem)
| Insert item into order after specified item. More...
| Prepend ($Item)
| Add item to beginning of order. More...
| Append ($Item)
| Add item to end of order. More...
| GetItemIdsInOrder ()
| Retrieve list of item IDs in order. More...
| RemoveItemFromOrder ($ItemId)
| Remove item from existing order. More...

## Protected Attributes
| $DB

## Detailed Description

Common factory class for item manipulation.

Not intended to be used directly, but rather as a parent for factory classes for specific item types. For a derived class to use the temp methods the item record in the database must include "DateLastModified" and "LastModifiedById" fields, and the item object must include a "Delete()" method.

Definition at line 17 of file ItemFactory.php.

## Member Function Documentation

ItemFactory::AddItem | ( |  | $ItemName,
|  |  | $AdditionalValues = `NULL`
| ) |  |

Add new item.

Parameters

  string | $ItemName | Value to store in name field for new item.
  array | $AdditionalValues | Associative array of additional values to set in the new item, with DB field names for the array index and values to set them to for the array values. (OPTIONAL)

Returns
  ID of new item.

Definition at line 895 of file ItemFactory.php.

ItemFactory::Append | ( |  | $Item | ) |

Add item to end of order.

If the item is already present in the order, it is moved to the end.

Parameters

  mixed | $Item | Item (object or ID) to add.

Definition at line 1015 of file ItemFactory.php.

ItemFactory::CleanOutStaleTempItems | ( |  | $MinutesUntilStale = `10080` | ) |

Clear out (call the Delete() method) for any temp items more than specified number of minutes old.

Parameters

  int | $MinutesUntilStale | Number of minutes before items are considered stale. (OPTIONAL - defaults to 7 days)

Returns
  Number of stale items deleted.

Definition at line 173 of file ItemFactory.php.

ItemFactory::ClearCurrentEditedItem | ( |  | ) |

Delete currently edited item and clear currently edited item ID.

If a Delete() method is available for the item class, then that is called, otherwise rows from the item table containing the appropriate item ID are just deleted from the database.

Definition at line 143 of file ItemFactory.php.

References ClearCurrentEditedItemId(), and GetCurrentEditedItemId().

ItemFactory::ClearCurrentEditedItemId | ( |  | ) |

Clear currently edited item ID.

Definition at line 119 of file ItemFactory.php.

Referenced by ClearCurrentEditedItem().

Here is the caller graph for this function:

ItemFactory::DeleteItem | ( |  | $ItemId | ) |

Delete item.

Parameters

  int | $ItemId | ID of item to delete.

Definition at line 924 of file ItemFactory.php.

ItemFactory::GetCountForItemNames | ( |  | $SearchString,
|  |  | $IncludeVariants = `FALSE`,
|  |  | $UseBooleanMode = `TRUE`,
|  |  | $IdExclusions = `array()`,
|  |  | $ValueExclusions = `array()`
| ) |  |

Retrieve count of items with names matching search string.

Parameters

  string | $SearchString | String to search for.
  bool | $IncludeVariants | (NOT YET IMPLEMENTED) (OPTIONAL)
  bool | $UseBooleanMode | If TRUE, perform search using MySQL "Boolean Mode", which among other things supports inclusion and exclusion operators on terms in the search string. (OPTIONAL, defaults to TRUE)
  array | $IdExclusions | List of IDs of items to exclude.
  array | $ValueExclusions | List of names of items to exclude.

Returns
  int Count of matching items.

Definition at line 803 of file ItemFactory.php.

References $DB.

ItemFactory::GetCurrentEditedItemId | ( |  | ) |

Get ID of currently edited item.

Returns
  int Item ID.

Definition at line 74 of file ItemFactory.php.

References GetLastTempItemId().

Referenced by ClearCurrentEditedItem().

Here is the caller graph for this function:

ItemFactory::GetHighestItemId | ( |  | $IgnoreSqlCondition = `FALSE` | ) |

Retrieve highest item ID in use.

Parameters

  bool | $IgnoreSqlCondition | If TRUE, any SQL condition set via the constructor is ignored. (OPTIONAL, defaults to FALSE)

Returns
  int Item ID.

See Also
  ItemFactory::ItemFactory()

Definition at line 248 of file ItemFactory.php.

Referenced by MetadataSchema\GetHighestFieldId(), and GetNextItemId().

Here is the caller graph for this function:

ItemFactory::GetItem | ( |  | $ItemId | ) |

Retrieve item by item ID.

This method assumes that an item can be loaded by passing an item ID to the appropriate class constructor.

Parameters

  int | $ItemId | Item ID.

Returns
  object Item of appropriate class.

Definition at line 433 of file ItemFactory.php.

Referenced by GetItemByName(), GetItems(), OAIServer\ProcessGetRecord(), and OAIServer\ProcessListRecords().

Here is the caller graph for this function:

ItemFactory::GetItemByName | ( |  | $Name,
|  |  | $IgnoreCase = `FALSE`
| ) |  |

Retrieve item by name.

Parameters

  string | $Name | Name to match.
  bool | $IgnoreCase | If TRUE, ignore case when attempting to match the item name. (OPTIONAL, defaults to FALSE)

Returns
  object Item of appropriate class or NULL if item not found.

Definition at line 463 of file ItemFactory.php.

References GetItem(), and GetItemIdByName().

ItemFactory::GetItemClassName | ( |  | ) |

Get class name of items manipulated by factory.

Returns
  string Class name.

Definition at line 65 of file ItemFactory.php.

ItemFactory::GetItemCount | ( |  | $Condition = `NULL`,
|  |  | $IncludeTempItems = `FALSE`
| ) |  |

Get count of items.

Parameters

  string | $Condition | SQL condition to include in query to retrieve item count. The condition should not include "WHERE". (OPTIONAL)
  bool | $IncludeTempItems | Whether to include temporary items in count. (OPTIONAL, defaults to FALSE)

Returns
  int Item count.

Definition at line 293 of file ItemFactory.php.

Referenced by FolderFactory\GetFolderCount().

Here is the caller graph for this function:

ItemFactory::GetItemIdByName | ( |  | $Name,
|  |  | $IgnoreCase = `FALSE`
| ) |  |

Retrieve item ID by name.

Parameters

  string | $Name | Name to match.
  bool | $IgnoreCase | If TRUE, ignore case when attempting to match the item name. (OPTIONAL, defaults to FALSE)

Returns
  int ID or NULL if name not found.

Definition at line 488 of file ItemFactory.php.

Referenced by GetItemByName().

Here is the caller graph for this function:

ItemFactory::GetItemIds | ( |  | $Condition = `NULL`,
|  |  | $IncludeTempItems = `FALSE`,
|  |  | $SortField = `NULL`,
|  |  | $SortAscending = `TRUE`
| ) |  |

Return array of item IDs.

Parameters

  string | $Condition | SQL condition clause to restrict selection of items (should not include "WHERE").
  bool | $IncludeTempItems | Whether to include temporary items in returned set. (OPTIONAL, defaults to FALSE)
  string | $SortField | Database column to use to sort results. (OPTIONAL)
  bool | $SortAscending | If TRUE, sort items in ascending order, otherwise sort items in descending order. (OPTIONAL, and only meaningful if a sort field is specified.)

Returns
  array Array of item IDs.

Definition at line 350 of file ItemFactory.php.

Referenced by FolderFactory\GetFolders(), GetItems(), and ClassificationFactory\RecalculateAllResourceCounts().

Here is the caller graph for this function:

ItemFactory::GetItemIdsInOrder | ( |  | ) |

Retrieve list of item IDs in order.

Returns
  array List of item IDs.

Definition at line 1033 of file ItemFactory.php.

ItemFactory::GetItemNames | ( |  | $SqlCondition = `NULL` | ) |

Retrieve item names.

Parameters

  string | $SqlCondition | SQL condition (w/o "WHERE") for name retrieval. (OPTIONAL)

Returns
  array Array with item names as values and item IDs as indexes.

Definition at line 520 of file ItemFactory.php.

Referenced by GetItemsAsOptionList().

Here is the caller graph for this function:

ItemFactory::GetItems | ( |  | $SqlCondition = `NULL` | ) |

Retrieve items.

Parameters

  string | $SqlCondition | SQL condition (w/o "WHERE") for name retrieval. (OPTIONAL)

Returns
  Array with item objects as values and item IDs as indexes.

Definition at line 565 of file ItemFactory.php.

References $Items, GetItem(), and GetItemIds().

Referenced by SavedSearchFactory\GetSearchesDueToRun(), SavedSearchFactory\GetSearchesForUser(), and OAIServer\ProcessListRecords().

Here is the caller graph for this function:

ItemFactory::GetItemsAsOptionList | ( |  | $OptionListName,
|  |  | $SelectedItemId = `NULL`,
|  |  | $SqlCondition = `NULL`,
|  |  | $DisplaySize = `1`,
|  |  | $SubmitOnChange = `FALSE`
| ) |  |

Retrieve items of specified type as HTML option list with item names as labels and item IDs as value attributes.

The first element on the list will have a label of "--" and an ID of -1 to indicate no item selected.

Parameters

  string | $OptionListName | Value of option list "name" attribute.
  int | $SelectedItemId | ID of currently-selected item or array of IDs of currently-selected items. (OPTIONAL)
  string | $SqlCondition | SQL condition (w/o "WHERE") for item retrieval. (OPTIONAL, defaults to NULL)
  int | $DisplaySize | Display length of option list. (OPTIONAL, defaults to 1)
  bool | $SubmitOnChange | Whether to submit form when option list changes. (OPTIONAL, defaults to FALSE)

Returns
  HTML for option list.

Definition at line 591 of file ItemFactory.php.

References GetItemNames().

ItemFactory::GetLastTempItemId | ( |  | ) |

Retrieve most recent temp item ID for currently-logged-in user.

Returns
  int Temp item ID, or NULL if no temp item found for the current user.

Definition at line 200 of file ItemFactory.php.

Referenced by GetCurrentEditedItemId().

Here is the caller graph for this function:

ItemFactory::GetLatestModificationDate | ( |  | $Condition = `NULL` | ) |

Get newest modification date (based on values in "DateLastModified" column in database table).

Parameters

  string | $Condition | SQL condition clause to restrict selection of items (should not include "WHERE").

Returns
  string Lastest modification date in SQL date/time format.

Definition at line 403 of file ItemFactory.php.

ItemFactory::GetNextItemId | ( |  | ) |

Retrieve next available (non-temp) item ID.

If there are currently no items, an ID of 1 will be returned.

Returns
  int Item ID.

Definition at line 222 of file ItemFactory.php.

References GetHighestItemId().

ItemFactory::GetNextTempItemId | ( |  | ) |

Return next available temporary item ID.

Returns
  int Temporary item ID.

Definition at line 267 of file ItemFactory.php.

ItemFactory::InsertAfter | ( |  | $TargetItem,
|  |  | $NewItem
| ) |  |

Insert item into order after specified item.

If the item is already present in the order, it is moved to the new location. If the target item is not found, the new item is added to the end of the order.

Parameters

  mixed | $TargetItem | Item (object or ID) to insert after.
  mixed | $NewItem | Item to insert.

Definition at line 977 of file ItemFactory.php.

ItemFactory::InsertBefore | ( |  | $TargetItem,
|  |  | $NewItem
| ) |  |

Insert item into order before specified item.

If the item is already present in the order, it is moved to the new location. If the target item is not found, the new item is added to the beginning of the order.

Parameters

  mixed | $TargetItem | Item (object or ID) to insert before.
  mixed | $NewItem | Item (object or ID) to insert.

Definition at line 956 of file ItemFactory.php.

ItemFactory::ItemExists | ( |  | $ItemId,
|  |  | $IgnoreSqlCondition = `FALSE`
| ) |  |

Check that item exists with specified ID.

Parameters

  int | $ItemId | ID of item.
  bool | $IgnoreSqlCondition | If TRUE, any SQL condition set in the constructor is ignored. (OPTIONAL, defaults to FALSE)

Returns
  bool TRUE if item exists with specified ID.

Definition at line 445 of file ItemFactory.php.

ItemFactory::ItemFactory | ( |  | $ItemClassName,
|  |  | $ItemTableName,
|  |  | $ItemIdFieldName,
|  |  | $ItemNameFieldName = `NULL`,
|  |  | $OrderOpsAllowed = `FALSE`,
|  |  | $SqlCondition = `NULL`
| ) |  |

Class constructor.

Parameters

  string | $ItemClassName | Class of items to be manipulated by factory.
  string | $ItemTableName | Name of database table used to store info about items.
  string | $ItemIdFieldName | Name of field in database table used to store item IDs.
  string | $ItemNameFieldName | Name of field in database table used to store item names. (OPTIONAL)
  bool | $OrderOpsAllowed | If TRUE, ordering operations are allowed with items, and the database table must contain "Previous" and "Next" fields as described by the PersistentDoublyLinkedList class.
  string | $SqlCondition | SQL condition clause (without "WHERE") to include when retrieving items from database. (OPTIONAL)

Definition at line 36 of file ItemFactory.php.

References SetOrderOpsCondition().

Referenced by SavedSearchFactory\__construct(), ControlledNameFactory\__construct(), FileFactory\__construct(), ClassificationFactory\ClassificationFactory(), FolderFactory\FolderFactory(), MessageFactory\MessageFactory(), MetadataSchema\MetadataSchema(), PrivilegeFactory\PrivilegeFactory(), QualifierFactory\QualifierFactory(), and ResourceFactory\ResourceFactory().

Here is the caller graph for this function:

ItemFactory::NameIsInUse | ( |  | $Name,
|  |  | $IgnoreCase = `FALSE`
| ) |  |

Check whether item name is currently in use.

Parameters

  string | $Name | Name to check.
  bool | $IgnoreCase | If TRUE, ignore case when checking. (Defaults to FALSE)

Returns
  TRUE if name is in use, otherwise FALSE.

Definition at line 640 of file ItemFactory.php.

Referenced by MetadataSchema\AddFieldsFromXmlFile(), and MetadataSchema\FieldExists().

Here is the caller graph for this function:

ItemFactory::Prepend | ( |  | $Item | ) |

Add item to beginning of order.

If the item is already present in the order, it is moved to the beginning.

Parameters

  mixed | $Item | Item (object or ID) to add.

Definition at line 996 of file ItemFactory.php.

ItemFactory::RemoveItemFromOrder | ( |  | $ItemId | ) |

Remove item from existing order.

If the item is not currently in the existing order, then the call has no effect. This does not delete or otherwise remove the item from the database.

Parameters

  int | $ItemId | ID of item to be removed from order.

Definition at line 1053 of file ItemFactory.php.

ItemFactory::SearchForItemNames | ( |  | $SearchString,
|  |  | $NumberOfResults = `100`,
|  |  | $IncludeVariants = `FALSE`,
|  |  | $UseBooleanMode = `TRUE`,
|  |  | $Offset = `0`,
|  |  | $IdExclusions = `array()`,
|  |  | $ValueExclusions = `array()`
| ) |  |

Retrieve items with names matching search string.

Parameters

  string | $SearchString | String to search for.
  int | $NumberOfResults | Number of results to return. (OPTIONAL, defaults to 100)
  bool | $IncludeVariants | (NOT YET IMPLEMENTED) (OPTIONAL)
  bool | $UseBooleanMode | If TRUE, perform search using MySQL "Boolean Mode", which among other things supports inclusion and exclusion operators on terms in the search string. (OPTIONAL, defaults to TRUE)
  int | $Offset | Beginning offset into results. (OPTIONAL, defaults to 0, which is the first element)
  array | $IdExclusions | List of IDs of items to exclude.
  array | $ValueExclusions | List of names of items to exclude.

Returns
  array List of item names, with item IDs for index.

Definition at line 671 of file ItemFactory.php.

References $DB.

ItemFactory::SetCurrentEditedItemId | ( |  | $NewId | ) |

Set ID of currently edited item.

Parameters

  int | $NewId | Item ID.

Definition at line 100 of file ItemFactory.php.

ItemFactory::SetOrderOpsCondition | ( |  | $Condition | ) |

Set SQL condition (added to WHERE clause) used to select items for ordering operations.

NULL may be passed in to clear any existing condition.

Parameters

  string | $Condition | SQL condition (should not include "WHERE").

Definition at line 940 of file ItemFactory.php.

Referenced by FolderFactory\FolderFactory(), and ItemFactory().

Here is the caller graph for this function:

## Member Data Documentation

ItemFactory::$DB
| protected

Definition at line 1070 of file ItemFactory.php.

Referenced by MetadataSchema\Create(), ClassificationFactory\GetChildIds(), GetCountForItemNames(), MetadataSchema\SchemaExistsWithId(), SearchForItemNames(), and ResourceFactory\UpdateResourceCountCallback().

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

- objects/ItemFactory.php