HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

ocPortal Developer's Guide: Downloads

» Return to Contents



sources/downloads.php

Global_functions_downloads.php

Function summary

void init__downloads ()
void download_licence_script ()
tempcode get_download_html (array row, boolean pic, boolean breadcrumbs, ?ID_TEXT zone, ?string text_summary)
tempcode get_download_category_html (array row, ID_TEXT zone, boolean put_in_box)
tempcode nice_get_downloads_tree (?AUTO_LINK it, ?AUTO_LINK submitter, ?AUTO_LINK shun, boolean use_compound_list, boolean editable_filter)
array get_downloads_tree (?MEMBER submitter, ?AUTO_LINK category_id, ?string tree, ?ID_TEXT title, ?integer shun, ?AUTO_LINK levels, boolean use_compound_list, boolean editable_filter, boolean tar_filter)
tempcode nice_get_download_category_tree (?AUTO_LINK it, boolean use_compound_list, boolean addable_filter)
tempcode nice_get_download_licences (?AUTO_LINK it, boolean allow_na)
array get_download_category_tree (?AUTO_LINK category_id, ?string tree, ?ID_TEXT title, boolean do_stats, boolean use_compound_list, ?integer levels, boolean addable_filter)
tempcode download_breadcrumbs (AUTO_LINK category_id, ?AUTO_LINK root, boolean no_link_for_me_sir, ?ID_TEXT zone)
array count_download_category_children (AUTO_LINK category_id)
tempcode get_category_downloads (AUTO_LINK category_id, AUTO_LINK root, ?string order)
tempcode get_download_sub_categories (AUTO_LINK category_id, ?AUTO_LINK root, ?ID_TEXT zone, ?string order)

void init__downloads()

Standard code module initialisation function.

Parameters…

(No return value)


Return to the function index for this class Expand: View the source code to this function

void download_licence_script()

Show a download licence for display

Parameters…

(No return value)


Return to the function index for this class Expand: View the source code to this function

tempcode get_download_html(array row, boolean pic, boolean breadcrumbs, ?ID_TEXT zone, ?string text_summary)

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

Parameters…

Name row
Description The database field row of this download
Type array

Name pic
Description Whether to show a picture
Default value boolean-true
Type boolean

Name breadcrumbs
Description Whether to show breadcrumbs
Default value boolean-true
Type boolean

Name zone
Description The zone the download module we're using is in (NULL: find it)
Default value
Type ?ID_TEXT

Name text_summary
Description Text summary for result (e.g. highlighted portion of actual file from search result) (NULL: none)
Default value
Type ?string

Returns…

Description A box for this download, linking to the full download page
Type tempcode

Return to the function index for this class Expand: View the source code to this function

tempcode get_download_category_html(array row, ID_TEXT zone, boolean put_in_box)

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

Parameters…

Name row
Description The database field row of it
Type array

Name zone
Description The zone to use
Default value _SEARCH
Type ID_TEXT

Name put_in_box
Description Whether to put it in a box
Default value boolean-true
Type boolean

Returns…

Description A box for it, linking to the full page
Type tempcode

Return to the function index for this class Expand: View the source code to this function

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

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

Parameters…

Name it
Description The currently selected entry (NULL: none selected)
Default value
Type ?AUTO_LINK

Name submitter
Description Only show entries submitted by this member (NULL: no filter)
Default value
Type ?AUTO_LINK

Name shun
Description Download we do not want to show (NULL: none to not show)
Default value
Type ?AUTO_LINK

Name use_compound_list
Description Whether to get a list of child categories (not just direct ones, recursively), instead of just IDs
Default value boolean-false
Type boolean

Name editable_filter
Description Whether to only show for what may be edited by the current member
Default value boolean-false
Type boolean

Returns…

Description The list of entries
Type tempcode

Return to the function index for this class Expand: View the source code to this function

array get_downloads_tree(?MEMBER submitter, ?AUTO_LINK category_id, ?string tree, ?ID_TEXT title, ?integer shun, ?AUTO_LINK levels, boolean use_compound_list, boolean editable_filter, boolean tar_filter)

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

Parameters…

Name submitter
Description Only show images/videos submitted by this member (NULL: no filter)
Default value
Type ?MEMBER

Name category_id
Description The category being at the root of our recursion (NULL: true root)
Default value
Type ?AUTO_LINK

Name tree
Description The tree up to this point in the recursion (NULL: blank, as we are starting the recursion)
Default value
Type ?string

Name title
Description 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
Default value
Type ?ID_TEXT

Name shun
Description The number of recursive levels to search (NULL: all)
Default value
Type ?integer

