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 4506 to 4543

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 3rd October 2022 12:05 Europe/London time based on the source file dated 30th September 2022 14:20 Europe/London time.