CWIS Developer Documentation
|
Factory for Resource objects. More...
Public Member Functions | |
__construct ($SchemaId=MetadataSchema::SCHEMAID_DEFAULT) | |
Class constructor. More... | |
Schema () | |
Get metadata schema associated with this resource factory. More... | |
DuplicateResource ($ResourceId) | |
Duplicate the specified resource and return to caller. More... | |
ImportResourcesFromXmlFile ($FileName) | |
Import resource records from XML file. 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... | |
GetPossibleFieldNames () | |
Get possible field names for resources. More... | |
GetMatchingResources ($ValuesToMatch, $AllRequired=TRUE, $ReturnObjects=TRUE, $Operator="==") | |
Find resources with values that match those specified. More... | |
AssociatedVisibleResourceCount ($ValueId, $User, $ForegroundUpdate=FALSE) | |
Return the number of resources in this schema that are visible to a specified user and 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... | |
GetVisibleResourceCount (CWUser $User) | |
Get the total number of resources visible to a specified user. More... | |
ClearVisibleResourceCountForValues ($ValueIds) | |
Clear cache of visible resources associated with a ControlledName. More... | |
ClearVisibleResourceCount ($Resource) | |
Clear database visibility caches for all the CNames referenced by a specified resource. 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... | |
ClearCaches () | |
Clear internal caches. More... | |
![]() | |
__construct ($ItemClassName, $ItemTableName, $ItemIdColumnName, $ItemNameColumnName=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... | |
GetItemIdsByNames ($Names) | |
Look up IDs for specified names. 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(), $NameExclusions=array()) | |
Retrieve items with names matching search string. More... | |
GetCountForItemNames ($SearchString, $IncludeVariants=FALSE, $UseBooleanMode=TRUE, $IdExclusions=array(), $NameExclusions=array()) | |
Retrieve count of items with names matching search string. More... | |
ReindexByItemIds ($Array) | |
Reindex supplied associative array, by replacing item names with item IDs. 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... | |
Static Public Member Functions | |
static | FlattenMultiSchemaResourceList ($ResourcesPerSchema) |
Take an array keyed by SchemaId with elements giving arrays of ResourceIds and merge it to a flattened list of ResourceIds. More... | |
static | BuildMultiSchemaResourceList ($ResourceIds) |
Take an array of ResourceIds and split it into an array keyed by SchemaId where the elements are arrays of ResourceIds for that schema. More... | |
static | ClearViewingPermsCache () |
Clear the cache of viewable resources. More... | |
Protected Attributes | |
$Schema | |
$SchemaId | |
![]() | |
$DB | |
Factory for Resource objects.
Definition at line 13 of file ResourceFactory.php.
ResourceFactory::__construct | ( | $SchemaId = MetadataSchema::SCHEMAID_DEFAULT | ) |
Class constructor.
int | $SchemaId | ID of schema to load resources for. (OPTIONAL, defaults to SCHEMAID_DEFAULT) |
Definition at line 22 of file ResourceFactory.php.
ResourceFactory::AssociatedVisibleResourceCount | ( | $ValueId, | |
$User, | |||
$ForegroundUpdate = FALSE |
|||
) |
Return the number of resources in this schema that are visible to a specified user and that have a given ControlledName value set.
string | $ValueId | Field valueid to look for |
User | $User | User to check |
bool | $ForegroundUpdate | TRUE to wait for value rather than a background update (OPTIONAL, default FALSE) |
Definition at line 805 of file ResourceFactory.php.
References UpdateAssociatedVisibleResourceCount().
|
static |
Take an array of ResourceIds and split it into an array keyed by SchemaId where the elements are arrays of ResourceIds for that schema.
array | $ResourceIds | Array of ResourceIds. |
Definition at line 987 of file ResourceFactory.php.
References ItemFactory\$DB, and $SchemaId.
Referenced by CWUserFactory\FilterNonViewableResourcesFromPerUserLists().
ResourceFactory::ClearCaches | ( | ) |
Clear internal caches.
This is primarily intended for situations where memory may have run low.
Definition at line 1031 of file ResourceFactory.php.
ResourceFactory::ClearQualifier | ( | $ObjectOrId, | |
$NewObjectOrId = NULL |
|||
) |
Clear or change specific qualifier for all resources.
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 249 of file ResourceFactory.php.
References Schema().
|
static |
Clear the cache of viewable resources.
Definition at line 1021 of file ResourceFactory.php.
References ItemFactory\$DB.
ResourceFactory::ClearVisibleResourceCount | ( | $Resource | ) |
Clear database visibility caches for all the CNames referenced by a specified resource.
Definition at line 932 of file ResourceFactory.php.
References ClearVisibleResourceCountForValues(), MetadataSchema\MDFTYPE_CONTROLLEDNAME, MetadataSchema\MDFTYPE_OPTION, and Schema().
ResourceFactory::ClearVisibleResourceCountForValues | ( | $ValueIds | ) |
Clear cache of visible resources associated with a ControlledName.
array | $ValueIds | CNIds to clear the cache for. |
Definition at line 918 of file ResourceFactory.php.
Referenced by ClearVisibleResourceCount().
ResourceFactory::DuplicateResource | ( | $ResourceId | ) |
Duplicate the specified resource and return to caller.
int | $ResourceId | ID of resource to duplicate. |
Definition at line 47 of file ResourceFactory.php.
References Resource\Create(), Item\ItemExists(), and Schema().
ResourceFactory::FilterNonViewableResources | ( | $ResourceIds, | |
$User | |||
) |
Filter a list of resources leaving only those viewable by a specified user.
Definition at line 464 of file ResourceFactory.php.
References Item\ItemExists(), and Schema().
Referenced by GetRecentlyReleasedResources(), GetVisibleResourceCount(), and UpdateAssociatedVisibleResourceCount().
|
static |
Take an array keyed by SchemaId with elements giving arrays of ResourceIds and merge it to a flattened list of ResourceIds.
array | $ResourcesPerSchema | Array of per-schema ResourceIds. |
Definition at line 968 of file ResourceFactory.php.
References $SchemaId.
Referenced by CWUserFactory\FilterNonViewableResourcesFromPerUserLists().
ResourceFactory::GetMatchingResources | ( | $ValuesToMatch, | |
$AllRequired = TRUE , |
|||
$ReturnObjects = TRUE , |
|||
$Operator = "==" |
|||
) |
Find resources with values that match those specified.
(Only works for Text, Paragraph, Number, Timestamp, Date, Flag, Url, Point, and User fields.)
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 |
string | $Operator | Operator for comparison, (OPTIONAL, default ==) |
Definition at line 617 of file ResourceFactory.php.
References MetadataSchema\GetCanonicalFieldIdentifier(), MetadataSchema\MDFTYPE_DATE, MetadataSchema\MDFTYPE_FLAG, MetadataSchema\MDFTYPE_NUMBER, MetadataSchema\MDFTYPE_PARAGRAPH, MetadataSchema\MDFTYPE_POINT, MetadataSchema\MDFTYPE_TEXT, MetadataSchema\MDFTYPE_TIMESTAMP, MetadataSchema\MDFTYPE_URL, MetadataSchema\MDFTYPE_USER, and Schema().
ResourceFactory::GetPossibleFieldNames | ( | ) |
Get possible field names for resources.
Definition at line 590 of file ResourceFactory.php.
References Schema().
ResourceFactory::GetRatedResourceCount | ( | ) |
Return number of resources that have ratings.
Definition at line 303 of file ResourceFactory.php.
ResourceFactory::GetRatedResourceUserCount | ( | ) |
Return number of users who have rated resources.
Definition at line 315 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.
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. |
Definition at line 332 of file ResourceFactory.php.
References FilterNonViewableResources().
ResourceFactory::GetReleasedResourceTotal | ( | ) |
Get the total number of released resources in the collection.
Definition at line 955 of file ResourceFactory.php.
References User\GetAnonymousUser(), and GetVisibleResourceCount().
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.
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) |
Definition at line 376 of file ResourceFactory.php.
References MetadataSchema\MDFTYPE_DATE, MetadataSchema\MDFTYPE_NUMBER, MetadataSchema\MDFTYPE_PARAGRAPH, MetadataSchema\MDFTYPE_TEXT, MetadataSchema\MDFTYPE_TIMESTAMP, MetadataSchema\MDFTYPE_URL, and Schema().
ResourceFactory::GetResourceTotal | ( | ) |
Get the total number of resources in the collection, even if they are not released.
Definition at line 1008 of file ResourceFactory.php.
ResourceFactory::GetVisibleResourceCount | ( | CWUser | $User | ) |
Get the total number of resources visible to a specified user.
Definition at line 901 of file ResourceFactory.php.
References FilterNonViewableResources().
Referenced by GetReleasedResourceTotal().
ResourceFactory::ImportResourcesFromXmlFile | ( | $FileName | ) |
Import resource records from XML file.
The file should contain a top-level "ResourceCollection" tag, inside of which should be one or more <Resource> tags. Within the <Resource> tag are tags giving metadata field values, with the tag names constructed from the alphanumeric part of the field names (e.g. Title in a <Title> tag, Date Record Checked in a <DateRecordChecked> tag, etc). See install/SampleResource.xml for an example.
string | $FileName | Name of XML file. |
Exception | When input file cannot be opened. |
Definition at line 95 of file ResourceFactory.php.
References ControlledName\Create(), Classification\Create(), Resource\Create(), MetadataSchema\MDFTYPE_CONTROLLEDNAME, MetadataSchema\MDFTYPE_DATE, MetadataSchema\MDFTYPE_FILE, MetadataSchema\MDFTYPE_FLAG, MetadataSchema\MDFTYPE_IMAGE, MetadataSchema\MDFTYPE_NUMBER, MetadataSchema\MDFTYPE_OPTION, MetadataSchema\MDFTYPE_PARAGRAPH, MetadataSchema\MDFTYPE_POINT, MetadataSchema\MDFTYPE_REFERENCE, MetadataSchema\MDFTYPE_TEXT, MetadataSchema\MDFTYPE_TIMESTAMP, MetadataSchema\MDFTYPE_TREE, MetadataSchema\MDFTYPE_URL, MetadataSchema\MDFTYPE_USER, and Schema().
ResourceFactory::Schema | ( | ) |
Get metadata schema associated with this resource factory.
Definition at line 37 of file ResourceFactory.php.
References $Schema.
Referenced by __construct(), ClearQualifier(), ClearVisibleResourceCount(), DuplicateResource(), FilterNonViewableResources(), GetMatchingResources(), GetPossibleFieldNames(), GetResourceIdsSortedBy(), and ImportResourcesFromXmlFile().
ResourceFactory::UpdateAssociatedVisibleResourceCount | ( | $ValueId, | |
$UserId | |||
) |
Update the count of resources associated with a ControlledName that are visible to a specified user.
int | $ValueId | ControlledNameId to update. |
int | $UserId | UserId to update. |
Definition at line 864 of file ResourceFactory.php.
References FilterNonViewableResources().
Referenced by AssociatedVisibleResourceCount().
|
protected |
Definition at line 1043 of file ResourceFactory.php.
Referenced by Schema().
|
protected |
Definition at line 1044 of file ResourceFactory.php.
Referenced by __construct(), BuildMultiSchemaResourceList(), and FlattenMultiSchemaResourceList().