dmBridge PHP API
DMObject Class Reference

Models a real-world CONTENTdm(R) object (item) - not a PHP object. More...

Inheritance diagram for DMObject:

Public Member Functions

Static Public Member Functions

Protected Member Functions


Detailed Description

Models a real-world CONTENTdm(R) object (item) - not a PHP object.

DMObjects should be instantiated using DMObjectFactory::getObject(). This will ensure that no duplicate objects are instantiated.

Author:
Alex Dolski <alex.dolski@unlv.edu> http://www.opensource.org/licenses/mit-license.php

Definition at line 17 of file DMObject.php.


Constructor & Destructor Documentation

DMObject::__construct ( DMCollection collection,
ptr,
DMDataStore data_store,
DMConfigIni config 
)

Not for public use; to instantiate a DMObject, use DMObjectFactory::getObject() instead.

Parameters:
DMCollectioncollection
intptr
DMDataStoredata_store
DMConfigIniconfig

Definition at line 80 of file DMObject.php.


Member Function Documentation

DMObject::__toString ( )
Returns:
string The DC title of the DMObject (if available), or "alias pointer" if not.
Since:
0.1

Definition at line 93 of file DMObject.php.

DMObject::addComment ( DMComment comment)

Convenience method that appends a new comment to the DMObject.

Parameters:
DMCommentcomment
Returns:
True if the comment was successfully saved; false if not.
Exceptions:
DMDataStoreException
DMPDOException

Definition at line 210 of file DMObject.php.

DMObject::addField ( DMDCElement elem)

Adds a metadata element, or replaces an existing element with the same nick.

This will not be persisted.

Parameters:
DMDCElementelem

Definition at line 342 of file DMObject.php.

DMObject::addRating ( DMRating r)

Appends a new rating to the instance and saves it to the data store.

Parameters:
DMRatingr
Returns:
void
Exceptions:
DMDataStoreException

Definition at line 637 of file DMObject.php.

DMObject::addTag ( DMTag tag)

Convenience method that appends a new tag to the instance and saves it to the data store.

Parameters:
DMTagtag
Returns:
void
Exceptions:
DMDataStoreException

Definition at line 678 of file DMObject.php.

DMObject::equals ( obj)
Parameters:
mixedobj
Returns:
True if the object to be compared has the same collection alias and pointer as the instance; false if not.
Since:
2.0

Definition at line 293 of file DMObject.php.

Referenced by DMSession::addRecentlyViewedObject(), UNLVRandomSQLiteDataStore::isRandomObject(), and UNLVRandomMySQLDataStore::isRandomObject().

static DMObject::exists ( DMCollection col,
ptr 
) [static]
Parameters:
DMCollectioncol
ptr
Returns:
boolean

Definition at line 65 of file DMObject.php.

Referenced by DMObjectFactory::getObject().

DMObject::getCdmURI ( )

Retrieves the URI of the DMObject's item record in CONTENTdm(R).

Use of the object's reference URL (accessible by getReferenceURL()) instead is preferred.

Returns:
string
See also:
getReferenceURL()

Definition at line 112 of file DMObject.php.

DMObject::getChild ( index)

Returns the child object at the given index (equivalent to page minus 1), or null if none exists at that index.

Parameters:
intindex
Returns:
DMObject|null
See also:
getChildren()

Definition at line 139 of file DMObject.php.

Referenced by getFullText(), getMediaType(), and getViewer().

DMObject::getChildren ( )
Returns:
Array of all of the DMObject's child DMObjects in page order, or an empty array if none exist or if the DMObject is not compound.
See also:
getChild()

Definition at line 160 of file DMObject.php.

Referenced by DMSession::addHasCommented(), getChild(), hasChildren(), DMXMLRepresentationTransformerV1::transformObject(), and DMJSONRepresentationTransformerV1::transformObject().

DMObject::getCollection ( )
Returns:
DMCollection The object's parent collection

Definition at line 198 of file DMObject.php.

