SnapResource Class Reference
[File Objects]

Wrapper class for Snap2 resources. More...

Inheritance diagram for SnapResource:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 countRelevantVersions ($constraint=array(), $limit=array(), $order=array())
 Retrieves count relevant versions of this resource.
 countVersions ($constraint=array(), $limit=array(), $order=array())
 Retrieves number of versions in this resource, using constraints.
 createVersion ($oldVersion=null)
 Creates a new version for this resource.
 listActions ($constraint=array(), $limit=array(), $order=array())
 Lists all actions that have occurred on versions of this resource.
 listRelevantVersions ($constraint=array(), $limit=array(), $order=array())
 Retrieves relevant versions of this resource.
 listVersions ($constraint=array(), $limit=array(), $order=array())
 Retrieves array of objects representing the versions of this resource.
 setValidDate ($validDate)
 Changes the valid date field associated with this resource.
 toCacheDump ()
 INSERT BRIEF DESCRIPTION HERE.

Static Public Member Functions

static _cancelDestroy ()
 INSERT BRIEF DESCRIPTION HERE.
static lookup ($path)
 Retrieves a resource by path.
static retrieve ($id)
 Retrieves a resource by ID.

Public Attributes

const TYPE_CSS
 CSS Stylesheets.
const TYPE_HTML
 Plain Old HTML (no external objects).
const TYPE_INTERACTIVATE_INSTRUCTOR
 Interactivate Instructors.
const TYPE_INTERACTIVATE_LESSON
 Interactivate Lessons.
const TYPE_JAVASCRIPT
 Javascript Files.
const TYPE_LESSONPLAN
 Experimental lesson plan XML.
const TYPE_MEDIA_AGENTSHEETS
 Agentsheets Applets.
const TYPE_MEDIA_DOCUMENT
 PDF and MS Word documents.
const TYPE_MEDIA_FILE
 Generic file XML.
const TYPE_MEDIA_IMAGE
 Images.
const TYPE_MEDIA_INTERACTIVATE
 Interactivate Java Applets.
const TYPE_MEDIA_NETLOGO
 Netlogo Applets.
const TYPE_STDXML
 Standard XML 3.0 (no external objects).

Static Public Attributes

static $ATTRIBUTES


Detailed Description

Wrapper class for Snap2 resources.

A resource represents one logical piece of content. It is a field, just like directories (see SnapFile), and thus can be linked, unlinked, deleted, etc. It cannot have its own children, though. Instead of children, it has zero or more versions, which store particular revisions of the content logically contained in the resource. The resource itself does not store content. Two special versions will be considered active and when the content needs to be gathered from the resource, it comes from one of these versions. One version is the "dev" version and the other is the "live" version. If the server is a dev server (such as newdev), then the dev version is used for content, or the live version if there is no dev version. If the server is a production server (such as "www"), then only the live version is consulted. If there is no live version, then there is no active content for the resource.

Resources also have types. The type determines the nature of the content. The basic types are HTML and XML, in which case, the versions simply store raw HTML or XML in their content field. Other types support various types of media, such as images and applets. These types require management of external files and that involves a lot of complexity. Content modules (see SnapContent and its derivates) handle these details and make it as easy as possible to add new content types.

Attributes:
  • id: Resource ID
  • name: Descriptive name of resource
  • description: Description of resource
  • created: Creation date/time of resource
  • modified: Date/time of last modification to resource metadata
  • canonParentId: ID of canonical parent directory
  • refCount: Number of links to this resource, including canonical link
  • contentType: Resource content type; one of the TYPE_* constants
  • approvalDate: Most recent date/time when a version was approved as live for this resource
  • validDate: User-defined date for "validity" of resource
  • liveVersionId: ID of version that is currently live for this resource
  • devVersionId: ID of version that is currently marked as dev for this resource
  • nextOrdinal: Next ordinal to be used when creating versions

Fields:
  • maxOrdinal: Highest ordinal of all the versions for this resource
  • devVersion: SnapVersion object corresponding to the dev version of this resource
  • liveVersion: SnapVersion object corresponding to the live version of this resource
  • activeVersion: SnapVersion object corresponding to the active version of this resource


Member Function Documentation

static SnapResource::_cancelDestroy (  )  [static]

INSERT BRIEF DESCRIPTION HERE.

INSERT FULL DESCRIPTION HERE

Returns:
[TYPE]: RETURN DESCRIPTION

SnapResource::countRelevantVersions ( constraint = array(),
limit = array(),
order = array() 
)

Retrieves count relevant versions of this resource.

A relevant version is one that is not defunct, or is defunct but is a direct "parent" of a non-defunct version. See listVersions() for more on the constraint parameters.

