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

collection_download_process_data_only_types()

Description

Add PDFs for "data only" types to a zip file during creation.

Parameters

ColumnTypeDefaultDescription
$dl_data array Array of collection download data
&$zip
$zip object Collection zip file

Return

void

Location

include/collections_functions.php lines 4505 to 4561

Definition

 
function collection_download_process_data_only_types(array $dl_data, &$zip)
{
    
$result $dl_data['collection_resources'] ?? [];

    for (
$n 0$n count($result); $n++) {
        
// Data-only type of resources should be generated and added in the archive
        
if (in_array($result[$n]['resource_type'], $GLOBALS["data_only_resource_types"])) {
            
$template_path get_pdf_template_path($result[$n]['resource_type']);
            if (
$template_path === false) {
                continue;
            }
            
$pdf_filename 'RS_' $result[$n]['ref'] . '_data_only.pdf';
            
$pdf_file_path get_temp_dir(false$dl_data['id']) . '/' $pdf_filename;

            
// Go through fields and decide which ones we add to the template
            
$placeholders = array(
                
'resource_type_name' => get_resource_type_name($result[$n]['resource_type'])
            );

            
$metadata get_resource_field_data($result[$n]['ref'], falsetruenull'' != $GLOBALS["k"]);

            foreach (
$metadata as $metadata_field) {
                
$metadata_field_value trim(tidylist(i18n_get_translated($metadata_field['value'])));

                
// Skip if empty
                
if ('' == $metadata_field_value) {
                    continue;
                }

                
$placeholders['metadatafield-' $metadata_field['ref'] . ':title'] = $metadata_field['title'];
                
$placeholders['metadatafield-' $metadata_field['ref'] . ':value'] = $metadata_field_value;
            }
            
generate_pdf($template_path$pdf_file_path$placeholderstrue);

            
// Go and add file to archive
            
if ($dl_data['collection_download_tar']) {
                
// Add a link to the pdf
                
$usertempdir get_temp_dir(false"rs_" $GLOBALS["userref"] . "_" $dl_data['id']);
                
symlink($pdf_file_path$usertempdir DIRECTORY_SEPARATOR  $pdf_filename);
            } elseif (
$GLOBALS["use_zip_extension"]) {
                
debug("Adding $pdf_file_path to " $zip->filename);
                
$zip->addFile($pdf_file_path$pdf_filename);
            } else {
                
$dl_data['includefiles'][] = $pdf_file_path "\r\n";
            }
            
$dl_data['deletion_array'][] = $pdf_file_path;
            
            
daily_stat('Resource download'$result[$n]['ref']);
            
resource_log($result[$n]['ref'], 'd'0$GLOBALS['lang']['pdffile'] . " - " $dl_data['usagecomment'], '''',(int) $dl_data['usage']);

            if (
$GLOBALS["resource_hit_count_on_downloads"]) {
                
$resource_ref_escaped $result[$n]['ref'];
                
ps_query("UPDATE resource SET new_hit_count = GREATEST(hit_count, new_hit_count) + 1 WHERE ref = ?", array("i",$resource_ref_escaped));
            }
        }
    }
}

This article was last updated 17th June 2025 21:35 Europe/London time based on the source file dated 13th June 2025 14:00 Europe/London time.