Referenced by DMObjectView::__construct(), DMObjectResultsView::__construct(), __toString(), DMSession::addFavorite(), DMSession::addHasRated(), UNLVHighlightSQLiteDataStore::addHighlightedObject(), UNLVHighlightMySQLDataStore::addHighlightedObject(), DMPDODataStore::addObjectComment(), DMPDODataStore::addObjectRating(), DMPDODataStore::addObjectTag(), UNLVRandomSQLiteDataStore::addRandomObject(), UNLVRandomMySQLDataStore::addRandomObject(), UNLVSpatialSQLiteDataStore::deleteObject(), UNLVSpatialMySQLDataStore::deleteObject(), equals(), DMPDODataStore::getAllRatingsForObject(), DMPDODataStore::getApprovedCommentsForObject(), getCdmURI(), getChildren(), getCommentsFeedURL(), getFile(), getFileURL(), getImageURL(), DMPDODataStore::getNumRatingsForObject(), getParent(), DMPDODataStore::getRatingForObject(), getReferenceURL(), getThumbnail(), getThumbnailURL(), getURI(), getViewer(), getViewerClassName(), DMSession::hasCommentedOnObject(), DMSession::hasRatedObject(), isCompound(), UNLVSpatialObjectFactory::spatializeObject(), DMXMLRepresentationTransformerV1::transformObject(), DMJSONRepresentationTransformerV1::transformObject(), DMXMLRepresentationTransformerV1::transformObjectComments(), DMJSONRepresentationTransformerV1::transformObjectComments(), DMXMLRepresentationTransformerV1::transformObjectRating(), DMJSONRepresentationTransformerV1::transformObjectRating(), DMXMLRepresentationTransformerV1::transformObjectTags(), DMJSONRepresentationTransformerV1::transformObjectTags(), UNLVSpatialSQLiteDataStore::updateObject(), and UNLVSpatialMySQLDataStore::updateObject().

DMObject::getCommentsFeedURL ( )

Retrieves the URI of the feed for the list of object comments.

Returns:
string
Since:
1.1

Definition at line 229 of file DMObject.php.

DMObject::getDateCreated ( )

Retrieves the DMObject's "dmcreated" value from CONTENTdm(R).

Returns:
DMDateTime

Definition at line 257 of file DMObject.php.

Referenced by DMXMLRepresentationTransformerV1::transformObject(), DMJSONRepresentationTransformerV1::transformObject(), and DMAtomRepresentationTransformer::transformObject().

DMObject::getDateUpdated ( )

Retrieves the DMObject's "dmmodified" value from CONTENTdm(R).

Returns:
DMDateTime

Definition at line 271 of file DMObject.php.

Referenced by DMXMLRepresentationTransformerV1::transformObject(), DMJSONRepresentationTransformerV1::transformObject(), and DMAtomRepresentationTransformer::transformObject().

DMObject::getFeedURI ( )

Convenience method equivalent to calling getURI(DMBridgeComponent::TemplateEngine, "atom").

Returns:
DMInternalURI

Definition at line 322 of file DMObject.php.

DMObject::getField ( nick)
Parameters:
stringnick
Returns:
DMDCElement If $nick is a valid field nickname, returns a DMDCElement object corresponding to the field. If it is not, returns null.

Definition at line 332 of file DMObject.php.

DMObject::getFields ( )

Alias of getMetadata().

Returns:
array An array of all of the DMObject's fields as DMDCElement objects.
See also:
getMetadata()

Definition at line 360 of file DMObject.php.

DMObject::getFile ( )

Returns a DMFile pointing to the object's file on disk.

Does not check whether the file actually exists. Note that direct filesystem access to CONTENTdm(R) files is not supported by OCLC, so use at your own risk. For certain media types, a subclass of DMFile may be returned, such as DMPDFFile.

Returns:
DMFile
See also:
getFilename()

Definition at line 374 of file DMObject.php.

Referenced by getThumbnail(), and getViewer().

DMObject::getFilename ( )
Returns:
string The filename of the DMObject, without any path information.
See also:
getFile()
Deprecated:
Deprecated as of version 2.1. Use getFile() instead.

Definition at line 397 of file DMObject.php.

Referenced by getFile(), getMediaType(), isURLType(), DMXMLRepresentationTransformerV1::transformObject(), and DMJSONRepresentationTransformerV1::transformObject().

DMObject::getFileURL ( )

Returns the public URL of the object's file.

Returns:
DMURI

Definition at line 417 of file DMObject.php.

Referenced by getURI(), DMXMLRepresentationTransformerV1::transformObject(), and DMJSONRepresentationTransformerV1::transformObject().

DMObject::getFullText ( )

Returns the DMDCElement object corresponding to the object's fulltext field (with nick "full").

If the DMObject is a compound object, returns the fulltext field corresponding to the first page. To avoid this behavior, use getMetadata("full").

Returns:
DMDCElement object, or false if not available
See also:
getMetadata()
Since:
0.1

Definition at line 433 of file DMObject.php.

DMObject::getHeight ( )
Returns:
The full height of the DMObject's image, if applicable.
Deprecated:
Deprecated in version 2.1. Use getImageHeight() instead.

Definition at line 452 of file DMObject.php.

Referenced by DMXMLRepresentationTransformerV1::transformObject(), and DMJSONRepresentationTransformerV1::transformObject().

DMObject::getImageHeight ( )
Returns:
int The full height of the DMObject's image, if applicable.
Since:
2.1

Definition at line 512 of file DMObject.php.

Referenced by getHeight(), and getImageURL().

