CWIS Developer Documentation
|
Common factory class for item manipulation. More...
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 | |
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.
ItemFactory::AddItem | ( | $ItemName, | |
$AdditionalValues = NULL |
|||
) |
Add new item.
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) |
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.
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.
int | $MinutesUntilStale | Number of minutes before items are considered stale. (OPTIONAL - defaults to 7 days) |
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().
ItemFactory::DeleteItem | ( | $ItemId | ) |
Delete item.
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.
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. |
Definition at line 803 of file ItemFactory.php.
References $DB.
ItemFactory::GetCurrentEditedItemId | ( | ) |
Get ID of currently edited item.
Definition at line 74 of file ItemFactory.php.
References GetLastTempItemId().
Referenced by ClearCurrentEditedItem().
ItemFactory::GetHighestItemId | ( | $IgnoreSqlCondition = FALSE | ) |
Retrieve highest item ID in use.
bool | $IgnoreSqlCondition | If TRUE, any SQL condition set via the constructor is ignored. (OPTIONAL, defaults to FALSE) |
Definition at line 248 of file ItemFactory.php.
Referenced by MetadataSchema\GetHighestFieldId(), and GetNextItemId().
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.
int | $ItemId | Item ID. |
Definition at line 433 of file ItemFactory.php.
Referenced by GetItemByName(), GetItems(), OAIServer\ProcessGetRecord(), and OAIServer\ProcessListRecords().
ItemFactory::GetItemByName | ( | $Name, | |
$IgnoreCase = FALSE |
|||
) |
Retrieve item by name.
string | $Name | Name to match. |
bool | $IgnoreCase | If TRUE, ignore case when attempting to match the item name. (OPTIONAL, defaults to FALSE) |
Definition at line 463 of file ItemFactory.php.
References GetItem(), and GetItemIdByName().
ItemFactory::GetItemClassName | ( | ) |
Get class name of items manipulated by factory.
Definition at line 65 of file ItemFactory.php.
ItemFactory::GetItemCount | ( | $Condition = NULL , |
|
$IncludeTempItems = FALSE |
|||
) |
Get count of items.
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) |
Definition at line 293 of file ItemFactory.php.
Referenced by FolderFactory\GetFolderCount().
ItemFactory::GetItemIdByName | ( | $Name, | |
$IgnoreCase = FALSE |
|||
) |
Retrieve item ID by name.
string | $Name | Name to match. |
bool | $IgnoreCase | If TRUE, ignore case when attempting to match the item name. (OPTIONAL, defaults to FALSE) |
Definition at line 488 of file ItemFactory.php.
Referenced by GetItemByName().
ItemFactory::GetItemIds | ( | $Condition = NULL , |
|
$IncludeTempItems = FALSE , |
|||
$SortField = NULL , |
|||
$SortAscending = TRUE |
|||
) |
Return array of item IDs.
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.) |
Definition at line 350 of file ItemFactory.php.
Referenced by FolderFactory\GetFolders(), GetItems(), and ClassificationFactory\RecalculateAllResourceCounts().
ItemFactory::GetItemIdsInOrder | ( | ) |
Retrieve list of item IDs in order.
Definition at line 1033 of file ItemFactory.php.
ItemFactory::GetItemNames | ( | $SqlCondition = NULL | ) |
Retrieve item names.
string | $SqlCondition | SQL condition (w/o "WHERE") for name retrieval. (OPTIONAL) |
Definition at line 520 of file ItemFactory.php.
Referenced by GetItemsAsOptionList().
ItemFactory::GetItems | ( | $SqlCondition = NULL | ) |
Retrieve items.
string | $SqlCondition | SQL condition (w/o "WHERE") for name retrieval. (OPTIONAL) |
Definition at line 565 of file ItemFactory.php.
References $Items, GetItem(), and GetItemIds().
Referenced by SavedSearchFactory\GetSearchesDueToRun(), SavedSearchFactory\GetSearchesForUser(), and OAIServer\ProcessListRecords().
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.
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) |
Definition at line 591 of file ItemFactory.php.
References GetItemNames().
ItemFactory::GetLastTempItemId | ( | ) |
Retrieve most recent temp item ID for currently-logged-in user.
Definition at line 200 of file ItemFactory.php.
Referenced by GetCurrentEditedItemId().
ItemFactory::GetLatestModificationDate | ( | $Condition = NULL | ) |
Get newest modification date (based on values in "DateLastModified" column in database table).
string | $Condition | SQL condition clause to restrict selection of items (should not include "WHERE"). |
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.
Definition at line 222 of file ItemFactory.php.
References GetHighestItemId().
ItemFactory::GetNextTempItemId | ( | ) |
Return next available 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.
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.
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.
int | $ItemId | ID of item. |
bool | $IgnoreSqlCondition | If TRUE, any SQL condition set in the constructor is ignored. (OPTIONAL, defaults to FALSE) |
Definition at line 445 of file ItemFactory.php.
ItemFactory::ItemFactory | ( | $ItemClassName, | |
$ItemTableName, | |||
$ItemIdFieldName, | |||
$ItemNameFieldName = NULL , |
|||
$OrderOpsAllowed = FALSE , |
|||
$SqlCondition = NULL |
|||
) |
Class constructor.
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().
ItemFactory::NameIsInUse | ( | $Name, | |
$IgnoreCase = FALSE |
|||
) |
Check whether item name is currently in use.
string | $Name | Name to check. |
bool | $IgnoreCase | If TRUE, ignore case when checking. (Defaults to FALSE) |
Definition at line 640 of file ItemFactory.php.
Referenced by MetadataSchema\AddFieldsFromXmlFile(), and MetadataSchema\FieldExists().
ItemFactory::Prepend | ( | $Item | ) |
Add item to beginning of order.
If the item is already present in the order, it is moved to the beginning.
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.
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.
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. |
Definition at line 671 of file ItemFactory.php.
References $DB.
ItemFactory::SetCurrentEditedItemId | ( | $NewId | ) |
Set ID of currently edited item.
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.
string | $Condition | SQL condition (should not include "WHERE"). |
Definition at line 940 of file ItemFactory.php.
Referenced by FolderFactory\FolderFactory(), and ItemFactory().
|
protected |
Definition at line 1070 of file ItemFactory.php.
Referenced by MetadataSchema\Create(), ClassificationFactory\GetChildIds(), GetCountForItemNames(), MetadataSchema\SchemaExistsWithId(), SearchForItemNames(), and ResourceFactory\UpdateResourceCountCallback().