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

Common factory class for item manipulation. More...

Inheritance diagram for ItemFactory:
Inheritance graph
[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$ItemNameValue to store in name field for new item.
array$AdditionalValuesAssociative 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$ItemItem (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$MinutesUntilStaleNumber 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$ItemIdID 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$SearchStringString to search for.
bool$IncludeVariants(NOT YET IMPLEMENTED) (OPTIONAL)
bool$UseBooleanModeIf 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$IdExclusionsList of IDs of items to exclude.
array$ValueExclusionsList 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$IgnoreSqlConditionIf 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$ItemIdItem 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$NameName to match.
bool$IgnoreCaseIf 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$ConditionSQL condition to include in query to retrieve item count. The condition should not include "WHERE". (OPTIONAL)
bool$IncludeTempItemsWhether 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$NameName to match.
bool$IgnoreCaseIf 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$ConditionSQL condition clause to restrict selection of items (should not include "WHERE").
bool$IncludeTempItemsWhether to include temporary items in returned set. (OPTIONAL, defaults to FALSE)
string$SortFieldDatabase column to use to sort results. (OPTIONAL)
bool$SortAscendingIf 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$SqlConditionSQL 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$SqlConditionSQL 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$OptionListNameValue of option list "name" attribute.
int$SelectedItemIdID of currently-selected item or array of IDs of currently-selected items. (OPTIONAL)
string$SqlConditionSQL condition (w/o "WHERE") for item retrieval. (OPTIONAL, defaults to NULL)
int$DisplaySizeDisplay length of option list. (OPTIONAL, defaults to 1)
bool$SubmitOnChangeWhether 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$ConditionSQL 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$TargetItemItem (object or ID) to insert after.
mixed$NewItemItem 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$TargetItemItem (object or ID) to insert before.
mixed$NewItemItem (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$ItemIdID of item.
bool$IgnoreSqlConditionIf 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$ItemClassNameClass of items to be manipulated by factory.
string$ItemTableNameName of database table used to store info about items.
string$ItemIdFieldNameName of field in database table used to store item IDs.
string$ItemNameFieldNameName of field in database table used to store item names. (OPTIONAL)
bool$OrderOpsAllowedIf TRUE, ordering operations are allowed with items, and the database table must contain "Previous" and "Next" fields as described by the PersistentDoublyLinkedList class.
string$SqlConditionSQL 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$NameName to check.
bool$IgnoreCaseIf 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$ItemItem (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$ItemIdID 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$SearchStringString to search for.
int$NumberOfResultsNumber of results to return. (OPTIONAL, defaults to 100)
bool$IncludeVariants(NOT YET IMPLEMENTED) (OPTIONAL)
bool$UseBooleanModeIf 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$OffsetBeginning offset into results. (OPTIONAL, defaults to 0, which is the first element)
array$IdExclusionsList of IDs of items to exclude.
array$ValueExclusionsList 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$NewIdItem 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$ConditionSQL 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

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