CWIS Developer Documentation

- Home
- Main Page
- Classes
- Files

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

Public Member Functions | List of all members
ResourceFactory Class Reference

Factory for Resource objects. More...

Inheritance diagram for ResourceFactory:
[legend]
Collaboration diagram for ResourceFactory:
[legend]

## Public Member Functions
| ResourceFactory ($SchemaId=MetadataSchema::SCHEMAID_DEFAULT)
| Class constructor. More...
| DuplicateResource ($ResourceId)
| Duplicate the specified resource and return to caller. More...
| ClearQualifier ($ObjectOrId, $NewObjectOrId=NULL)
| Clear or change specific qualifier for all resources. More...
| GetRatedResourceCount ()
| Return number of resources that have ratings. More...
| GetRatedResourceUserCount ()
| Return number of users who have rated resources. More...
| GetRecentlyReleasedResources ($Count=10, $Offset=0, $MaxDaysToGoBack=90)
| Get resources sorted by descending Date of Record Release, with Date of Record Creation as the secondary sort criteria. More...
| GetResourceIdsSortedBy ($FieldName, $Ascending=TRUE, $Limit=NULL)
| Get resource IDs sorted by specified field. More...
| GetTimestampOfLastResourceModification ($OnlyReleasedResources=TRUE)
| Get date/time of when last a resource was modified. More...
| GetPossibleFieldNames ()
| Get possible field names for resources. More...
| GetMatchingResources ($ValuesToMatch)
| Find resources with values that match those specified. More...
| GetResourceCount ($FieldId, $Value, $CountType="All")
| Return the number of resources having a given value set for a specified ControlledName field, restricted to a "CountType" (e.g., All vs Released resources). More...
| GetReleasedResourceTotal ()
| Get the total number of released resources in the collection. More...
| GetResourceTotal ()
| Get the total number of resources in the collection, even if they are not released. More...
| QueueResourceCountUpdate ()
| Add a task to the queue which will update the resource counts for ControlledNames. More...
| UpdateResourceCountCallback ()
| Update the stored counts of resources per controlled name, looking at the private var $ResourceCountConditions to determine what differnt kinds of counts should be available (by default, "All" and "Released"), but this can be extended in a subclass. More...
Public Member Functions inherited from ItemFactory
| 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...

## Additional Inherited Members
Protected Attributes inherited from ItemFactory
| $DB

## Detailed Description

Factory for Resource objects.

Definition at line 13 of file ResourceFactory.php.

## Member Function Documentation

ResourceFactory::ClearQualifier | ( |  | $ObjectOrId,
|  |  | $NewObjectOrId = `NULL`
| ) |  |

Clear or change specific qualifier for all resources.

Parameters

  mixed | Qualifier ID or object to clear or change.
  mixed | New Qualifier ID or object. (OPTIONAL, defaults to NULL, which will clear old qualifier)

Definition at line 78 of file ResourceFactory.php.

ResourceFactory::DuplicateResource | ( |  | $ResourceId | ) |

Duplicate the specified resource and return to caller.

Parameters

  int | $ResourceId | ID of resource to duplicate.

Returns
  object New Resource object.

Definition at line 37 of file ResourceFactory.php.

References Resource\Create().

ResourceFactory::GetMatchingResources | ( |  | $ValuesToMatch | ) |

Find resources with values that match those specified.

(Only works for Text, Paragraph, Number, Timestamp, Date, Flag, and Url fields.)

Parameters

  array | $ValuesToMatch | Array with metadata field IDs for the index and string values to search for for the values.

Returns
  Array of Resource objects with resource IDs for index.

Definition at line 328 of file ResourceFactory.php.

References MetadataSchema\MDFTYPE_DATE, MetadataSchema\MDFTYPE_FLAG, MetadataSchema\MDFTYPE_NUMBER, MetadataSchema\MDFTYPE_PARAGRAPH, MetadataSchema\MDFTYPE_TEXT, MetadataSchema\MDFTYPE_TIMESTAMP, and MetadataSchema\MDFTYPE_URL.

ResourceFactory::GetPossibleFieldNames | ( |  | ) |

Get possible field names for resources.

Returns
  array Array of metadata field names with metadata field IDs for the index.

Definition at line 306 of file ResourceFactory.php.

ResourceFactory::GetRatedResourceCount | ( |  | ) |

Return number of resources that have ratings.

Returns
  int Resource count.

Definition at line 133 of file ResourceFactory.php.

