Welcompose
[ class tree: Welcompose ] [ index: Welcompose ] [ all elements ]

Class: Media_Object

Source Location: /media_classes/object.class.php

Class Overview




Variables

Methods



Class Details

[line 38]


[ Top ]


Class Variables

static $instance =  null

[line 45]

Singleton



Tags:

access:  public

Type:   object


[ Top ]

$base =  null

[line 52]

Reference to base class



Tags:

access:  public

Type:   object


[ Top ]



Class Methods


constructor __construct [line 59]

Media_Object __construct( )

Start instance of base class, load configuration and establish database connection. Please don't call the constructor direcly, use the singleton pattern instead.



Tags:

access:  public


[ Top ]

method addObject [line 85]

int addObject( array $sqlData)

Adds object to the object table. Takes a field=>value array with object data as first argument. Returns insert id.



Tags:

return:  Object id
throws:  Media_ObjectException
access:  public


Parameters:

array   $sqlData   Row data

[ Top ]

method countObjects [line 417]

array countObjects( [array $params = array()])

Counts objects saved in the media object table.

List of supported params:

  • types, array, optional: Return only objects that belong to the given generic types
  • tags, array, optional: Returns objects with given tags
  • timeframe, string, optional: Returns objects from given timeframe




Tags:

throws:  Media_ObjectException
access:  public


Parameters:

array   $params   Count params

[ Top ]

method createImageThumbnail [line 631]

array createImageThumbnail( string $orig_name, string $object_name, int $width, int $height, [bool $fill_up = false], [bool $hex = null])

Creates thumbnail of given image. Takes the original name (as saved on

user's disk) of the object as first argument and the filename of the object on the server as second argument. The arguments three and four define the maximum width and height of the thumbnail. The image will be scaled keeping the aspect ratio of the original image.

If the image is smaller than $width or $height and you don't like that, the image will be placed on the middle of an empty canvas with the size of $width x $height if you pass boolean true as fifth argument. The color of the canvas can be defined using a hexadecimal color code as sixth argument (e.g. ffffff for white or ff0000 for red).

Returns array with complete array information:

  • name: Name of the thumbnail on the server's disk
  • width: Width of the thumbnail
  • height: Height of the thumbnail
  • type: MIME type the thumbnail
  • size: Filesize of the thumbnail in bytes




Tags:

throws:  Media_ObjectException
access:  public


Parameters:

string   $orig_name   Original image name
string   $object_name   Image name on server
int   $width   Maximal thumbnail width
int   $height   Maximal thumbnail height
bool   $fill_up   Fill the image up
bool   $hex   Canvas color

[ Top ]

method deleteObject [line 151]

int deleteObject( int $id)

Removes object from the object table. Takes the object id as first argument. Returns amount of affected rows.



Tags:

return:  Amount of affected rows
throws:  Media_ObjectException
access:  public


Parameters:

int   $id   Object id

[ Top ]

method genericTypesToMimeTypes [line 1093]

array genericTypesToMimeTypes( string $generic_type)

Returns list of mime types that belong to the given generic type. Valid generic types:

  • image
  • document
  • audio
  • video
  • other




Tags:

throws:  Media_ObjectException
access:  public


Parameters:

string   $generic_type  

[ Top ]

method getGenericTypes [line 1061]

array getGenericTypes( )

Returns list of generic image types.



Tags:

throws:  Media_ObjectException
access:  public


[ Top ]

method getMimeTypeConfigurations [line 1286]

array getMimeTypeConfigurations( )

Returns list with mime type configurations.



Tags:

access:  public


[ Top ]

method getPathToObject [line 824]

mixed getPathToObject( string $object_name)

Returns full path to media object. Takes media object name on disk as first argument. Please note that the object doesn't have to exist to get the path to a object.



Tags:

access:  public


Parameters:

string   $object_name   Object name

[ Top ]

method getPathToObjectUsingId [line 846]

mixed getPathToObjectUsingId( string $object_id)

Takes media object id as first argument. Returns full disk path to media object.



Tags:

access:  public


Parameters:

string   $object_id   Object id

[ Top ]

method getPathToThumbnail [line 925]

mixed getPathToThumbnail( string $object_name)

Returns full path to media thumbnail. Takes the media object name on disk as first argument. Please note that the thumbnail doesn't have to exist to get the path to the thumbnail.



Tags:

access:  public


Parameters:

string   $object_name   Thumbnail name

[ Top ]

method getWwwPathToObject [line 872]

mixed getWwwPathToObject( string $object_name)

Returns full www path to media object. Takes media object name on disk as first argument. Please note that the object doesn't have to exist to get the path to a object.



Tags:

access:  public


Parameters:

string   $object_name   Object name

[ Top ]

method getWwwPathToObjectUsingId [line 894]

mixed getWwwPathToObjectUsingId( string $object_id)

Takes media object id as first argument. Returns full www path to media object.



Tags:

access:  public


Parameters:

string   $object_id   Object id

[ Top ]

method imageStoreIsReady [line 945]

bool imageStoreIsReady( )

Tests if the image store is ready to save some files there.



Tags:

access:  public


[ Top ]

method isPodcastFormat [line 1127]

bool isPodcastFormat( string $mime_type)

Tests if object with given mime type can be used for a podcast.

Returns bool.




Tags:

throws:  Media_ObjectException
access:  public


Parameters:

string   $mime_type   Object's mime type

[ Top ]

method mimeTypeToIcon [line 1223]

string mimeTypeToIcon( string $mime_type)

Returns name of a fancy icon for the given mime type. Takes the mime type name as first argument. If the given mime type could not be found, the name of a generic icon will be returned.



Tags:

throws:  Media_ObjectExpception
access:  public


Parameters:

string   $mime_type  

[ Top ]

method mimeTypeToInsertCallBack [line 1255]

string mimeTypeToInsertCallBack( string $mime_type)

Returns name of text converter callback for given mime type.



Tags:

access:  public


Parameters:

string   $mime_type   Mime type name

[ Top ]

method moveObjectToStore [line 508]

string moveObjectToStore( string $name, string $path, string 2)

Moves object to store. Takes the real name (~ file name on user's disk) as first argument, the path to the uploaded file as second argument. Returns the new name on disk which could be former name on edit action or newly build (uniqid + real name) on initial upload.



Tags:

return:  File name on disk
throws:  Media_ObjectException
access:  public


Parameters:

string   2   Current file name on disk
string   $name   File name
string   $path   Path to uploaded file

[ Top ]

method removeImageThumbnail [line 765]

bool removeImageThumbnail( int $object)

Remove thumbnail. Takes the object id as first argument.

Returns bool.




Tags:

throws:  Media_ObjectException
access:  public


Parameters:

int   $object   Object id

[ Top ]

method removeObjectFromStore [line 552]

bool removeObjectFromStore( int $object)

Removes object form store. Takes the id of the object as first argument. Returns bool.



Tags:

throws:  Media_ObjectException
access:  public


Parameters:

int   $object   Global file id

[ Top ]

method selectObject [line 184]

array selectObject( int $id)

Selects one object. Takes the object id as first argument.

Returns array with object information.




Tags:

throws:  Media_ObjectException
access:  public


Parameters:

int   $id   Object id

[ Top ]

method selectObjects [line 266]

array selectObjects( [array $params = array()])

Method to select one or more objects. Takes key=>value array with select params as first argument. Returns array.

List of supported params:

  • types, array, optional: Return only objects that belong to the given generic types
  • tags, array, optional: Returns objects with given tags
  • timeframe, string, optional: Returns objects from given timeframe
  • start, int, optional: row offset
  • limit, int, optional: amount of rows to return
  • order_marco, string, otpional: How to sort the result set. Supported macros:
    • DATE_MODIFIED: sorty by date modified
    • DATE_ADDED: sort by date added
</ul>




Tags:

throws:  Media_ObjectException
access:  public


Parameters:

array   $params   Select params

[ Top ]

method sqlForGenericTypes [line 1163]

string sqlForGenericTypes( string $field, array $types)

Generates sql fragment to select objects that belong to the different generic types. Takes the name of the mime type as first argument, the list of generic types that should be queried as second argument. Returns string.



Tags:

throws:  Media_ObjectException
access:  protected


Parameters:

string   $field  
array   $types  

[ Top ]

method testForUniqueFilename [line 993]

bool testForUniqueFilename( string $file_name, [integer $id = null])

Tests given file for uniqueness. Takes the file name as first argument and the id as second argument as an option.

The second argument is used to compare if the uploaded file name equals the former file name that is already on disk. When the file name is identical, we allow to replace this file.

Returns boolean true if file name is unique.




Tags:

throws:  Media_ObjectException
access:  public


Parameters:

string   $file_name   file name
integer   $id   Id of current file

[ Top ]

method updateObject [line 114]

int updateObject( int $id, array $sqlData)

Updates object. Takes the object id as first argument, a field=>value array with the new object data as second argument.

Returns amount of affected rows.




Tags:

return:  Affected rows
throws:  Media_ObjectException
access:  public


Parameters:

int   $id   Object id
array   $sqlData   Row data

[ Top ]

method _flipTypes [line 1034]

array _flipTypes( array $types)

Flips keys and values in type array.



Tags:

throws:  Media_ObjectException
access:  protected


Parameters:

array   $types  

[ Top ]


Documentation generated on Sun, 08 Jan 2012 17:51:55 +0100 by phpDocumentor 1.4.3