CWIS Developer Documentation
Public Member Functions | List of all members
ResourceFactory Class Reference

Factory for Resource objects. More...

Inheritance diagram for ResourceFactory:
Inheritance graph
[legend]
Collaboration diagram for ResourceFactory:
Collaboration graph
[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 ($FieldName, $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)
 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.

Constructor & Destructor Documentation

ResourceFactory::__construct (   $SchemaId = MetadataSchema::SCHEMAID_DEFAULT)

Class constructor.

Parameters
int$SchemaIdID of schema to load resources for. (OPTIONAL, defaults to SCHEMAID_DEFAULT)

Definition at line 22 of file ResourceFactory.php.

References ItemFactory\ItemFactory().

Member Function Documentation

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

Clear or change specific qualifier for all resources.

Parameters
mixedQualifier ID or object to clear or change.
mixedNew Qualifier ID or object. (OPTIONAL, defaults to NULL, which will clear old qualifier)

Definition at line 77 of file ResourceFactory.php.

ResourceFactory::ClearViewingPermsCache ( )

Clear the cache of viewable resources.

Definition at line 349 of file ResourceFactory.php.

References ItemFactory\$DB.

ResourceFactory::DuplicateResource (   $ResourceId)

Duplicate the specified resource and return to caller.

Parameters
int$ResourceIdID of resource to duplicate.
Returns
object New Resource object.

Definition at line 37 of file ResourceFactory.php.

References Resource\Create().

ResourceFactory::FilterNonViewableResources (   $ResourceIds,
  $User 
)

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

Parameters
array$ResourceIdsto check
CWUser$Userto use for check
Returns
array of ResourceIds (subset of $ResourceIds) that $User can view

Definition at line 289 of file ResourceFactory.php.

References ItemFactory\$DB.

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$ValuesToMatchArray 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 399 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 377 of file ResourceFactory.php.

ResourceFactory::GetRatedResourceCount ( )

Return number of resources that have ratings.

Returns
int Resource count.

Definition at line 132 of file ResourceFactory.php.

ResourceFactory::GetRatedResourceUserCount ( )

Return number of users who have rated resources.

Returns
int User count.

Definition at line 144 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$CountMaximum number of resources to return.
int$OffsetStarting offset of segment to return (0=beginning).
int$MaxDaysToGoBackMaximum number of days to go back for resources, according to Date of Record Release.
Returns
array Array of Resource objects.

Definition at line 161 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 509 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$FieldIdDesired field ID number
string$ValueField 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 462 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$FieldNameName of field.
bool$AscendingIf TRUE, sort is ascending, otherwise sort is descending.
int$LimitNumber of IDs to retrieve. (OPTIONAL)
Returns
array Resource IDs.

Definition at line 198 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 525 of file ResourceFactory.php.

ResourceFactory::GetTimestampOfLastResourceModification (   $OnlyReleasedResources = TRUE)

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

Parameters
bool$OnlyReleasedResourcesIf 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 361 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 542 of file ResourceFactory.php.

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

References ItemFactory\$DB.


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