CWIS Developer Documentation
|
Represents a "resource" in CWIS. More...
Public Member Functions | |
__construct ($ResourceId) | |
Object constructor for loading an existing resource. More... | |
Delete () | |
Remove resource (and accompanying associations) from database and delete any associated files. More... | |
Status () | |
Retrieve result of last operation if available. More... | |
Id () | |
Retrieve numerical resource ID. More... | |
SchemaId () | |
Retrieve ID of schema for resource. More... | |
Schema () | |
Get MetadataSchema for resource. More... | |
IsTempResource ($NewSetting=NULL) | |
Get/set whether resource is a temporary record. More... | |
GetViewPageUrl () | |
Retrieve view page URL for this resource. More... | |
Get ($Field, $ReturnObject=FALSE, $IncludeVariants=FALSE) | |
Retrieve value using field name or field object. More... | |
GetForDisplay ($FieldNameOrObject, $ReturnObject=TRUE, $IncludeVariants=FALSE) | |
Retrieve value using field name or field object, signaling EVENT_FIELD_DISPLAY_FILTER to allow other code to possibly modify the value before it's returned. More... | |
GetByField ($FieldNameOrObject, $ReturnObject=FALSE, $IncludeVariants=FALSE) | |
Old method for retrieving values, deprecated in favor of Get(). More... | |
GetByFieldId ($FieldId, $ReturnObject=FALSE, $IncludeVariants=FALSE) | |
Retrieve value using field ID. More... | |
GetAsArray ($IncludeDisabledFields=FALSE, $ReturnObjects=TRUE) | |
Retrieve all resource values as an array. More... | |
GetMapped ($MappedName, $ReturnObject=FALSE, $IncludeVariants=FALSE) | |
Retrieve value using standard (mapped) field name. More... | |
GetQualifier ($FieldName, $ReturnObject=TRUE) | |
Retrieve qualifier by field name. More... | |
GetQualifierByFieldId ($FieldId, $ReturnObject=TRUE) | |
Retrieve qualifier by field ID. More... | |
GetQualifierByField ($Field, $ReturnObject=TRUE) | |
Retrieve qualifier by Field object. More... | |
FieldIsSet ($FieldNameOrObject, $IgnorePadding=FALSE) | |
Determine if the value for a field is set. More... | |
GetImageUrls ($FieldNameOrObject, $ImageSize=SPTImage::SIZE_FULL) | |
Get URLs for images, returning CleanURLs when possible and direct paths to image files otherwise. More... | |
Set ($Field, $NewValue, $Reset=FALSE) | |
Set value using field name or field object. More... | |
SetByField ($Field, $NewValue) | |
Method replaced by Resource::Set(), preserved for backward compatibility. More... | |
SetByFieldId ($FieldId, $NewValue) | |
Set field value using field ID. More... | |
SetQualifier ($FieldName, $NewValue) | |
Set qualifier using field name. More... | |
SetQualifierByFieldId ($FieldId, $NewValue) | |
Set qualifier using field ID. More... | |
SetQualifierByField ($Field, $NewValue) | |
Set qualifier using field object. More... | |
ClearByFieldId ($FieldId, $ValueToClear=NULL) | |
Clear field value specified by field ID. More... | |
Clear ($Field, $ValueToClear=NULL) | |
Clear field value. More... | |
ClearByField ($Field, $ValueToClear=NULL) | |
Clear field value. More... | |
Classifications () | |
Get 2D array of classifications associated with resource. More... | |
CumulativeRating () | |
Get cumulative rating (range is usually 0-100) More... | |
ScaledCumulativeRating () | |
Return cumulative rating scaled to 1/10th. More... | |
NumberOfRatings () | |
Get current number of ratings for resource. More... | |
Rating ($NewRating=NULL, $UserId=NULL) | |
Get/set rating by a specific user for resource. More... | |
Comments () | |
Get comments for resource. More... | |
NumberOfComments () | |
Get current number of comments for resource. More... | |
UserCanView (User $User, $AllowHooksToModify=TRUE) | |
Determine if the given user can view the resource, e.g., on the full record page. More... | |
UserCanEdit ($User) | |
Determine if the given user can edit the resource. More... | |
UserCanAuthor ($User) | |
Determine if the given user can edit the resource. More... | |
UserCanModify ($User) | |
Check if the user is allowed to modify (Edit for perm resources, Author for temp) a specified resources. More... | |
UserCanViewField ($User, $FieldOrFieldName) | |
Check whether user is allowed to view specified metadata field. More... | |
UserCanEditField ($User, $FieldOrFieldName) | |
Check whether user is allowed to edit specified metadata field. More... | |
UserCanAuthorField ($User, $FieldOrFieldName) | |
Check whether user is allowed to author specified metadata field. More... | |
UserCanModifyField ($User, $FieldOrFieldName) | |
Check whether user is allowed to modify (Edit for perm resources, Author for temp) specified metadata field. More... | |
QueueSearchAndRecommenderUpdate () | |
Update search and recommender system DBs. More... | |
Static Public Member Functions | |
static | Create ($SchemaId) |
Create a new resource. More... | |
static | GetSchemaForResource ($ResourceId) |
Get schema ID for specified resource(s). More... | |
Protected Attributes | |
$DB | |
Represents a "resource" in CWIS.
Definition at line 13 of file Resource.php.
Resource::__construct | ( | $ResourceId | ) |
Object constructor for loading an existing resource.
(To create a new resource, use Resource::Create().)
int | $ResourceId | ID of resource to load. |
Definition at line 24 of file Resource.php.
References CumulativeRating(), Id(), and SchemaId().
Resource::Classifications | ( | ) |
Get 2D array of classifications associated with resource.
Definition at line 2189 of file Resource.php.
Referenced by Delete().
Resource::Clear | ( | $Field, | |
$ValueToClear = NULL |
|||
) |
Clear field value.
object | $Field | Metadata field. |
mixed | $ValueToClear | Specific value to clear (for fields that support multiple values). (OPTIONAL) |
Definition at line 1825 of file Resource.php.
References $DB, SPTImage\ClearImageSymlinksForResource(), Get(), Id(), IsTempResource(), 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().
Referenced by ClearByField(), and ClearByFieldId().
Resource::ClearByField | ( | $Field, | |
$ValueToClear = NULL |
|||
) |
Clear field value.
DEPRECATED in favor of Clear().
object | $Field | Metadata field. |
mixed | $ValueToClear | Specific value to clear (for fields that support multiple values). (OPTIONAL) |
Definition at line 2177 of file Resource.php.
References Clear().
Referenced by Set().
Resource::ClearByFieldId | ( | $FieldId, | |
$ValueToClear = NULL |
|||
) |
Clear field value specified by field ID.
int | $FieldId | Metadata field ID. |
mixed | $ValueToClear | Specific value to clear (for fields that support multiple values). (OPTIONAL) |
Definition at line 1813 of file Resource.php.
Resource::Comments | ( | ) |
Get comments for resource.
Definition at line 2368 of file Resource.php.
References Id().
|
static |
Create a new resource.
int | $SchemaId | ID of metadata schema for new resource. |
Exception | If resource creation failed. |
Definition at line 66 of file Resource.php.
References $DB, Id(), MetadataSchema\MDFTYPE_FLAG, MetadataSchema\MDFTYPE_NUMBER, MetadataSchema\MDFTYPE_OPTION, MetadataSchema\MDFTYPE_POINT, MetadataSchema\MDFTYPE_TEXT, MetadataSchema\MDFTYPE_TIMESTAMP, MetadataSchema\SCHEMAID_DEFAULT, and MetadataField\UPDATEMETHOD_ONRECORDCREATE.
Referenced by CWUserFactory\CreateNewUser(), ResourceFactory\DuplicateResource(), and Resource_Test\testGetandSet().
Resource::CumulativeRating | ( | ) |
Get cumulative rating (range is usually 0-100)
Definition at line 2222 of file Resource.php.
Referenced by __construct(), GetAsArray(), NumberOfRatings(), and ScaledCumulativeRating().
Resource::Delete | ( | ) |
Remove resource (and accompanying associations) from database and delete any associated files.
Definition at line 169 of file Resource.php.
References $DB, Classifications(), and Id().
Referenced by CWUser\Delete().
Resource::FieldIsSet | ( | $FieldNameOrObject, | |
$IgnorePadding = FALSE |
|||
) |
Determine if the value for a field is set.
mixed | $FieldNameOrObject | Full name of field or a Field object. |
bool | $IgnorePadding | Optional flag for ignoring whitespace padding for text, paragraph, number, and URL fields. |
Definition at line 1060 of file Resource.php.
References Get(), 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().
Resource::Get | ( | $Field, | |
$ReturnObject = FALSE , |
|||
$IncludeVariants = FALSE |
|||
) |
Retrieve value using field name or field object.
mixed | $Field | Field ID or full name of field or a Field object. |
bool | $ReturnObject | For field types that can return multiple values, if TRUE, returns array of objects, else returns array of values. Defaults to FALSE. |
bool | $IncludeVariants | If TRUE, includes variants in return value. Only applicable for ControlledName fields. |
Definition at line 416 of file Resource.php.
References FileFactory\GetFilesForResource(), Id(), 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, Schema(), SchemaId(), and Set().
Referenced by Clear(), FieldIsSet(), CWUser\Get(), GetAsArray(), GetByField(), GetByFieldId(), GetForDisplay(), GetImageUrls(), GetMapped(), GetQualifierByField(), and Set().
Resource::GetAsArray | ( | $IncludeDisabledFields = FALSE , |
|
$ReturnObjects = TRUE |
|||
) |
Retrieve all resource values as an array.
bool | $IncludeDisabledFields | Include values for disabled fields. (OPTIONAL, defaults to FALSE) |
bool | $ReturnObjects | If TRUE, an object is returned for field types where appropriate, in the same fashion as Resource::Get() (OPTIONAL, defaults to TRUE) |
Definition at line 834 of file Resource.php.
References CumulativeRating(), Get(), GetQualifierByField(), Id(), and Schema().
Resource::GetByField | ( | $FieldNameOrObject, | |
$ReturnObject = FALSE , |
|||
$IncludeVariants = FALSE |
|||
) |
Old method for retrieving values, deprecated in favor of Get().
mixed | $FieldNameOrObject | Full name of field or a Field object. |
bool | $ReturnObject | For field types that can return multiple values, if TRUE, returns array of objects, else returns array of values. Defaults to FALSE. |
bool | $IncludeVariants | If TRUE, includes variants in return value. Only applicable for ControlledName fields. |
Definition at line 796 of file Resource.php.
References Get().
Resource::GetByFieldId | ( | $FieldId, | |
$ReturnObject = FALSE , |
|||
$IncludeVariants = FALSE |
|||
) |
Retrieve value using field ID.
int | $FieldId | ID of field. |
bool | $ReturnObject | For field types that can return multiple values, if TRUE, returns array of objects, else returns array of values. Defaults to FALSE. |
bool | $IncludeVariants | If TRUE, includes variants in return value. Only applicable for ControlledName fields. |
Definition at line 816 of file Resource.php.
References Get().
Resource::GetForDisplay | ( | $FieldNameOrObject, | |
$ReturnObject = TRUE , |
|||
$IncludeVariants = FALSE |
|||
) |
Retrieve value using field name or field object, signaling EVENT_FIELD_DISPLAY_FILTER to allow other code to possibly modify the value before it's returned.
Note that the default for the $ReturnObject parameter is TRUE, which is the opposite of the default for the same parameter to all other Resource::Get*() methods.
mixed | $FieldNameOrObject | Full name of field or a Field object. |
bool | $ReturnObject | For field types that can return multiple values, if TRUE, returns array of objects, else returns array of values. (OPTIONAL, defaults to TRUE) |
bool | $IncludeVariants | If TRUE, includes variants in return value. Only applicable for ControlledName fields. (OPTIONAL, defaults to FALSE) |
Definition at line 760 of file Resource.php.
Resource::GetImageUrls | ( | $FieldNameOrObject, | |
$ImageSize = SPTImage::SIZE_FULL |
|||
) |
Get URLs for images, returning CleanURLs when possible and direct paths to image files otherwise.
mixed | $FieldNameOrObject | Full field name, FieldId, or a MetadataField object. |
mixed | $ImageSize | Desired size as an SPTImage::SIZE_ constant. |
Definition at line 1130 of file Resource.php.
Resource::GetMapped | ( | $MappedName, | |
$ReturnObject = FALSE , |
|||
$IncludeVariants = FALSE |
|||
) |
Retrieve value using standard (mapped) field name.
string | $MappedName | Standard field name. |
bool | $ReturnObject | For field types that can return multiple values, if TRUE, returns array of objects, else returns array of values. Defaults to FALSE. |
bool | $IncludeVariants | If TRUE, includes variants in return value. Only applicable for ControlledName fields. Defaults to FALSE. |
Definition at line 880 of file Resource.php.
Resource::GetQualifier | ( | $FieldName, | |
$ReturnObject = TRUE |
|||
) |
Retrieve qualifier by field name.
string | $FieldName | Full name of field. |
bool | $ReturnObject | If TRUE, return Qualifier objects, else return qualifier IDs. Defaults to TRUE. |
Definition at line 898 of file Resource.php.
References GetQualifierByField(), and Schema().
Resource::GetQualifierByField | ( | $Field, | |
$ReturnObject = TRUE |
|||
) |
Retrieve qualifier by Field object.
MetadataField | $Field | Field object. |
bool | $ReturnObject | If TRUE, return Qualifier objects, else return qualifier IDs. Defaults to TRUE. |
Definition at line 926 of file Resource.php.
References $Items, Get(), MetadataSchema\MDFTYPE_CONTROLLEDNAME, MetadataSchema\MDFTYPE_OPTION, and MetadataSchema\MDFTYPE_TREE.
Referenced by GetAsArray(), GetQualifier(), and GetQualifierByFieldId().
Resource::GetQualifierByFieldId | ( | $FieldId, | |
$ReturnObject = TRUE |
|||
) |
Retrieve qualifier by field ID.
int | $FieldId | ID of field. |
int | $ReturnObject | If TRUE, return Qualifier objects, else return qualifier IDs. Defaults to TRUE. |
Definition at line 912 of file Resource.php.
References GetQualifierByField(), and Schema().
|
static |
Get schema ID for specified resource(s).
int | $ResourceId | ID of resource or array of IDs of resources. |
Definition at line 2529 of file Resource.php.
References $DB.
Resource::GetViewPageUrl | ( | ) |
Retrieve view page URL for this resource.
Definition at line 392 of file Resource.php.
Resource::Id | ( | ) |
Retrieve numerical resource ID.
Definition at line 293 of file Resource.php.
Referenced by __construct(), Classifications(), Clear(), Comments(), Create(), Delete(), Get(), GetAsArray(), GetImageUrls(), GetViewPageUrl(), IsTempResource(), NumberOfComments(), NumberOfRatings(), Rating(), CWUser\ResourceId(), and Set().
Resource::IsTempResource | ( | $NewSetting = NULL | ) |
Get/set whether resource is a temporary record.
bool | $NewSetting | TRUE/FALSE setting for whether resource is temporary. (OPTIONAL) |
Definition at line 322 of file Resource.php.
References $DB, Id(), and SchemaId().
Referenced by Clear(), QueueSearchAndRecommenderUpdate(), and Set().
Resource::NumberOfComments | ( | ) |
Get current number of comments for resource.
Definition at line 2391 of file Resource.php.
References Id().
Resource::NumberOfRatings | ( | ) |
Get current number of ratings for resource.
Definition at line 2247 of file Resource.php.
References CumulativeRating(), and Id().
Resource::QueueSearchAndRecommenderUpdate | ( | ) |
Update search and recommender system DBs.
Definition at line 2512 of file Resource.php.
References IsTempResource().
Resource::Rating | ( | $NewRating = NULL , |
|
$UserId = NULL |
|||
) |
Get/set rating by a specific user for resource.
int | $NewRating | New rating value. |
int | $UserId | ID of user rating resource. |
Definition at line 2278 of file Resource.php.
Resource::ScaledCumulativeRating | ( | ) |
Return cumulative rating scaled to 1/10th.
(Range is usually 0-10.)
Definition at line 2231 of file Resource.php.
References CumulativeRating().
Resource::Schema | ( | ) |
Get MetadataSchema for resource.
Definition at line 311 of file Resource.php.
Referenced by Clear(), ClearByFieldId(), FieldIsSet(), Get(), GetAsArray(), GetForDisplay(), GetImageUrls(), GetMapped(), GetQualifier(), GetQualifierByFieldId(), GetViewPageUrl(), Set(), SetQualifier(), and SetQualifierByFieldId().
Resource::SchemaId | ( | ) |
Retrieve ID of schema for resource.
Definition at line 302 of file Resource.php.
Referenced by __construct(), Get(), IsTempResource(), and Set().
Resource::Set | ( | $Field, | |
$NewValue, | |||
$Reset = FALSE |
|||
) |
Set value using field name or field object.
mixed | $Field | Field ID or full name of field or a Field object. |
mixed | $NewValue | New value for field. |
bool | $Reset | When TRUE Controlled Names, Classifications, and Options will be set to contain ONLY the contents of NewValue, rather than appending $NewValue to the current value. |
Exception | When attempting to set a value for a field that is part of a different schema than the resource. |
InvalidArgumentException | When attempting to set a controlled name with an invalid ID. |
Definition at line 1165 of file Resource.php.
References $DB, Classification\CLASSSTAT_OK, ClearByField(), SPTImage\ClearImageSymlinksForResource(), FileFactory\Copy(), Get(), Id(), IsTempResource(), 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, Schema(), SchemaId(), and ControlledName\STATUS_OK.
Referenced by Get(), CWUser\Set(), SetByField(), and SetByFieldId().
Resource::SetByField | ( | $Field, | |
$NewValue | |||
) |
Method replaced by Resource::Set(), preserved for backward compatibility.
object | $Field | MetadataField object. |
mixed | $NewValue | New value for field. |
Definition at line 1735 of file Resource.php.
References Set().
Resource::SetByFieldId | ( | $FieldId, | |
$NewValue | |||
) |
Set field value using field ID.
int | $FieldId | Metadata field ID. |
mixed | $NewValue | Value to set. |
Definition at line 1747 of file Resource.php.
References Set().
Resource::SetQualifier | ( | $FieldName, | |
$NewValue | |||
) |
Set qualifier using field name.
string | $FieldName | Metadata field name. |
mixed | $NewValue | Qualifier object or ID. |
Definition at line 1757 of file Resource.php.
References Schema(), and SetQualifierByField().
Resource::SetQualifierByField | ( | $Field, | |
$NewValue | |||
) |
Set qualifier using field object.
object | $Field | Metadata field. |
mixed | $NewValue | Qualifier object or ID. |
Definition at line 1779 of file Resource.php.
Referenced by SetQualifier(), and SetQualifierByFieldId().
Resource::SetQualifierByFieldId | ( | $FieldId, | |
$NewValue | |||
) |
Set qualifier using field ID.
int | $FieldId | Metadata field ID. |
mixed | $NewValue | Qualifier object or ID. |
Definition at line 1768 of file Resource.php.
References Schema(), and SetQualifierByField().
Resource::Status | ( | ) |
Retrieve result of last operation if available.
Definition at line 284 of file Resource.php.
Resource::UserCanAuthor | ( | $User | ) |
Determine if the given user can edit the resource.
The result of this method can be modified via the EVENT_RESOURCE_EDIT_PERMISSION_CHECK event.
Definition at line 2443 of file Resource.php.
Resource::UserCanAuthorField | ( | $User, | |
$FieldOrFieldName | |||
) |
Check whether user is allowed to author specified metadata field.
Definition at line 2488 of file Resource.php.
Resource::UserCanEdit | ( | $User | ) |
Determine if the given user can edit the resource.
The result of this method can be modified via the EVENT_RESOURCE_EDIT_PERMISSION_CHECK event.
Definition at line 2432 of file Resource.php.
Resource::UserCanEditField | ( | $User, | |
$FieldOrFieldName | |||
) |
Check whether user is allowed to edit specified metadata field.
Definition at line 2477 of file Resource.php.
Resource::UserCanModify | ( | $User | ) |
Check if the user is allowed to modify (Edit for perm resources, Author for temp) a specified resources.
Definition at line 2454 of file Resource.php.
Resource::UserCanModifyField | ( | $User, | |
$FieldOrFieldName | |||
) |
Check whether user is allowed to modify (Edit for perm resources, Author for temp) specified metadata field.
Definition at line 2500 of file Resource.php.
Resource::UserCanView | ( | User | $User, |
$AllowHooksToModify = TRUE |
|||
) |
Determine if the given user can view the resource, e.g., on the full record page.
The result of this method can be modified via the EVENT_RESOURCE_VIEW_PERMISSION_CHECK event.
User | $User | User to check against. |
bool | $AllowHooksToModify | TRUE if hook functions should be allowed to modify the return value (OPTIONAL default TRUE). |
Definition at line 2421 of file Resource.php.
Resource::UserCanViewField | ( | $User, | |
$FieldOrFieldName | |||
) |
Check whether user is allowed to view specified metadata field.
Definition at line 2466 of file Resource.php.
|
protected |
Definition at line 2575 of file Resource.php.
Referenced by Classifications(), Clear(), Create(), Delete(), GetSchemaForResource(), IsTempResource(), Rating(), and Set().