DMObject::getImageURL ( maxwidth,
maxheight,
x = 0,
y = 0,
rotate = 0 
)
Parameters:
intmaxwidth
intmaxheight
intx X offset
inty Y offset
introtate
Returns:
string Absolute URL of the DMObject's image with dimensions and orientation corresponding to the supplied parameters, or false if the height/width of the image are 0 (such as would be the case if it did not have one).

Definition at line 467 of file DMObject.php.

Referenced by DMXMLRepresentationTransformerV1::transformObject(), and DMJSONRepresentationTransformerV1::transformObject().

DMObject::getImageWidth ( )
Returns:
int The full width of the DMObject's image, if applicable.
Since:
2.1

Definition at line 523 of file DMObject.php.

Referenced by getImageURL(), and getWidth().

DMObject::getMediaType ( )

Returns a best guess at the file's media (MIME) type.

The guess is based exclusively on the file's filename extension, as the CONTENTdm(R) PHP API does not supply media type information. If the media type cannot be guessed, returns a media type of "unknown/unknown".

Returns:
DMMediaType
Since:
2.0

Definition at line 562 of file DMObject.php.

Referenced by getFile(), getViewer(), getViewerClassName(), DMXMLRepresentationTransformerV1::transformObject(), and DMJSONRepresentationTransformerV1::transformObject().

DMObject::getMetadata ( nick = null)
Parameters:
stringnick
Returns:
If $nick is supplied and a valid field nickname, returns a DMDCElement object corresponding to the field. If it is supplied but not valid, returns null. If it is not supplied, returns an array of all of the DMObject's fields, as DMDCElement objects.
See also:
getField()

Definition at line 538 of file DMObject.php.

Referenced by __toString(), getField(), getFields(), getFullText(), UNLVSpatialObjectFactory::spatializeObject(), DMXMLRepresentationTransformerV1::transformObject(), DMJSONRepresentationTransformerV1::transformObject(), DMAtomRepresentationTransformer::transformObject(), and DMAtomRepresentationTransformer::transformObjectComments().

DMObject::getPage ( )
Returns:
int

Definition at line 596 of file DMObject.php.

Referenced by DMXMLRepresentationTransformerV1::transformObject().

DMObject::getParent ( )
DMObject::getPtr ( )
Returns:
int

Definition at line 626 of file DMObject.php.

Referenced by __toString(), DMSession::addFavorite(), DMSession::addHasRated(), UNLVHighlightSQLiteDataStore::addHighlightedObject(), UNLVHighlightMySQLDataStore::addHighlightedObject(), DMPDODataStore::addObjectComment(), DMPDODataStore::addObjectRating(), DMPDODataStore::addObjectTag(), UNLVRandomSQLiteDataStore::addRandomObject(), UNLVRandomMySQLDataStore::addRandomObject(), UNLVSpatialSQLiteDataStore::deleteObject(), UNLVSpatialMySQLDataStore::deleteObject(), equals(), DMPDODataStore::getAllRatingsForObject(), DMPDODataStore::getApprovedCommentsForObject(), getCdmURI(), getChildren(), getCommentsFeedURL(), getFileURL(), getImageURL(), DMPDODataStore::getNumRatingsForObject(), getParent(), DMPDODataStore::getRatingForObject(), getReferenceURL(), getThumbnailURL(), getURI(), DMSession::hasCommentedOnObject(), DMSession::hasRatedObject(), isCompound(), UNLVSpatialObjectFactory::spatializeObject(), DMXMLRepresentationTransformerV1::transformObject(), DMJSONRepresentationTransformerV1::transformObject(), DMXMLRepresentationTransformerV1::transformObjectComments(), DMJSONRepresentationTransformerV1::transformObjectComments(), DMXMLRepresentationTransformerV1::transformObjectRating(), DMJSONRepresentationTransformerV1::transformObjectRating(), DMXMLRepresentationTransformerV1::transformObjectTags(), DMJSONRepresentationTransformerV1::transformObjectTags(), UNLVSpatialSQLiteDataStore::updateObject(), and UNLVSpatialMySQLDataStore::updateObject().

DMObject::getRating ( out_of = 100,
decimal_places = 10 
)

Retrieves the DMObject's rating from the data store, as a float.

Parameters:
intout_of
intdecimal_places
Returns:
float
Exceptions:
DMDataStoreException

Definition at line 649 of file DMObject.php.

Referenced by DMXMLRepresentationTransformerV1::transformObject(), DMJSONRepresentationTransformerV1::transformObject(), DMXMLRepresentationTransformerV1::transformObjectRating(), and DMJSONRepresentationTransformerV1::transformObjectRating().

DMObject::getThumbnail ( )

Returns a DMFile pointing to the object's thumbnail image on disk.

