Collections functions
General functions
Render functions
Theme permission functions
Resource functions

get_alternative_files()

Parameters

ColumnTypeDefaultDescription
$resource
$order_by ""
$sort ""
$type ""

Location

include/resource_functions.php lines 4454 to 4491

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")) 
        && 
in_array(strtoupper($sort),array("ASC","DESC")) )
        {
        
$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 20th May 2022 08:05 Europe/London time based on the source file dated 16th May 2022 11:00 Europe/London time.