Parameters:
$constraint [array]: trim down results by conditions
$limit [array]: limit number of results by count and offset
$order [array]: sort results
Returns:
[integer]: number of versions for given constraints

SnapResource::countVersions ( constraint = array(),
limit = array(),
order = array() 
)

Retrieves number of versions in this resource, using constraints.

See the documentation for listContents() for more on the parameters to this method

Parameters:
$constraint [array]: trim down results by conditions
$limit [array]: limit number of results by count and offset
$order [array]: sort results
Returns:
[integer]: number of results given constraints

SnapResource::createVersion ( oldVersion = null  ) 

Creates a new version for this resource.

The version can be created out of nothing, or it can be created as a copy of an existing version. In the latter case, pass in a SnapVersion object as the sole parameter to this method. The new version will be in the 'In Progress' state and will be owned by the current user. You must have the Edit permission on this resource to create a new version.

Parameters:
$oldVersion [SnapVersion]: version to copy from (if desired)
Returns:
[SnapVersion]: newly created version object, or null on failure

SnapResource::listActions ( constraint = array(),
limit = array(),
order = array() 
)

Lists all actions that have occurred on versions of this resource.

Actions are things like "Edit", "Submit", etc. That is, changes in state of a version. This is useful for tracking progress. This method will list those actions. The result array consists of subarrays which contain three fields: 'uid', which is the user ID of the user who performed the action; 'action', which is a string naming the action; 'actionTime', which is a MySQL timestamp of when the action occurred; and 'id', which is the ID of the version upon which the action was performed. See listContents() for more on the constraint parameters.

Parameters:
$constraint [array]: trim down results by conditions
$limit [array]: limit number of results by count and offset
$order [array]: sort results
Returns:
[array]: array of action info arrays (see description above), or null on error

SnapResource::listRelevantVersions ( constraint = array(),
limit = array(),
order = array() 
)

Retrieves relevant versions of this resource.

A relevant version is one that is not defunct, or is defunct but is a direct "parent" of a non-defunct version. See listVersions() for more on the constraint parameters.

Parameters:
$constraint [array]: trim down results by conditions
$limit [array]: limit number of results by count and offset
$order [array]: sort results
Returns:
[array]: array of SnapVersion objects for given constraints

SnapResource::listVersions ( constraint = array(),
limit = array(),
order = array() 
)

Retrieves array of objects representing the versions of this resource.

This method allows you to trim down the result set and sort it, mostly arbitrarily. The first parameter can be an array that specifies constraints that are converted into a WHERE clause on the database query. See [[SWAT_Model2::Simple_Entities]] for more on how to specify a constraint array. The second parameter lets you limit the number of results. As a simple number, a 'LIMIT x' is appended to the query. If an array of two numbers is given, then the first number specifies the offset to start the resultset at and the second specifies the number of records after that. The final parameter specifies how to order the results. If the elements in the array are not associative, then they are passed directly to the ORDER BY clause as is. If they are associative, then the key specifies the column and the value specifies either ASC or DESC.

Parameters:
$constraint [array]: trim down results by conditions
$limit [array]: limit number of results by count and offset
$order [array]: sort results
Returns:
[array]: array of SnapVersion objects that belong to this directory and satisfy the given constraints; or null if there was an error or invalid parameter

static SnapResource::lookup ( path  )  [static]

Retrieves a resource by path.

Use this method to retrieve a resource if you know its path. You cannot instantiate a resource and have it populate via a path anyways, but don't try, or badder things will happen.

Parameters:
$path [string]: path to resource
Returns:
[SnapResource]: resource object pointed to by $path, or null on failure or invalid path

Reimplemented from SnapFile.

static SnapResource::retrieve ( id  )  [static]

Retrieves a resource by ID.

Use this method to get a SnapREsource object if you know the ID. Do not instantiate a SnapResource object directly, or bad things will happen.

Parameters:
$id [integer]: ID of resource
Returns:
[SnapResource]: resource indicated by ID, or null if ID is invalid

SnapResource::setValidDate ( validDate  ) 

Changes the valid date field associated with this resource.

The valid date indicates when the resource is considered to be applicable. It's meaning is user-defined.

Parameters:
$validDate [string]: MySQL-acceptable timestamp for new valid date
Returns:
[boolean]: success or failure

SnapResource::toCacheDump (  ) 

INSERT BRIEF DESCRIPTION HERE.

INSERT FULL DESCRIPTION HERE

Returns:
[TYPE]: RETURN DESCRIPTION

Reimplemented from SnapObject.


Member Data Documentation

SnapResource::$ATTRIBUTES [static]

Database attributes for resources


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

Generated on Wed Nov 24 02:03:21 2010 for Common by  doxygen 1.5.6