Name levels
Description Download we do not want to show (NULL: none to not show)
Default value
Type ?AUTO_LINK

Name use_compound_list
Description Whether to get a list of child categories (not just direct ones, recursively), instead of just IDs
Default value boolean-false
Type boolean

Name editable_filter
Description Whether to only show for what may be edited by the current member
Default value boolean-false
Type boolean

Name tar_filter
Description Whether to only show entries that are tar files (addons)
Default value boolean-false
Type boolean

Returns…

Description A list of maps for all categories. Each map entry containins the fields 'id' (category ID) and 'tree' (tree path 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
Type array

Return to the function index for this class Expand: View the source code to this function

tempcode nice_get_download_category_tree(?AUTO_LINK it, boolean use_compound_list, boolean addable_filter)

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

Parameters…

Name it
Description The currently selected category (NULL: none selected)
Default value
Type ?AUTO_LINK

Name use_compound_list
Description Whether to make the list elements store comma-separated child lists instead of IDs
Default value boolean-false
Type boolean

Name addable_filter
Description Whether to only show for what may be added to by the current member
Default value boolean-false
Type boolean

Returns…

Description The list of categories
Type tempcode

Return to the function index for this class Expand: View the source code to this function

tempcode nice_get_download_licences(?AUTO_LINK it, boolean allow_na)

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

Parameters…

Name it
Description The currently selected licence (NULL: none selected)
Default value
Type ?AUTO_LINK

Name allow_na
Description Whether to allow an N/A selection
Default value boolean-false
Type boolean

Returns…

Description The list of categories
Type tempcode

Return to the function index for this class Expand: View the source code to this function

array get_download_category_tree(?AUTO_LINK category_id, ?string tree, ?ID_TEXT title, boolean do_stats, boolean use_compound_list, ?integer levels, boolean addable_filter)

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

Parameters…

Name category_id
Description The category being at the root of our recursion (NULL: true root category)
Default value
Type ?AUTO_LINK

Name tree
Description The tree up to this point in the recursion (NULL: blank, as we are starting the recursion)
Default value
Type ?string

Name title
Description 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
Default value
Type ?ID_TEXT

Name do_stats
Description Whether to collect download counts with our tree information
Default value boolean-true
Type boolean

Name use_compound_list
Description Whether to make a compound list (a pair of a comma-separated list of children, and the child array)
Default value boolean-false
Type boolean

Name levels
Description The number of recursive levels to search (NULL: all)
Default value
Type ?integer

Name addable_filter
Description Whether to only show for what may be added to by the current member
Default value boolean-false
Type boolean

Returns…

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

Return to the function index for this class Expand: View the source code to this function

tempcode download_breadcrumbs(AUTO_LINK category_id, ?AUTO_LINK root, boolean no_link_for_me_sir, ?ID_TEXT zone)

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

Parameters…

Name category_id
Description The category we are finding for
Type AUTO_LINK

Name root
Description The root of the tree (NULL: the true root)
Default value
Type ?AUTO_LINK

Name no_link_for_me_sir
Description Whether to include category links at this level (the recursed levels will always contain links - the top level is optional, hence this parameter)
Default value boolean-true
Type boolean

Name zone
Description The zone the download module we're using is in (NULL: find it)
Default value
Type ?ID_TEXT

Returns…

Description The tree route
Type tempcode

Return to the function index for this class Expand: View the source code to this function

array count_download_category_children(AUTO_LINK category_id)

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

Parameters…

Name category_id
Description The ID of the category for which count details are collected
Type AUTO_LINK

Returns…

Description The 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'].
Type array

Return to the function index for this class Expand: View the source code to this function

tempcode get_category_downloads(AUTO_LINK category_id, AUTO_LINK root, ?string order)

Get tempcode to view the downloads in a download category.

Parameters…

Name category_id
Description The download category ID
Type AUTO_LINK

Name root
Description The virtual root
Type AUTO_LINK

Name order
Description Force an order (NULL: don't)
Default value
Type ?string

Returns…

Description The UI
Type tempcode

Return to the function index for this class Expand: View the source code to this function

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

Get a templated view of the subcategories directly under the specified category.

Parameters…

Name category_id
Description The category the subcategories are being found for
Type AUTO_LINK

Name root
Description 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
Default value
Type ?AUTO_LINK

Name zone
Description The zone the download module we're using is in (NULL: find it)
Default value
Type ?ID_TEXT

Name order
Description The order to show results in (NULL: default)
Default value
Type ?string

Returns…

Description The templated view
Type tempcode

Return to the function index for this class Expand: View the source code to this function

sources/downloads2.php

Global_functions_downloads2.php

Function summary

void init__downloads2 ()
void dload_script ()
AUTO_LINK add_download_category (SHORT_TEXT category, AUTO_LINK parent_id, LONG_TEXT description, LONG_TEXT notes, URLPATH rep_image, ?AUTO_LINK id)
void 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)
void delete_download_category (AUTO_LINK category_id)
LONG_TEXT create_data_mash (URLPATH url, ?string data, ?ID_TEXT extension, boolean direct_path)
AUTO_LINK 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)
void set_download_gallery_permissions (AUTO_LINK id, ?MEMBER submitter)
void 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)
void delete_download (AUTO_LINK id, boolean leave)
AUTO_LINK add_download_licence (SHORT_TEXT title, LONG_TEXT text)
void edit_download_licence (AUTO_LINK id, SHORT_TEXT title, LONG_TEXT text)
void delete_download_licence (AUTO_LINK id)
void log_download (AUTO_LINK id, integer size, boolean got_before)