Does not check whether the file actually exists. Note that direct filesystem access to CONTENTdm(R) files is not supported by OCLC, so use at your own risk.

Returns:
DMFile

Definition at line 690 of file DMObject.php.

DMObject::getThumbnailURL ( )

Returns the URI of the DMObject's thumbnail image.

Returns:
DMURI

Definition at line 723 of file DMObject.php.

Referenced by getThumbURL(), DMXMLRepresentationTransformerV1::transformObject(), and DMJSONRepresentationTransformerV1::transformObject().

DMObject::getThumbURL ( )

Wraps getThumbnailURL().

Returns:
string
Deprecated:
Deprecated as of version 2.1. Use getThumbnailURL() instead.

Definition at line 714 of file DMObject.php.

Referenced by DMAtomRepresentationTransformer::transformObject().

DMObject::getTitle ( )

Returns the DMObject's page title, which may be different from the metadata title returned by DMObject::getField() or getMetadata().

See also:
getField()
getMetadata()

Definition at line 736 of file DMObject.php.

Referenced by DMXMLRepresentationTransformerV1::transformObject().

DMObject::getURI ( component = DMBridgeComponent::TemplateEngine,
representation = null,
resolve_links = true 
)
Parameters:
intcomponent One of the constants in DMBridgeComponent.
stringrepresentation An optional alternate representation such as "atom". The default is HTML.
booleanresolve_links If true, returns the URL of a "URL object." If false, returns its physical URI in dmBridge. Affects only objects that were created as "URL"-type objects in CONTENTdm(R). Supplying false for this parameter is not recommended in the template engine because it will link to an object view page that might have otherwise never been seen.
Returns:
DMURI The absolute URI of the instance within the given component and with the given representation.
Since:
2.0

Definition at line 759 of file DMObject.php.

Referenced by DMAtomRepresentationTransformer::transformObject(), DMXMLRepresentationTransformerV1::transformObjectComments(), DMJSONRepresentationTransformerV1::transformObjectComments(), DMAtomRepresentationTransformer::transformObjectComments(), DMXMLRepresentationTransformerV1::transformObjectRating(), DMJSONRepresentationTransformerV1::transformObjectRating(), DMXMLRepresentationTransformerV1::transformObjectTags(), and DMJSONRepresentationTransformerV1::transformObjectTags().

DMObject::getViewer ( width_override = null,
height_override = null 
)
Parameters:
intwidth_override
intheight_override
Returns:
DMObjectViewerDelegate Will return null if there is no viewer definition for the object's media type.
Exceptions:
DMClassNotFoundExceptionIf a viewer definition is set but the viewer class cannot be found.

Definition at line 798 of file DMObject.php.

Referenced by DMObjectView::__construct().

DMObject::getViewerClassName ( )
Returns:
string

Definition at line 837 of file DMObject.php.

DMObject::getWidth ( )
Returns:
int The full width of the DMObject's image, if applicable.
Deprecated:
Deprecated in version 2.1. Use getImageWidth() instead.

Definition at line 854 of file DMObject.php.

Referenced by DMXMLRepresentationTransformerV1::transformObject(), and DMJSONRepresentationTransformerV1::transformObject().

DMObject::hasChildren ( )

Returns true if the object is compound and has children, or false if it is either not compound, or has no children.

Returns:
Boolean
See also:
isCompound()

Definition at line 191 of file DMObject.php.

Referenced by getFullText(), and getViewer().

DMObject::hasComments ( )
Returns:
Boolean True if the object has at least one approved comment, or false if not

Definition at line 218 of file DMObject.php.

DMObject::isChild ( )
Returns:
Boolean

Definition at line 150 of file DMObject.php.

Referenced by DMSession::addHasCommented(), and getCdmURI().

DMObject::isCompound ( )

Whether the object is compound, even if it has no pages.

Returns:
Boolean

Definition at line 240 of file DMObject.php.

Referenced by DMSession::addHasCommented(), getCdmURI(), getMediaType(), DMXMLRepresentationTransformerV1::transformObject(), and DMJSONRepresentationTransformerV1::transformObject().

DMObject::isFavorite ( )

Checks whether the DMObject is in the user's favorites.

Returns:
Boolean
Since:
0.1

Definition at line 306 of file DMObject.php.

DMObject::isURLType ( )
Returns:
boolean Whether the instance is a "URL-type" object.

Definition at line 785 of file DMObject.php.

Referenced by getURI().

DMObject::setDateUpdated ( DMDateTime date) [protected]
Parameters:
DMDateTimedate

Definition at line 283 of file DMObject.php.

Referenced by getDateUpdated().

DMObject::setFilename ( filename) [protected]
Parameters:
stringfilename
Since:
0.1

Definition at line 408 of file DMObject.php.


The documentation for this class was generated from the following file:
 All Data Structures Functions Variables