Public Member Functions | |
copy () | |
Performs deep copy of this content module. | |
delete () | |
Deletes any external resources associated with the content. | |
getContentSuffix () | |
INSERT BRIEF DESCRIPTION HERE. | |
getEditor ($redirectTo="", $showPreview=true) | |
Retrieves editor instance for this content. | |
getEditorClass () | |
INSERT BRIEF DESCRIPTION HERE. | |
getHTML ($params=array()) | |
Retrieves HTML to embed content in a page. | |
getLinkURL ($download=false) | |
Retrieves URL for downloading resource. | |
getName () | |
Retrieves descriptive name for this type of content. | |
getPreview ($mode=TKSnapPreview::MODE_DEFAULT) | |
Retrieves preview instance for this content. | |
getPreviewClass () | |
INSERT BRIEF DESCRIPTION HERE. | |
getRaw () | |
Retrieves raw content to be put into database. | |
getTranslator () | |
Retrieves the name of the translator class to be used for this type of object. | |
isValid () | |
Returns whether content module is in a valid, consisten state. | |
Static Public Member Functions | |
static | create ($version) |
Create a new blank content module of the appropriate type. | |
static | getContentModule ($version, $new=false) |
Returns an instance of a content module of the correct type for the given version. | |
static | getContentModuleClass ($version) |
Returns name of content module class. | |
static | getContentName ($type) |
Same as getName(), but static. | |
static | getInitialValue ($type) |
Retrieves the initial value to be stored in the database for a new version. | |
static | getTypeFromSuffix ($suffix) |
Retrieves content type from file suffix. | |
static | isValidType ($type) |
Returns whether given content type is valid. |
A content module represents a chunk of Snap2 content. All operations on content in Snap2 are to be done via a content module, and not by directly manipulating the value of the 'content' field in a SnapVersion.
A content module exists in one of two modes: read-only and new. In read-only mode, the content module represents existing content and that should not be manipulated. In new mode, the content module can be modified and ultimately saved to the database. Both modes allow for the deletion of the content. To modify content, one should create a new content module, uninitialized with existing content (thus putting it in new mode), and then calling content-type specific methods to fill in the content. To get at existing content, simply call SnapVersion::getContentModule. Do not create read-only content modules yourself.
SnapContent::copy | ( | ) |
Performs deep copy of this content module.
The new content module returned from this method is read-only and is intended to be used when a version is being created as a copy of an existing version.
static SnapContent::create | ( | $ | version | ) | [static] |
Create a new blank content module of the appropriate type.
This content module is meant to be modified and ultimately serialized into the database
$version | [SnapVersion]: version to create content module for (really only for type information) |
SnapContent::delete | ( | ) |
Deletes any external resources associated with the content.
For content types that have external resources, those must be deleted when a revision of a version is destroyed, or when the version itself is destroyed. When a version is updated the old content is delete()'ed and a new content module is created. When a version is destroyed the content is also delete()'ed. Finally, if a blank content module is created for an update and it is initialized with new data, but the update fails, then the module should be deleted to clean up any external files. These are the only three cases in which delete() needs to be called.
static SnapContent::getContentModule | ( | $ | version, | |
$ | new = false | |||
) | [static] |
Returns an instance of a content module of the correct type for the given version.
The content module returned is prefilled with data from the version and cannot be modified. It is meant for queries only.
$version | [SnapVersion]: version to retrieve content module for | |
$new | [boolean]: if true, create an empty content module, otherwise, fill it with the content from the version |
static SnapContent::getContentModuleClass | ( | $ | version | ) | [static] |
Returns name of content module class.
$version | [SnapVersion]: version to get content module class name for |
static SnapContent::getContentName | ( | $ | type | ) | [static] |
Same as getName(), but static.
$type | [int]: content type |
SnapContent::getContentSuffix | ( | ) |
INSERT BRIEF DESCRIPTION HERE.
INSERT FULL DESCRIPTION HERE
SnapContent::getEditor | ( | $ | redirectTo = "" , |
|
$ | showPreview = true | |||
) |
Retrieves editor instance for this content.
$redirectTo | [string]: provide an alternate address to redirect to when exiting the editor | |
$showPreview | [boolean]: whether the editor should include a preview frame |
SnapContent::getEditorClass | ( | ) |
INSERT BRIEF DESCRIPTION HERE.
INSERT FULL DESCRIPTION HERE
SnapContent::getHTML | ( | $ | params = array() |
) |
Retrieves HTML to embed content in a page.
The HTML should either embed the content directly, or, at the very least, provide a link for it to be downloaded or some other indication that the content is there.
$params | [array]: array of parameters that control the nature of the embed HTML (only relevant for some content types) |
static SnapContent::getInitialValue | ( | $ | type | ) | [static] |
Retrieves the initial value to be stored in the database for a new version.
When a new version is created, the database must be filled with some initial value before the user has entered anything. So, this function delegates to the appropriate content module to get an appropriate initial value.
$type | [int]: content type; should be one of the SnapResource::TYPE_XXX constants |
SnapContent::getLinkURL | ( | $ | download = false |
) |
Retrieves URL for downloading resource.
Links are of the form '/media/content//path/to/resource.suffix'. Note that there is not and never will be a way to download a particular version. The correct active version will be used.
SnapContent::getName | ( | ) |
Retrieves descriptive name for this type of content.
SnapContent::getPreview | ( | $ | mode = TKSnapPreview::MODE_DEFAULT |
) |
Retrieves preview instance for this content.
SnapContent::getPreviewClass | ( | ) |
INSERT BRIEF DESCRIPTION HERE.
INSERT FULL DESCRIPTION HERE
SnapContent::getRaw | ( | ) |
Retrieves raw content to be put into database.
This function automatically serializes internal data structures and thus no further processing need be done on the return value
SnapContent::getTranslator | ( | ) |
Retrieves the name of the translator class to be used for this type of object.
static SnapContent::getTypeFromSuffix | ( | $ | suffix | ) | [static] |
Retrieves content type from file suffix.
Given a file suffix, this function will determine which content type would be used for that suffix. For example, the "xml" suffix will return SnapResource::TYPE_STDXML.
$suffix | [string]: file suffix without leading dot |
SnapContent::isValid | ( | ) |
Returns whether content module is in a valid, consisten state.
Each content module class decides what counts as valid, but in general, a valid content module has all of its internal data structures in a state that they can be serialized and put in the database and later be retrieved and correctly used for displaying and modifying content.
static SnapContent::isValidType | ( | $ | type | ) | [static] |
Returns whether given content type is valid.
$type | [int]: content type |