Functions

Add a download.

add_download(\AUTO_LINK $category_id, \SHORT_TEXT $name, \URLPATH $url, \LONG_TEXT $description, \ID_TEXT $author, \LONG_TEXT $comments, \?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, \?TIME $add_date, integer $num_downloads, integer $views, \?MEMBER $submitter, \?TIME $edit_date, \?AUTO_LINK $id) : \AUTO_LINK

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)

$comments

\LONG_TEXT

The comments 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)

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) : \AUTO_LINK

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)

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

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

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.

create_data_mash(\URLPATH $url, \?string $data, \?ID_TEXT $extension, boolean $direct_path) : \LONG_TEXT

This is data useful for the search engine.

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

Delete a download.

delete_download(\AUTO_LINK $id, boolean $leave) 

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) 

Parameters

$category_id

\AUTO_LINK

The download category to delete

Delete a download licence.

delete_download_licence(\AUTO_LINK $id) 

Parameters

$id

\AUTO_LINK

The ID of the download licence to delete

Farm out the files for downloads.

dload_script() 

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, boolean $no_link_for_me_sir, \?ID_TEXT $zone) : \tempcode

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)

Returns

\tempcodeThe breadcrumbs

Show a download licence for display

download_licence_script() 

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 $comments, \?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) 

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)

$comments

\LONG_TEXT

The comments 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 the given download category with the new details given

edit_download_category(\SHORT_TEXT $category, \AUTO_LINK $parent_id, \LONG_TEXT $description, \AUTO_LINK $category_id, \LONG_TEXT $notes, \URLPATH $rep_image, \?SHORT_TEXT $meta_keywords, \?LONG_TEXT $meta_description) 

Parameters

$category

\SHORT_TEXT

The name of the download category

$parent_id

\AUTO_LINK

The parent download category

$description

\LONG_TEXT

A description

$category_id

\AUTO_LINK

The ID of the category being edited

$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)

Edit a download licence.

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

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

Get tempcode to view the downloads in a download category.

get_category_downloads(\AUTO_LINK $category_id, \AUTO_LINK $root, \?string $order) : \tempcode

Parameters

$category_id

\AUTO_LINK

The download category ID

$root

\AUTO_LINK

The virtual root

$order

\?string

Force an order (NULL: don't)

Returns

\tempcodeThe UI

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

get_download_archive_size() : string

Returns

stringThe total size of all the currently available downloads

Get the currently used download bandwidth.

get_download_bandwidth() : integer

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, \?string $breadcrumbs, \?ID_TEXT $title, boolean $do_stats, boolean $use_compound_list, \?integer $levels, boolean $addable_filter) : array

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)

$title

\?ID_TEXT

The category 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

$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 templated view of the subcategories directly under the specified category.

get_download_sub_categories(\AUTO_LINK $category_id, \?AUTO_LINK $root, \?ID_TEXT $zone, \?string $order) : \tempcode

Parameters

$category_id

\AUTO_LINK

The category the subcategories are being found for

$root

\?AUTO_LINK

The pretend root of our download system (NULL: true root). This system is provided for large sites to be able to do virtually seperated download systems

$zone

\?ID_TEXT

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

$order

\?string

The order to show results in (NULL: default)

Returns

\tempcodeThe templated view

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, \?AUTO_LINK $category_id, \?string $breadcrumbs, \?ID_TEXT $title, \?integer $shun, \?AUTO_LINK $levels, boolean $use_compound_list, boolean $editable_filter, boolean $tar_filter) : array

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

Returns

integerThe total number of downloads available

Get the total number of files downloaded since installation.

get_num_downloads_downloaded() : integer

Returns

integerThe total number of files downloaded since installation

Standard code module initialisation function.

init__downloads() 

Standard code module initialisation function.

init__downloads2() 

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

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

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 a nice, formatted XHTML list extending from the root, and showing all subcategories, and their subcategories (ad infinitum).

nice_get_download_category_tree(\?AUTO_LINK $it, boolean $use_compound_list, boolean $addable_filter) : \tempcode

The tree bit is because each entry in the list is shown to include the path through the tree that gets to it

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

Returns

\tempcodeThe list of categories

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

nice_get_download_licences(\?AUTO_LINK $it, boolean $allow_na) : \tempcode

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

nice_get_downloads_tree(\?AUTO_LINK $it, \?AUTO_LINK $submitter, \?AUTO_LINK $shun, boolean $use_compound_list, boolean $editable_filter) : \tempcode

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

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

render_download_box(array $row, boolean $pic, boolean $include_breadcrumbs, \?ID_TEXT $zone, \?string $text_summary) : \tempcode

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)

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, boolean $put_in_box) : \tempcode

Parameters

$row

array

The database field row of it

$zone

\ID_TEXT

The zone to use

$put_in_box

boolean

Whether to put it in a box

Returns

\tempcodeA box for it, linking to the full page