Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

add_download_column()

Description

Render the Download info for the resource tool (on view page)

Parameters

ColumnTypeDefaultDescription
$ref int Resource ref
$size_info array Preview size information
$downloadthissize bool Should the size be downloadable or requested?
$view_in_browser bool false Allow the size to be viewed directly in the browser

Location

include/render_functions.php lines 6541 to 6676

Definition

 
function add_download_column($ref$size_info$downloadthissize$view_in_browser=false)
    {
    global 
$save_as$terms_download$order_by$lang$baseurl$k$search$request_adds_to_collection$offset$archive$sort$internal_share_access$urlparams$resource$iOS_save,$download_usage;
    
$view_in_browser_msg $view_in_browser $lang["view_in_browser"] : $lang["action-download"];
    if (
$downloadthissize)
        {
        
?>
        <td class="DownloadButton">
            
            
global $size_info_array;
            
$size_info_array $size_info;
            if(!
hook("downloadbuttonreplace"))
                {
                if(
$terms_download || $save_as)
                    {
                    
?>
                    <a id="downloadlink"
                        
                        
if (!hook("downloadlink","",array("ref=" $ref "&k=" $k "&size=" $size_info["id"] . "&ext=" $size_info["extension"], $view_in_browser)))
                            {
                            if (
$view_in_browser)
                                {
                                echo 
"href=\"" generateURL($baseurl "/pages/terms.php",$urlparams,array("url"=> generateURL($baseurl "/pages/download.php",$urlparams,array("size"=>$size_info["id"],"ext"=> $size_info["extension"],"direct"=>1,"noattach"=>true)))) . "\"";
                                }
                            else
                                {
                                echo 
"href=\"" generateURL($baseurl "/pages/terms.php",$urlparams,array("url"=> generateURL($baseurl "/pages/download_progress.php",$urlparams,array("size"=>$size_info["id"],"ext"=> $size_info["extension"])))) . "\"";
                                }
                            }

                        if(
$iOS_save || $view_in_browser)
                            {
                            echo 
" target=\"_blank\"";
                            }
                        else
                            {
                            echo 
" onClick=\"return CentralSpaceLoad(this,true);\"";
                            }
                        
?>>
                         echo escape($view_in_browser_msg); ?>
                    </a>
                    
                    
}
                elseif (
$download_usage)
                    
// download usage form displayed - load into main window
                    

                    
?>
                    <a id="downloadlink"
                        
                        
if (!hook("downloadlink","",array("ref=" $ref "&k=" $k "&size=" $size_info["id"]. "&ext=" $size_info["extension"])))
                            {
                            if (
$view_in_browser)
                                {
                                echo 
"href=\"" generateURL($baseurl "/pages/download_usage.php",$urlparams,array("url"=> generateURL($baseurl "/pages/download.php",$urlparams,array("size"=>$size_info["id"],"ext"=> $size_info["extension"],"direct"=>1,"noattach"=>true)))) . "\"";
                                }
                            else
                                {
                                echo 
"href=\"" generateURL($baseurl "/pages/download_usage.php",$urlparams,array("url"=> generateURL($baseurl "/pages/download_progress.php",$urlparams,array("size"=>$size_info["id"],"ext"=> $size_info["extension"])))) . "\"";
                                }
                            }

                        if(
$iOS_save || $view_in_browser)
                            {
                            echo 
" target=\"_blank\"";
                            }
                        else
                            {
                            echo 
" onClick=\"return CentralSpaceLoad(this,true);\"";
                            }
                        
?>>
                         echo escape($view_in_browser_msg); ?>
                    </a>
                    
                    
}
                else
                    {
                    
?>
                    <a id="downloadlink"
                        
                        
if (!hook("downloadlink","",array("ref=" $ref "&k=" $k "&size=" $size_info["id"]. "&ext=" $size_info["extension"], $view_in_browser)))
                            {
                            if (
$view_in_browser)
                                {
                                echo 
'href="' $baseurl "/pages/download.php?direct=1&noattach=true&ref=" urlencode($ref) . "&ext=" $size_info['extension'] . "&k=" urlencode($k) . '" target="_blank"';
                                }
                            else
                                {
                                echo 
'href="#" onclick="directDownload(' '\'' $baseurl '/pages/download_progress.php?ref=' urlencode($ref) . '&size=' $size_info['id'] . '&ext=' $size_info['extension'] . '&k=' urlencode($k) . '\'' ', this)"';
                                }
                            }
                        
?>>
                         echo escape($view_in_browser_msg); ?>
                    </a>
                    
                    
}

                unset(
$size_info_array);
                }
            
?>
        </td>
        
        
}
    elseif (
checkperm("q"))
        {
        if (!
hook("resourcerequest"))
            {
            
?>
            <td class="DownloadButton">
                
                
if ($request_adds_to_collection && ($k=="" || $internal_share_access) && !checkperm('b')) // We can't add to a collection if we are accessing an external share, unless we are a logged in user
                    
{
                    if (isset(
$size_info["id"])) 
                        {
                        echo 
add_to_collection_link($ref,"alert('" escape($lang["requestaddedtocollection"]) . "');",$size_info["id"]);
                        }
                    else
                        {
                        echo 
add_to_collection_link($ref);
                        }
                    }
                else
                    {
                    
?><a href=" echo generateURL($baseurl "/pages/resource_request.php",$urlparams?>" onClick="return CentralSpaceLoad(this,true);">
                    
}
                echo 
escape($lang["action-request"]) ?>
                </a>
            </td>
            
            
}
        }
    else
        {
        
# No access to this size, and the request functionality has been disabled. Show just 'restricted'.
        
?><td class="DownloadButton DownloadDisabled"> echo escape($lang["access1"])?></td>
        
}
    }

This article was last updated 24th May 2024 12:05 Europe/London time based on the source file dated 23rd May 2024 10:00 Europe/London time.