void init__downloads2()

Standard code module initialisation function.

Parameters…

(No return value)


Return to the function index for this class Expand: View the source code to this function

void dload_script()

Farm out the files for downloads.

Parameters…

(No return value)


Return to the function index for this class Expand: View the source code to this function

AUTO_LINK add_download_category(SHORT_TEXT category, AUTO_LINK parent_id, LONG_TEXT description, LONG_TEXT notes, URLPATH rep_image, ?AUTO_LINK id)

Add a download category

Parameters…

Name category
Description The name of the download category
Type SHORT_TEXT

Name parent_id
Description The parent download category
Type AUTO_LINK

Name description
Description A description
Type LONG_TEXT

Name notes
Description Hidden notes pertaining to this download category
Type LONG_TEXT

Name rep_image
Description The representative image for the category (blank: none)
Default value
Type URLPATH

Name id
Description Force an ID (NULL: don't force an ID)
Default value
Type ?AUTO_LINK

Returns…

Description The ID of the newly added download category
Type AUTO_LINK

Return to the function index for this class Expand: View the source code to this function

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

Edit the given download category with the new details given

Parameters…

Name category
Description The name of the download category
Type SHORT_TEXT

Name parent_id
Description The parent download category
Type AUTO_LINK

Name description
Description A description
Type LONG_TEXT

Name category_id
Description The ID of the category being edited
Type AUTO_LINK

Name notes
Description Hidden notes pertaining to this download category
Type LONG_TEXT

Name rep_image
Description The representative image for the category (blank: none)
Type URLPATH

Name meta_keywords
Description Meta keywords for this resource (NULL: do not edit)
Type ?SHORT_TEXT

Name meta_description
Description Meta description for this resource (NULL: do not edit)
Type ?LONG_TEXT

(No return value)


Return to the function index for this class Expand: View the source code to this function

void delete_download_category(AUTO_LINK category_id)

Delete a download category.

Parameters…

Name category_id
Description The download category to delete
Type AUTO_LINK

(No return value)


Return to the function index for this class Expand: View the source code to this function

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

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

Parameters…

Name url
Description The URL to make a data-mash of, or a filename if $data isn't blank
Type URLPATH

Name data
Description Data (NULL: use URL)
Default value
Type ?string

Name extension
Description File extension (NULL: get from URL)
Default value
Type ?ID_TEXT

Name direct_path
Description Whether a direct file path was given instead of a URL
Default value boolean-false
Type boolean

Returns…

Description The data-mash
Type LONG_TEXT

Return to the function index for this class Expand: View the source code to this function

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

Add a download.

Parameters…

Name category_id
Description The ID of the category the download is to be in
Type AUTO_LINK

Name name
Description The name of the download
Type SHORT_TEXT

Name url
Description The URL to the download
Type URLPATH

Name description
Description The description of the download
Type LONG_TEXT

Name author
Description The author of the download (not necessarily same as the submitter)
Type ID_TEXT

Name comments
Description The comments for the download
Type LONG_TEXT

Name out_mode_id
Description 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)
Type ?AUTO_LINK

Name validated
Description Whether the download has been validated
Type BINARY

Name allow_rating
Description Whether the download may be rated
Type BINARY

Name allow_comments
Description Whether comments are allowed (0=no, 1=yes, 2=review style)
Type SHORT_INTEGER

Name allow_trackbacks
Description Whether the download may be trackbacked
Type BINARY

Name notes
Description Hidden notes pertaining to the download
Type LONG_TEXT

