📄 galleryresource.class.php
字号:
<?php lt_include( PLOG_CLASS_PATH."class/database/dbobject.class.php" ); lt_include( PLOG_CLASS_PATH."class/gallery/galleryconstants.php" ); // Add this to avoid long file name error in windows server define('GETID3_HELPERAPPSDIR', 'no_helper_apps_needed'); /** * \ingroup Gallery * * Encapsulates a resource from our database. * * Each GalleryResource object can belong to only one GalleryAlbum object, and therefore every object * has a reference to its album. * * This class also provides methods for getting the correct metadata reader, for checking the type of the * resource, for getting access to the thumbnail of the object, etc. */ class GalleryResource extends DbObject { var $_id; var $_ownerId; var $_albumId; var $_date; var $_description; var $_flags; var $_resourceType; var $_filePath; var $_fileName; var $_metadata; var $_album; var $_thumbnailFormat; var $_fileDescriptor; var $_fileSize; /** * Constructor. * * @param ownerId Id of the user to whom this resource belongs * @param albumId The id of the GalleryAlbum object to which this resource belongs * @param description Description of this file * @param flags As of pLog 1.0, there is only one flag available: GALLERY_RESOURCE_PREVIEW_AVAILABLE. * @param resourceType The type of the resource. One of the following constants: * - GALLERY_RESOURCE_IMAGE * - GALLERY_RESOURCE_VIDEO * - GALLERY_RESOURCE_SOUND * - GALLERY_RESOURCE_UNKNOWN * - GALLERY_RESOURCE_DOCUMENT * - GALLERY_RESOURCE_ZIP * @param filePath path in disk to the real file. Not used. * @param fileName name of the file, which is not exactly the same name that the file has in disk, since the * GalleryResourceStorage class is taking care of managing things in disk. Nevertheless, this is the file that will * be shown to users in the user interface * @param metadata An array, as generated by the getID3 class. * @param date A SQL date * @param thumbnailFormat The format of the thumbnail * @param id Optinally, the id. When creating new resources, the GalleryResources::addResource() method will * update the id so it does not matter what we provide here. * @see getID3 */ function GalleryResource( $ownerId, $albumId, $description, $flags, $resourceType, $filePath, $fileName, $metadata, $date, $thumbnailFormat, $properties = Array(), $id = -1 ) { $this->DbObject(); $this->_ownerId = $ownerId; $this->_albumId = $albumId; $this->_description = $description; $this->_flags = $flags; $this->_resourceType = $resourceType; $this->_filePath = $filePath; $this->_fileName = $fileName; $this->_fileSize = 0; $this->_metadata = $metadata; $this->_date = $date; $this->_thumbnailFormat = $thumbnailFormat; $this->_id = $id; $this->_album = null; $this->setProperties( $properties ); $this->_fields = Array( "owner_id" => "getOwnerId", "album_id" => "getAlbumId", "description" => "getDescription", "date" => "getDate", "flags" => "getFlags", "resource_type" => "getResourceType", "file_path" => "getFilePath", "file_name" => "getFileName", "file_size" => "getFileSize", "thumbnail_format" => "getThumbnailFormat", "normalized_description" => "getNormalizedDescription", "properties" => "getProperties", "metadata" => "getMetadata" ); $this->_fileDescriptor = false; } /** * @return the identifier of the resource, or -1 if none has been set yet. */ function getId() { return $this->_id; } /** * @return the identifier of the owner of this resource */ function getOwnerId() { return $this->_ownerId; } /** * @return the bloginfo of the owner of this resource */ function getBlogInfo() { lt_include( PLOG_CLASS_PATH."class/dao/blogs.class.php" ); $blogs = new Blogs(); $blogInfo = $blogs->getBlogInfo( $this->_ownerId ); return $blogInfo; } /** * @return returns the identifier of the GalleryAlbum object to which this resource belongs */ function getAlbumId() { return $this->_albumId; } /** * @return Returns a 14-digit SQL date */ function getDate() { return $this->_date; } /** * @return Returns a Timestamp object * @see Timestamp */ function getTimestamp() { // source necessary source lt_include( PLOG_CLASS_PATH."class/data/timestamp.class.php" ); return new Timestamp($this->_date); } /** * @return returns the "raw" metadata information, as generated by the getID3 class. It is * advisable to use the GalleryResource::getResourceMetadataReader to get the right * metadata reader class, since these classes provide convenience methods for accessing * the most common attributes of sound files, videos, etc. */ function getMetadata() { return $this->_metadata; } /** * Set the resource metadata to the given array * * @param metadata * @return Nothing */ function setMetadata( $metadata ) { $this->_metadata = $metadata; } /** * @return the flags of the resource object */ function getFlags() { return $this->_flags; } /** * @return The path of the file in disk */ function getFilePath() { return $this->_filePath; } /** * @return the name of the file in disk */ function getFileName() { return $this->_fileName; } /** * @return the encoded name of the file in disk */ function getEncodedFileName() { $fileParts = explode( ".", $this->_fileName ); $fileExt = strtolower($fileParts[count($fileParts)-1]); $encodedFileName = $this->getOwnerId()."-".$this->getId().".".$fileExt; return $encodedFileName; } /** * @return the description of the resource */ function getDescription() { return $this->_description; } /** * returns the mime type of the resource * * @return a valid mime type */ function getMimeType() { lt_include( PLOG_CLASS_PATH."class/data/mimetype.class.php" ); $mimeType = new MimeType(); return $mimeType->getType( $this->_fileName ); } /** * returns the mime type of the thumbnails * * @return a valid mime type */ function getThumbnailMimeType() { lt_include( PLOG_CLASS_PATH."class/data/mimetype.class.php" ); if( $this->getThumbnailFormat() == "same" ) return $this->getMimeType(); else { $mimeType = new MimeType(); return $mimeType->getType( $this->getThumbnailFormat()); } } function getResourceType() { return $this->_resourceType; } /** * Sets the album id. You should normally not need to use this method * * @param albumId The id of the album */ function setAlbumId( $albumId ) { $this->_albumId = $albumId; } /** * Sets the GalleryAlbum object to which this file belongs */ function setAlbum( $album ) { $this->_album = $album; } /** * @return The GalleryAlbum object to which this resource belongs */ function getAlbum() { if( $this->_album == null ) { lt_include( PLOG_CLASS_PATH."class/gallery/dao/galleryalbums.class.php" );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -