This is the API docs for LemonStand V1, which has been discontinued. LemonStand is now a cloud based platform, available at lemonstand.com.

LemonStand API

Shop_ProductFile class

Defined in /modules/shop/models/shop_productfile.php, lines 13-56
Inheritance Phpr_Extension » Phpr_Extensible » Phpr_Validatable » Db_Base » Db_WhereBase » Db_SqlBase » Db_ActiveRecord » Db_File » Shop_ProductFile
Author LemonStand eCommerce Inc.
Represents a file in a downloadable product. Objects of this class are available through the Shop_Product::$files property. See the Creating the Order Details page article for examples of the class usage.

Public properties

Show inherited properties.

Property Type Description Defined By
auto_create_timestamps array a list of create timestamp columns. Db_ActiveRecord
auto_timestamps boolean determines whether create and update timestamp field should be set automatically. Db_ActiveRecord
auto_update_timestamps array a list of update timestamp columns. Db_ActiveRecord
belongs_to array contains a list of Belongs To Many relations. Db_ActiveRecord
custom_columns array contains a list of custom fields definition. Db_ActiveRecord
description string specifies the file description. Db_File
fetched array contains an associative array of table column values fetched from the database. Db_ActiveRecord
has_and_belongs_to_many array contains a list of Has and Belongs To Many relations. Db_ActiveRecord
has_many array contains a list of Has Many relations. Db_ActiveRecord
has_one array contains a list of Has One relations. Db_ActiveRecord
id integer specifies the file record identifier. Db_File
is_public boolean determines whether the file on the server can be accessed from the Web. Db_File
name string specifies the file name. Db_File
primary_key string specifies a name of the table primary key. Db_ActiveRecord
size integer specifies the file size, in bytes. Db_File
size_str string specifies the file size as string. Shop_ProductFile
title string specifies the file tittle. Db_File
validation Phpr_Validation contains the model's validation object. Db_ActiveRecord

Public methods

Show inherited methods.

Method Description Defined By
add_form_custom_area() adds a form custom area. Db_ActiveRecord
add_form_field() makes a column visible in forms. Db_ActiveRecord
add_form_partial() adds a custom form partial. Db_ActiveRecord
add_form_section() adds a form section. Db_ActiveRecord
after_create_saved() called after a new object is saved to the database. Db_ActiveRecord
after_modify() called after an existing or new record was modified. Db_ActiveRecord
after_save() called after an existing or new record is created or updated in the database. Db_ActiveRecord
after_update() called after an existing record is updated in the database. Db_ActiveRecord
after_validation() triggered after the model column values are validated. Db_ActiveRecord
after_validation_on_create() triggered after a new model column values are validated. Db_ActiveRecord
after_validation_on_update() triggered after an existing model column values are validated. Db_ActiveRecord
before_delete() called before a record is deleted from the database. Db_ActiveRecord
before_save() called before an existing or new record is created or updated in the database. Db_ActiveRecord
before_update() called before an existing record is updated in the database. Db_ActiveRecord
before_validation() triggered before the model column values are validated. Db_ActiveRecord
before_validation_on_create() triggered before a new model column values are validated. Db_ActiveRecord
before_validation_on_update() triggered before an existing model column values are validated. Db_ActiveRecord
collection() executes the find_all() method and returns a collection. Db_ActiveRecord
columnValue() alias for the displayField() method. Db_ActiveRecord
copy() copies the file and returns the new file object. Db_File
define_column() adds a column definition to the model. Db_ActiveRecord
define_form_fields() defines form fields. Db_ActiveRecord
define_multi_relation_column() adds column definition for has_and_belongs_to_many or has_many relation field. Db_ActiveRecord
define_relation_column() adds column definition for has_on or belongs_to relation field. Db_ActiveRecord
delete() deletes the record from the database. Db_ActiveRecord
delete_form_field() deletes a form field by its corresponding column name. Db_ActiveRecord
displayField() returns a formatted column value. The field should be defined with define_column(), Db_ActiveRecord
download_url() returns an URL for downloading the file. Shop_ProductFile
find() finds a record by its primary key value. Db_ActiveRecord
find_all() finds all records and returns the Db_DataCollection object, containing a list of models. Db_ActiveRecord
find_by() finds a record by a field value. Db_ActiveRecord
find_column_definition() finds a column definition by the column name. Db_ActiveRecord
find_form_field() finds a form field definition by its corresponding column name. Db_ActiveRecord
fromFile() creates a file object from a disk file. Db_File
getPath() returns the file path relative to LemonStand root directory. Db_File
getThumbnailPath() creates an image thumbnail. Db_File
is_image() returns TRUE if the file is an image. Db_File
join() adds a table to the query with JOIN statement. Db_SqlBase
limit() allows to limit the result of the find_all() method with the specified number of records. Db_ActiveRecord
list_related_records_deferred() returns a list of relation objects, taking into account deferred relations. Db_ActiveRecord
order() allows to order the result of the find_all() method by a specific table column. Db_SqlBase
orWhere() adds OR statement to the where clause, allowing to to limit the result of the find() and find_all() methods with SQL filter. Db_WhereBase
output() outputs the file to the browser. Db_File
paginate() allows to limit the result of the find_all() method with a single page of records. Db_ActiveRecord
requestRowCount() returns a number of rows which would be returned with find_all() method. Db_ActiveRecord
save() saves record to the database. Db_ActiveRecord
thumb() this method is an alias for the getThumbnailPath() method. Db_File
where() allows to limit the result of the find() and find_all() methods with SQL filter. Db_WhereBase

Protected methods

Show inherited methods.

Method Description Defined By
define_columns() defines model columns. Db_ActiveRecord

Property details

size_str property

public string $size_str;
Specifies the file size as string.

Method details

download_url() method

public string download_url(Shop_Order $order, string $mode=NULL, string $custom_download_url=NULL)
$order Shop_Order specifies the order object.
$mode string specifies the file download mode (disposition). Supported values are: attachment, inline.
$custom_download_url string specifies a custom download URL.
{return} string returns the URL string.
Returns an URL for downloading the file. Use this function to create links to product files. Please refer the Creating the Order Details page article for details of the method usage. In the default implementation customers can only download files from products which belong to paid orders. You can develop a custom file download page as it is described in the Integrating downloadable products article.
By default the built-in URL /download_product_file used for product downloadable files. The $custom_download_url parameter allows to specify an URL of a custom file download page. A custom download URL should should be specified relative to LemonStand root address, without the subdirectory prefix: /custom_download_page