Name original_filename
Description The downloads original filename (the URL may be obfuscated)
Type SHORT_TEXT

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

Name cost
Description The cost of the download that members will have to pay to get it
Type integer

Name submitter_gets_points
Description 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)
Type BINARY

Name licence
Description The licence to use (NULL: none)
Default value
Type ?AUTO_LINK

Name add_date
Description The add date for the download (NULL: now)
Default value
Type ?TIME

Name num_downloads
Description The number of downloads that this download has had
Default value 0
Type integer

Name views
Description The number of views that this download has had
Default value 0
Type integer

Name submitter
Description The submitter (NULL: current user)
Default value
Type ?MEMBER

Name edit_date
Description The edit date (NULL: never)
Default value
Type ?TIME

Name id
Description Force an ID (NULL: don't force an ID)
Default value
Type ?AUTO_LINK

Returns…

Description The ID of the newly added download
Type AUTO_LINK

Return to the function index for this class Expand: View the source code to this function

void set_download_gallery_permissions(AUTO_LINK id, ?MEMBER submitter)

Set the permissions for a download gallery.

Parameters…

Name id
Description The ID of the download
Type AUTO_LINK

Name submitter
Description The submitter (NULL: work out automatically)
Default value
Type ?MEMBER

(No return value)


Return to the function index for this class Expand: View the source code to this function

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

Edit a download.

Parameters…

Name id
Description The ID of the download to edit
Type AUTO_LINK

Name category_id
Description The ID of the category the download is to be in
Type AUTO_LINK

Name name
Description The name of the download
Type SHORT_TEXT

Name url
Description The URL to the download
Type URLPATH

Name description
Description The description of the download
Type LONG_TEXT

Name author
Description The author of the download (not necessarily same as the submitter)
Type ID_TEXT

Name comments
Description The comments for the download
Type LONG_TEXT

Name out_mode_id
Description 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
Type AUTO_LINK

Name default_pic
Description The ordered number of the gallery image to use as the download representative image
Type integer

Name validated
Description Whether the download has been validated
Type BINARY

Name allow_rating
Description Whether the download may be rated
Type BINARY

Name allow_comments
Description Whether comments are allowed (0=no, 1=yes, 2=review style)
Type SHORT_INTEGER

Name allow_trackbacks
Description Whether the download may be trackbacked
Type BINARY

Name notes
Description Hidden notes pertaining to the download
Type LONG_TEXT

Name original_filename
Description The downloads original filename (the URL may be obfuscated)
Type SHORT_TEXT

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

Name cost
Description The cost of the download that members will have to pay to get it
Type integer

Name submitter_gets_points
Description 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)
Type BINARY

Name licence
Description The licence to use (NULL: none)
Type ?AUTO_LINK

Name meta_keywords
Description Meta keywords
Type SHORT_TEXT

Name meta_description
Description Meta description
Type LONG_TEXT

(No return value)


Return to the function index for this class Expand: View the source code to this function

void delete_download(AUTO_LINK id, boolean leave)

Delete a download.

Parameters…

Name id
Description The ID of the download to delete
Type AUTO_LINK

Name leave
Description Whether to leave the actual file behind
Default value boolean-false
Type boolean

(No return value)


Return to the function index for this class Expand: View the source code to this function

AUTO_LINK add_download_licence(SHORT_TEXT title, LONG_TEXT text)

Add a download licence.

Parameters…

Name title
Description The title of the download licence
Type SHORT_TEXT

Name text
Description The text of the download licence
Type LONG_TEXT

Returns…

Description The ID of the new download licence
Type AUTO_LINK

Return to the function index for this class Expand: View the source code to this function

void edit_download_licence(AUTO_LINK id, SHORT_TEXT title, LONG_TEXT text)

Edit a download licence.

Parameters…

Name id
Description The ID of the download licence to edit
Type AUTO_LINK

Name title
Description The title of the download licence
Type SHORT_TEXT

Name text
Description The text of the download licence
Type LONG_TEXT

(No return value)


Return to the function index for this class Expand: View the source code to this function

void delete_download_licence(AUTO_LINK id)

Delete a download licence.

Parameters…

Name id
Description The ID of the download licence to delete
Type AUTO_LINK

(No return value)


Return to the function index for this class Expand: View the source code to this function

void log_download(AUTO_LINK id, integer size, boolean got_before)

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

Parameters…

Name id
Description The ID of the download being downloaded
Type AUTO_LINK

Name size
Description 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)
Type integer

Name got_before
Description Whether the download has been downloaded before
Type boolean

(No return value)


Return to the function index for this class Expand: View the source code to this function