ResourceFactory::GetRatedResourceUserCount | ( |  | ) |

Return number of users who have rated resources.

Returns
  int User count.

Definition at line 145 of file ResourceFactory.php.

ResourceFactory::GetRecentlyReleasedResources | ( |  | $Count = `10`,
|  |  | $Offset = `0`,
|  |  | $MaxDaysToGoBack = `90`
| ) |  |

Get resources sorted by descending Date of Record Release, with Date of Record Creation as the secondary sort criteria.

Parameters

  int | $Count | Maximum number of resources to return.
  int | $Offset | Starting offset of segment to return (0=beginning).
  int | $MaxDaysToGoBack | Maximum number of days to go back for resources, according to Date of Record Release.

Returns
  array Array of Resource objects.

Definition at line 162 of file ResourceFactory.php.

ResourceFactory::GetReleasedResourceTotal | ( |  | ) |

Get the total number of released resources in the collection.

Returns
  int The total number of released resources.

Definition at line 434 of file ResourceFactory.php.

ResourceFactory::GetResourceCount | ( |  | $FieldId,
|  |  | $Value,
|  |  | $CountType = `"All"`
| ) |  |

Return the number of resources having a given value set for a specified ControlledName field, restricted to a "CountType" (e.g., All vs Released resources).

Parameters

  int | $FieldId | Desired field ID number
  string | $Value | Field value to look for
  string | $CountType | (default All) specifies which resources should be counted. By default, options are "All" and "Released", but this can be extended in subclasses.

Returns
  int the number of associated resources.

Definition at line 391 of file ResourceFactory.php.

References MetadataSchema\MDFTYPE_CONTROLLEDNAME, and MetadataSchema\MDFTYPE_OPTION.

ResourceFactory::GetResourceIdsSortedBy | ( |  | $FieldName,
|  |  | $Ascending = `TRUE`,
|  |  | $Limit = `NULL`
| ) |  |

Get resource IDs sorted by specified field.

Only IDs for resources with non-empty non-null values for the specified field are returned.

Parameters

  string | $FieldName | Name of field.
  bool | $Ascending | If TRUE, sort is ascending, otherwise sort is descending.
  int | $Limit | Number of IDs to retrieve. (OPTIONAL)

Returns
  array Resource IDs.

Definition at line 199 of file ResourceFactory.php.

References MetadataSchema\MDFTYPE_DATE, MetadataSchema\MDFTYPE_NUMBER, MetadataSchema\MDFTYPE_PARAGRAPH, MetadataSchema\MDFTYPE_TEXT, MetadataSchema\MDFTYPE_TIMESTAMP, and MetadataSchema\MDFTYPE_URL.

ResourceFactory::GetResourceTotal | ( |  | ) |

Get the total number of resources in the collection, even if they are not released.

Returns
  int The total number of resources.

Definition at line 450 of file ResourceFactory.php.

ResourceFactory::GetTimestampOfLastResourceModification | ( |  | $OnlyReleasedResources = `TRUE` | ) |

Get date/time of when last a resource was modified.

Parameters

  bool | $OnlyReleasedResources | If TRUE, only resources with the Release Flag set are considered.

Returns
  int Unix timestamp or NULL if no last modification time found.

Definition at line 290 of file ResourceFactory.php.

ResourceFactory::QueueResourceCountUpdate | ( |  | ) |

Add a task to the queue which will update the resource counts for ControlledNames.

We need to divest ourselves of large instance variables before queueing the update, to avoid creating gigantic rows in the Task Queue table. This function should be called after a resource is edited and when the search database is rebuilt.

Definition at line 467 of file ResourceFactory.php.

ResourceFactory::ResourceFactory | ( |  | $SchemaId = `MetadataSchema::SCHEMAID_DEFAULT` | ) |

Class constructor.

Parameters

  int | $SchemaId | ID of schema to load resources for. (OPTIONAL, defaults to SCHEMAID_DEFAULT)

Definition at line 22 of file ResourceFactory.php.

References ItemFactory\ItemFactory().

ResourceFactory::UpdateResourceCountCallback | ( |  | ) |

Update the stored counts of resources per controlled name, looking at the private var $ResourceCountConditions to determine what differnt kinds of counts should be available (by default, "All" and "Released"), but this can be extended in a subclass.

Definition at line 486 of file ResourceFactory.php.

References ItemFactory\$DB.

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

- objects/ResourceFactory.php