CWIS Developer Documentation

- Home
- Main Page
- Namespaces
- 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
| __construct ($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 ($FieldId, $Ascending=TRUE, $Limit=NULL)
| Get resource IDs sorted by specified field. More...
| FilterNonViewableResources ($ResourceIds, $User)
| Filter a list of resources leaving only those viewable by a specified user. More...
| ClearViewingPermsCache ()
| Clear the cache of viewable resources. 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, $AllRequired=TRUE, $ReturnObjects=TRUE)
| Find resources with values that match those specified. More...
| AssociatedVisibleResourceCount ($ValueId, $User)
| Return the number of resources visible to a specified user that have a given ControlledName value set. More...
| UpdateAssociatedVisibleResourceCount ($ValueId, $UserId)
| Update the count of resources associated with a ControlledName that are visible to a specified user. 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...
Public Member Functions inherited from ItemFactory
| __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...

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

## Detailed Description

Factory for Resource objects.

Definition at line 13 of file ResourceFactory.php.

## Constructor & Destructor Documentation

ResourceFactory::__construct | ( |  | $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.

## Member Function Documentation

ResourceFactory::AssociatedVisibleResourceCount | ( |  | $ValueId,
|  |  | $User
| ) |  |

Return the number of resources visible to a specified user that have a given ControlledName value set.

Parameters

  string | $ValueId | Field valueid to look for
  User | $User | User to check

Returns
  int the number of associated resources or -1 when no count is available

Definition at line 576 of file ResourceFactory.php.

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

Clear or change specific qualifier for all resources.

Parameters

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

Definition at line 83 of file ResourceFactory.php.

ResourceFactory::ClearViewingPermsCache | ( |  | ) |

Clear the cache of viewable resources.

Definition at line 369 of file ResourceFactory.php.

References ItemFactory\$DB.

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 40 of file ResourceFactory.php.

References Resource\Create(), and Item\ItemExists().

ResourceFactory::FilterNonViewableResources | ( |  | $ResourceIds,
|  |  | $User
| ) |  |

Filter a list of resources leaving only those viewable by a specified user.

Parameters

  array | $ResourceIds | ResourceIds to check
  CWUser | $User | User to use for check

Returns
  array of ResourceIds (subset of $ResourceIds) that $User can view

Definition at line 296 of file ResourceFactory.php.

References ItemFactory\$DB.

Referenced by UpdateAssociatedVisibleResourceCount().

Here is the caller graph for this function:

ResourceFactory::GetMatchingResources | ( |  | $ValuesToMatch,
|  |  | $AllRequired = `TRUE`,
|  |  | $ReturnObjects = `TRUE`
| ) |  |

Find resources with values that match those specified.

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

Parameters

  array | $ValuesToMatch | Array with metadata field IDs (or other values that can be resolved by MetadataSchema::GetCanonicalFieldIdentifier()) for the index and string values to search for for the values.
  bool | $AllRequired | TRUE to AND conditions together, FALSE to OR them (OPTIONAL, default TRUE)
  bool | $ReturnObjects | TRUE to return Resource objects, FALSE for IDs

Returns
  Array of Resource objects with resource IDs for index.

Definition at line 424 of file ResourceFactory.php.

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

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 397 of file ResourceFactory.php.

ResourceFactory::GetRatedResourceCount | ( |  | ) |

Return number of resources that have ratings.

Returns
  int Resource count.

Definition at line 138 of file ResourceFactory.php.

ResourceFactory::GetRatedResourceUserCount | ( |  | ) |

Return number of users who have rated resources.

Returns
  int User count.

Definition at line 150 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 167 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 655 of file ResourceFactory.php.

ResourceFactory::GetResourceIdsSortedBy | ( |  | $FieldId,
|  |  | $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

  mixed | $FieldId | ID or 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 205 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 671 of file ResourceFactory.php.

References ItemFactory\$DB.

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 381 of file ResourceFactory.php.

ResourceFactory::UpdateAssociatedVisibleResourceCount | ( |  | $ValueId,
|  |  | $UserId
| ) |  |

Update the count of resources associated with a ControlledName that are visible to a specified user.

Parameters

  int | $ValueId | ControlledNameId to update.
  int | $UserId | UserId to update.

Definition at line 619 of file ResourceFactory.php.

References FilterNonViewableResources().

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

- objects/ResourceFactory.php