CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- 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
| __construct ($ItemClassName, $ItemTableName, $ItemIdFieldName, $ItemNameFieldName=NULL, $OrderOpsAllowed=FALSE, $SqlCondition=NULL)
| Class constructor. More...
| GetItemClassName ()
| Get class name of items manipulated by factory. More...
| CleanOutStaleTempItems ($MinutesUntilStale=10080)
| Clear out (call the Delete() method) for any temp items more than specified number of minutes old. 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, $Disabled=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...
| CachingEnabled ($NewValue=NULL)
| Enable/disable caching of item information. More...
| ClearCaches ()
| Clear item information caches. 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 a "DateLastModified" column, and the item object must include a "Delete()" method.

Definition at line 17 of file ItemFactory.php.

## Constructor & Destructor Documentation

ItemFactory::__construct | ( |  | $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 37 of file ItemFactory.php.

References SetOrderOpsCondition().

## Member Function Documentation

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 752 of file ItemFactory.php.

ItemFactory::CachingEnabled | ( |  | $NewValue = `NULL` | ) |

Enable/disable caching of item information.

Parameters

  bool | $NewValue | TRUE to enable caching, or FALSE to disable. (OPTIONAL)

Returns
  bool TRUE if caching is enabled, otherwise FALSE.

See also
  ClearCaches()

Definition at line 650 of file ItemFactory.php.

Referenced by GetItemIdByName().

Here is the caller graph for this function:

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 78 of file ItemFactory.php.

ItemFactory::ClearCaches | ( |  | ) |

Clear item information caches.

See also
  CachingEnabled()

Definition at line 663 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 | Include Variants ? (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 625 of file ItemFactory.php.

References $DB.

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 131 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 316 of file ItemFactory.php.

Referenced by GetItemByName(), GetItems(), and OAIServer\GetResponse().

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 350 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 66 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 176 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 FALSE if name not found.

Exceptions

  Exception | If item type does not have a name field defined.

Definition at line 376 of file ItemFactory.php.

References CachingEnabled().

Referenced by MetadataSchema\GetFieldIdByName(), and 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 233 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 770 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 415 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 460 of file ItemFactory.php.

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

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

Here is the caller graph for this function:

ItemFactory::GetItemsAsOptionList | ( |  | $OptionListName,
|  |  | $SelectedItemId = `NULL`,
|  |  | $SqlCondition = `NULL`,
|  |  | $DisplaySize = `1`,
|  |  | $SubmitOnChange = `FALSE`,
|  |  | $Disabled = `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)
  bool | $Disabled | If TRUE, field will not be editable.

Returns
  HTML for option list.

Definition at line 487 of file ItemFactory.php.

References GetItemNames().

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 286 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 105 of file ItemFactory.php.

References GetHighestItemId().

ItemFactory::GetNextTempItemId | ( |  | ) |

Return next available temporary item ID.

Returns
  int Temporary item ID.

Definition at line 150 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 714 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 693 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 328 of file ItemFactory.php.

Referenced by MetadataSchema\FieldExists().

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 513 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 733 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 790 of file ItemFactory.php.

References $DB.

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 | SHould Variants be included? (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 545 of file ItemFactory.php.

References $DB.

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 677 of file ItemFactory.php.

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

Here is the caller graph for this function:

## Member Data Documentation

ItemFactory::$DB
| protected

Definition at line 927 of file ItemFactory.php.

Referenced by ResourceFactory\ClearViewingPermsCache(), MetadataSchema\Create(), MetadataSchema\FieldExistsInAnySchema(), ResourceFactory\FilterNonViewableResources(), MetadataSchema\GetCanonicalFieldIdentifier(), ClassificationFactory\GetChildIds(), GetCountForItemNames(), MetadataSchema\GetPrintableFieldName(), ResourceFactory\GetResourceTotal(), RemoveItemFromOrder(), MetadataSchema\SchemaExistsWithId(), and SearchForItemNames().

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

- lib/ScoutLib/ItemFactory.php