Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test functions

get_alternative_files()

Description

Retrieves alternative files associated with a specified resource.

Parameters

ColumnTypeDefaultDescription
$resource int The resource ID for which to fetch alternative files.
$order_by string "" The field to order the results by (optional).
$sort string "" The sorting direction (ASC or DESC) for the order_by field (optional).
$type string "" The type of alternative file to filter by (optional).

Return

array|bool An array of alternative files if successful, false otherwise.

Location

include/resource_functions.php lines 4548 to 4583

Definition

 
function get_alternative_files($resource$order_by ""$sort ""$type "")
{
    
# Returns a list of alternative files for the given resource
    
if (
        
$order_by != ""
        
&& $sort != ""
        
&& in_array(strtoupper($order_by), array("ALT_TYPE"))
        && 
validate_sort_value($sort)
    ) {
        
$ordersort $order_by " " $sort ",";
    } else {
        
$ordersort "";
    }

    
# The following hook now returns a query object
    
$extrasql hook("get_alternative_files_extra_sql""", array($resource));

    if (!
$extrasql) {
        
# Hook inactive, ensure we have an empty query object
        
$extrasql = new PreparedStatementQuery();
    }

    
# Filter by type, if provided.
    
if ($type != "") {
        
$extrasql->sql .= " AND alt_type=?";
        
$extrasql->parameters array_merge($extrasql->parameters, array("s",$type));
    }

    
$alt_files_sql "SELECT ref,name,description,file_name,file_extension,file_size,creation_date,alt_type
                    FROM resource_alt_files where resource=? " 
$extrasql->sql .
                   
" order by " $ordersort " name asc, file_size desc";

    
$alt_files_parameters array_merge(array("i",$resource), $extrasql->parameters);

    return 
ps_query($alt_files_sql$alt_files_parameters);
}

This article was last updated 11th February 2025 20:35 Europe/London time based on the source file dated 10th February 2025 10:40 Europe/London time.