Functions

Add a download.

add_download(\AUTO_LINK $category_id, \SHORT_TEXT $name, \URLPATH $url, \LONG_TEXT $description, \ID_TEXT $author, \LONG_TEXT $additional_details, \?AUTO_LINK $out_mode_id, \BINARY $validated, \BINARY $allow_rating, \SHORT_INTEGER $allow_comments, \BINARY $allow_trackbacks, \LONG_TEXT $notes, \SHORT_TEXT $original_filename, integer $file_size, integer $cost, \BINARY $submitter_gets_points, \?AUTO_LINK $licence = null, \?TIME $add_date = null, integer $num_downloads = 0, integer $views = 0, \?MEMBER $submitter = null, \?TIME $edit_date = null, \?AUTO_LINK $id = null, \SHORT_TEXT $meta_keywords = '', \LONG_TEXT $meta_description = '', integer $default_pic = 1, \URLPATH $url_redirect = '') : \AUTO_LINK
package downloads

Parameters

$category_id

\AUTO_LINK

The ID of the category the download is to be in

$name

\SHORT_TEXT

The name of the download

$url

\URLPATH

The URL to the download

$description

\LONG_TEXT

The description of the download

$author

\ID_TEXT

The author of the download (not necessarily same as the submitter)

$additional_details

\LONG_TEXT

The supplementary description for the download

$out_mode_id

\?AUTO_LINK

The out-mode-id (the ID of a download that this download is an old version of). Often people wonder why this is specified with the old version, and not the opposite with the new version - it is because statistically, we perceive more chance of downloads merging than splitting (null: none)

$validated

\BINARY

Whether the download has been validated

$allow_rating

\BINARY

Whether the download may be rated

$allow_comments

\SHORT_INTEGER

Whether comments are allowed (0=no, 1=yes, 2=review style)

$allow_trackbacks

\BINARY

Whether the download may be trackbacked

$notes

\LONG_TEXT

Hidden notes pertaining to the download

$original_filename

\SHORT_TEXT

The downloads original filename (the URL may be obfuscated)

$file_size

integer

The file size of the download (we can't really detect this in real-time for remote URLs)

$cost

integer

The cost of the download that members will have to pay to get it

$submitter_gets_points

\BINARY

Whether the submitter gets the points for the download (they are selling it) (otherwise they are just thrown out, which is an alternative model - one of enforcing community point building)

$licence

\?AUTO_LINK

The licence to use (null: none)

$add_date

\?TIME

The add date for the download (null: now)

$num_downloads

integer

The number of downloads that this download has had

$views

integer

The number of views that this download has had

$submitter

\?MEMBER

The submitter (null: current user)

$edit_date

\?TIME

The edit date (null: never)

$id

\?AUTO_LINK

Force an ID (null: don't force an ID)

$meta_keywords

\SHORT_TEXT

Meta keywords for this resource (blank: implicit)

$meta_description

\LONG_TEXT

Meta description for this resource (blank: implicit)

$default_pic

integer

The ordered number of the gallery image to use as the download representative image

$url_redirect

\URLPATH

The URL to redirect

Returns

\AUTO_LINKThe ID of the newly added download

Add a download category

add_download_category(\SHORT_TEXT $category, \AUTO_LINK $parent_id, \LONG_TEXT $description, \LONG_TEXT $notes, \URLPATH $rep_image = '', \?AUTO_LINK $id = null, \?TIME $add_time = null, \?SHORT_TEXT $meta_keywords = '', \?LONG_TEXT $meta_description = '') : \AUTO_LINK
package downloads

Parameters

$category

\SHORT_TEXT

The name of the download category

$parent_id

\AUTO_LINK

The parent download category

$description

\LONG_TEXT

A description

$notes

\LONG_TEXT

Hidden notes pertaining to this download category

$rep_image

\URLPATH

The representative image for the category (blank: none)

$id

\?AUTO_LINK

Force an ID (null: don't force an ID)

$add_time

\?TIME

Add time (null: now)

$meta_keywords

\?SHORT_TEXT

Meta keywords for this resource (null: do not edit) (blank: implicit)

$meta_description

\?LONG_TEXT

Meta description for this resource (null: do not edit) (blank: implicit)

Returns

\AUTO_LINKThe ID of the newly added download category

Add a download licence.

add_download_licence(\SHORT_TEXT $title, \LONG_TEXT $text) : \AUTO_LINK
package downloads

Parameters

$title

\SHORT_TEXT

The title of the download licence

$text

\LONG_TEXT

The text of the download licence

Returns

\AUTO_LINKThe ID of the new download licence

Count the downloads and subcategories underneath the specified category, recursively.

count_download_category_children(\AUTO_LINK $category_id) : array
package downloads

Parameters

$category_id

\AUTO_LINK

The ID of the category for which count details are collected

Returns

arrayThe number of downloads is returned in $output['num_downloads'], and the number of subcategories is returned in $output['num_children'], and the (possibly recursive) number of downloads is returned in $output['num_downloads_children'].

Create a data-mash from the file at a URL. This is data useful for the search engine.

create_data_mash(\URLPATH $url, \?string $data = null, \?ID_TEXT $extension = null, boolean $direct_path = false) : \LONG_TEXT
package downloads

Parameters

$url

\URLPATH

The URL to make a data-mash of, or a filename if $data isn't blank

$data

\?string

Data (null: use URL)

$extension

\?ID_TEXT

File extension (null: get from URL)

$direct_path

boolean

Whether a direct file path was given instead of a URL

Returns

\LONG_TEXTThe data-mash

Get a nice, formatted XHTML list extending from the root, and showing all subcategories, and their subcategories (ad infinitum). The tree bit is because each entry in the list is shown to include the path through the tree that gets to it

create_selection_list_download_category_tree(\?AUTO_LINK $it = null, boolean $use_compound_list = false, boolean $addable_filter = false, \?TIME $updated_since = null) : \Tempcode
package downloads

Parameters

$it

\?AUTO_LINK

The currently selected category (null: none selected)

$use_compound_list

boolean

Whether to make the list elements store comma-separated child lists instead of IDs

$addable_filter

boolean

Whether to only show for what may be added to by the current member

$updated_since

\?TIME

Time from which content must be updated (null: no limit).

Returns

\TempcodeThe list of categories

Get a nice, formatted XHTML list to select a download licence

create_selection_list_download_licences(\?AUTO_LINK $it = null, boolean $allow_na = false) : \Tempcode
package downloads

Parameters

$it

\?AUTO_LINK

The currently selected licence (null: none selected)

$allow_na

boolean

Whether to allow an N/A selection

Returns

\TempcodeThe list of categories

Get a nice, formatted XHTML list of downloads, in download tree structure

create_selection_list_downloads_tree(\?AUTO_LINK $it = null, \?AUTO_LINK $submitter = null, \?AUTO_LINK $shun = null, boolean $use_compound_list = false, boolean $editable_filter = false) : \Tempcode
package downloads

Parameters

$it

\?AUTO_LINK

The currently selected entry (null: none selected)

$submitter

\?AUTO_LINK

Only show entries submitted by this member (null: no filter)

$shun

\?AUTO_LINK

Download we do not want to show (null: none to not show)

$use_compound_list

boolean

Whether to get a list of child categories (not just direct ones, recursively), instead of just IDs

$editable_filter

boolean

Whether to only show for what may be edited by the current member

Returns

\TempcodeThe list of entries

Delete a download.

delete_download(\AUTO_LINK $id, boolean $leave = false
package downloads

Parameters

$id

\AUTO_LINK

The ID of the download to delete

$leave

boolean

Whether to leave the actual file behind

Delete a download category.

delete_download_category(\AUTO_LINK $category_id) 
package downloads

Parameters

$category_id

\AUTO_LINK

The download category to delete

Delete a download licence.

delete_download_licence(\AUTO_LINK $id) 
package downloads

Parameters

$id

\AUTO_LINK

The ID of the download licence to delete

Farm out the files for downloads.

dload_script() 
package downloads

Get a formatted XHTML string of the route back to the specified root, from the specified category.

download_breadcrumbs(\AUTO_LINK $category_id, \?AUTO_LINK $root = null, boolean $no_link_for_me_sir = true, \?ID_TEXT $zone = null, boolean $attach_to_url_filter = false) : \Tempcode: array
package downloads

Parameters

$category_id

\AUTO_LINK

The category we are finding for

$root

\?AUTO_LINK

The root of the tree (null: the true root)

$no_link_for_me_sir

boolean

Whether to include category links at this level (the recursed levels will always contain links - the top level is optional, hence this parameter)

$zone

\?ID_TEXT

The zone the download module we're using is in (null: find it)

$attach_to_url_filter

boolean

Whether to copy through any filter parameters in the URL, under the basis that they are associated with what this box is browsing

Returns

\TempcodeThe breadcrumbs
arrayThe breadcrumb segments

Farm out the files for downloads.

download_gateway_script() 
package downloads

Show a download licence for display

download_licence_script() 
package downloads

Edit a download.

edit_download(\AUTO_LINK $id, \AUTO_LINK $category_id, \SHORT_TEXT $name, \URLPATH $url, \LONG_TEXT $description, \ID_TEXT $author, \LONG_TEXT $additional_details, \?AUTO_LINK $out_mode_id, integer $default_pic, \BINARY $validated, \BINARY $allow_rating, \SHORT_INTEGER $allow_comments, \BINARY $allow_trackbacks, \LONG_TEXT $notes, \SHORT_TEXT $original_filename, integer $file_size, integer $cost, \BINARY $submitter_gets_points, \?AUTO_LINK $licence, \SHORT_TEXT $meta_keywords, \LONG_TEXT $meta_description, \?TIME $edit_time = null, \?TIME $add_time = null, \?integer $views = null, \?MEMBER $submitter = null, \?integer $num_downloads = null, boolean $null_is_literal = false, \URLPATH $url_redirect = ''
package downloads

Parameters

$id

\AUTO_LINK

The ID of the download to edit

$category_id

\AUTO_LINK

The ID of the category the download is to be in

$name

\SHORT_TEXT

The name of the download

$url

\URLPATH

The URL to the download

$description

\LONG_TEXT

The description of the download

$author

\ID_TEXT

The author of the download (not necessarily same as the submitter)

$additional_details

\LONG_TEXT

The supplementary description for the download

$out_mode_id

\?AUTO_LINK

The out-mode-id (the ID of a download that this download is an old version of). Often people wonder why this is specified with the old version, and not the opposite with the new version - it is because statistically, we perceive more chance of downloads merging than splitting (null: none)

$default_pic

integer

The ordered number of the gallery image to use as the download representative image

$validated

\BINARY

Whether the download has been validated

$allow_rating

\BINARY

Whether the download may be rated

$allow_comments

\SHORT_INTEGER

Whether comments are allowed (0=no, 1=yes, 2=review style)

$allow_trackbacks

\BINARY

Whether the download may be trackbacked

$notes

\LONG_TEXT

Hidden notes pertaining to the download

$original_filename

\SHORT_TEXT

The downloads original filename (the URL may be obfuscated)

$file_size

integer

The file size of the download (we can't really detect this in real-time for remote URLs)

$cost

integer

The cost of the download that members will have to pay to get it

$submitter_gets_points

\BINARY

Whether the submitter gets the points for the download (they are selling it) (otherwise they are just thrown out, which is an alternative model - one of enforcing community point building)

$licence

\?AUTO_LINK

The licence to use (null: none)

$meta_keywords

\SHORT_TEXT

Meta keywords

$meta_description

\LONG_TEXT

Meta description

$edit_time

\?TIME

Edit time (null: either means current time, or if $null_is_literal, means reset to to NULL)

$add_time

\?TIME

Add time (null: do not change)

$views

\?integer

Number of views (null: do not change)

$submitter

\?MEMBER

Submitter (null: do not change)

$num_downloads

\?integer

The number of downloads that this download has had (null: do not change)

$null_is_literal

boolean

Determines whether some NULLs passed mean 'use a default' or literally mean 'set to NULL'

$url_redirect

\URLPATH

The URL to redirect

Edit the given download category with the new details given

edit_download_category(\AUTO_LINK $category_id, \SHORT_TEXT $category, \AUTO_LINK $parent_id, \LONG_TEXT $description, \LONG_TEXT $notes, \URLPATH $rep_image, \?SHORT_TEXT $meta_keywords, \?LONG_TEXT $meta_description, \?TIME $add_time = null
package downloads

Parameters

$category_id

\AUTO_LINK

The ID of the category being edited

$category

\SHORT_TEXT

The name of the download category

$parent_id

\AUTO_LINK

The parent download category

$description

\LONG_TEXT

A description

$notes

\LONG_TEXT

Hidden notes pertaining to this download category

$rep_image

\URLPATH

The representative image for the category (blank: none)

$meta_keywords

\?SHORT_TEXT

Meta keywords for this resource (null: do not edit)

$meta_description

\?LONG_TEXT

Meta description for this resource (null: do not edit)

$add_time

\?TIME

Add time (null: do not change)

Edit a download licence.

edit_download_licence(\AUTO_LINK $id, \SHORT_TEXT $title, \LONG_TEXT $text) 
package downloads

Parameters

$id

\AUTO_LINK

The ID of the download licence to edit

$title

\SHORT_TEXT

The title of the download licence

$text

\LONG_TEXT

The text of the download licence

Generate a link to a Composr download.

generate_dload_url(\AUTO_LINK $id, boolean $use_gateway) : \URLPATH
package downloads

Parameters

$id

\AUTO_LINK

The ID of the download to be downloaded

$use_gateway

boolean

Whether to use the gateway script

Returns

\URLPATHThe URL

Get the total size of all the currently available downloads in a formatted string.

get_download_archive_size() : string
package downloads

Returns

stringThe total size of all the currently available downloads

Get the currently used download bandwidth.

get_download_bandwidth() : integer
package downloads

Returns

integerThe currently used download bandwidth (forever)

Get a list of maps containing all the subcategories, and path information, of the specified category - and those beneath it, recursively.

get_download_category_tree(\?AUTO_LINK $category_id = null, \?string $breadcrumbs = null, \?ID_TEXT $category_info = null, boolean $do_stats = false, boolean $use_compound_list = false, \?integer $levels = null, boolean $addable_filter = false) : array
package downloads

Parameters

$category_id

\?AUTO_LINK

The category being at the root of our recursion (null: true root category)

$breadcrumbs

\?string

The breadcrumbs up to this point in the recursion (null: blank, as we are starting the recursion)

$category_info

\?ID_TEXT

The category row of the $category_id we are currently going through (null: look it up). This is here for efficiency reasons, as finding children IDs to recurse to also reveals the childs details

$do_stats

boolean

Whether to collect download counts with our tree information

$use_compound_list

boolean

Whether to make a compound list (a pair of a comma-separated list of children, and the child array)

$levels

\?integer

The number of recursive levels to search (null: all)

$addable_filter

boolean

Whether to only show for what may be added to by the current member

Returns

arrayA list of maps for all subcategories. Each map entry containins the fields 'id' (category ID) and 'breadcrumbs' (path to the category, including the categories own title). There is also an additional 'downloadcount' entry if stats were requested

Get a list of maps containing all the downloads, and path information, under the specified category - and those beneath it, recursively.

get_downloads_tree(\?MEMBER $submitter = null, \?AUTO_LINK $category_id = null, \?string $breadcrumbs = null, \?ID_TEXT $title = null, \?integer $shun = null, \?AUTO_LINK $levels = null, boolean $use_compound_list = false, boolean $editable_filter = false, boolean $tar_filter = false) : array
package downloads

Parameters

$submitter

\?MEMBER

Only show images/videos submitted by this member (null: no filter)

$category_id

\?AUTO_LINK

The category being at the root of our recursion (null: true root)

$breadcrumbs

\?string

The breadcrumbs up to this point in the recursion (null: blank, as we are starting the recursion)

$title

\?ID_TEXT

The name of the $category_id we are currently going through (null: look it up). This is here for efficiency reasons, as finding children IDs to recurse to also reveals the childs title

$shun

\?integer

The number of recursive levels to search (null: all)

$levels

\?AUTO_LINK

Download we do not want to show (null: none to not show)

$use_compound_list

boolean

Whether to get a list of child categories (not just direct ones, recursively), instead of just IDs

$editable_filter

boolean

Whether to only show for what may be edited by the current member

$tar_filter

boolean

Whether to only show entries that are tar files (addons)

Returns

arrayA list of maps for all categories. Each map entry containins the fields 'id' (category ID) and 'breadcrumbs' (to the category, including the categories own title), and more. Or if $use_compound_list, the tree structure built with pairs containing the compound list in addition to the child branches

Get the total number of downloads available.

get_num_archive_downloads() : integer
package downloads

Returns

integerThe total number of downloads available

Get the total number of files downloaded since installation.

get_num_downloads_downloaded() : integer
package downloads

Returns

integerThe total number of files downloaded since installation

Log a file download, update the downloads counter and the download bandwidth counter.

log_download(\AUTO_LINK $id, integer $size, boolean $got_before) 
package downloads

Parameters

$id

\AUTO_LINK

The ID of the download being downloaded

$size

integer

The size of the download (if zero, no bandwidth will be done - zero implies either an empty file, or a remote file that doesn't affect our bandwidth)

$got_before

boolean

Whether the download has been downloaded before

Get Tempcode for a download 'feature box' for the sgiven row

render_download_box(array $row, boolean $pic = true, boolean $include_breadcrumbs = true, \?ID_TEXT $zone = null, \?string $text_summary = null, boolean $give_context = true, \?AUTO_LINK $root = null, \ID_TEXT $guid = '') : \Tempcode
package downloads

Parameters

$row

array

The database field row of this download

$pic

boolean

Whether to show a picture

$include_breadcrumbs

boolean

Whether to show breadcrumbs

$zone

\?ID_TEXT

The zone the download module we're using is in (null: find it)

$text_summary

\?string

Text summary for result (e.g. highlighted portion of actual file from search result) (null: none)

$give_context

boolean

Whether to include context (i.e. say WHAT this is, not just show the actual content)

$root

\?AUTO_LINK

The virtual root (null: read from environment)

$guid

\ID_TEXT

Overridden GUID to send to templates (blank: none)

Returns

\TempcodeA box for this download, linking to the full download page

Get Tempcode for a download category 'feature box' for the given row

render_download_category_box(array $row, \ID_TEXT $zone = '_SEARCH', boolean $give_context = true, boolean $include_breadcrumbs = true, \?AUTO_LINK $root = null, boolean $attach_to_url_filter = false, \ID_TEXT $guid = '') : \Tempcode
package downloads

Parameters

$row

array

The database field row of it

$zone

\ID_TEXT

The zone to use

$give_context

boolean

Whether to include context (i.e. say WHAT this is, not just show the actual content)

$include_breadcrumbs

boolean

Whether to include breadcrumbs (if there are any)

$root

\?AUTO_LINK

Virtual root to use (null: none)

$attach_to_url_filter

boolean

Whether to copy through any filter parameters in the URL, under the basis that they are associated with what this box is browsing

$guid

\ID_TEXT

Overridden GUID to send to templates (blank: none)

Returns

\TempcodeA box for it, linking to the full page